RoR2: Move filler item creation to `get_filler_item_name` (#2075)
This commit is contained in:
parent
7ce9f20bc7
commit
b235ba2c52
|
@ -40,6 +40,10 @@ class RiskOfRainWorld(World):
|
|||
web = RiskOfWeb()
|
||||
total_revivals: int
|
||||
|
||||
def __init__(self, multiworld: "MultiWorld", player: int):
|
||||
super().__init__(multiworld, player)
|
||||
self.junk_pool: Dict[str, int] = {}
|
||||
|
||||
def generate_early(self) -> None:
|
||||
# figure out how many revivals should exist in the pool
|
||||
if self.multiworld.goal[self.player] == "classic":
|
||||
|
@ -87,6 +91,52 @@ class RiskOfRainWorld(World):
|
|||
self.multiworld.push_precollected(self.create_item(unlock[0]))
|
||||
environments_pool.pop(unlock[0])
|
||||
|
||||
# Generate item pool
|
||||
itempool: List = []
|
||||
# Add revive items for the player
|
||||
itempool += ["Dio's Best Friend"] * self.total_revivals
|
||||
itempool += ["Beads of Fealty"]
|
||||
|
||||
for env_name, _ in environments_pool.items():
|
||||
itempool += [env_name]
|
||||
|
||||
if self.multiworld.goal[self.player] == "classic":
|
||||
# classic mode
|
||||
total_locations = self.multiworld.total_locations[self.player].value
|
||||
else:
|
||||
# explore mode
|
||||
total_locations = len(
|
||||
orderedstage_location.get_locations(
|
||||
chests=self.multiworld.chests_per_stage[self.player].value,
|
||||
shrines=self.multiworld.shrines_per_stage[self.player].value,
|
||||
scavengers=self.multiworld.scavengers_per_stage[self.player].value,
|
||||
scanners=self.multiworld.scanner_per_stage[self.player].value,
|
||||
altars=self.multiworld.altars_per_stage[self.player].value,
|
||||
dlc_sotv=self.multiworld.dlc_sotv[self.player].value
|
||||
)
|
||||
)
|
||||
# Create junk items
|
||||
self.junk_pool = self.create_junk_pool()
|
||||
# Fill remaining items with randomly generated junk
|
||||
while len(itempool) < total_locations:
|
||||
itempool.append(self.get_filler_item_name())
|
||||
|
||||
# Convert itempool into real items
|
||||
itempool = list(map(lambda name: self.create_item(name), itempool))
|
||||
self.multiworld.itempool += itempool
|
||||
|
||||
def set_rules(self) -> None:
|
||||
set_rules(self.multiworld, self.player)
|
||||
|
||||
def get_filler_item_name(self) -> str:
|
||||
if not self.junk_pool:
|
||||
self.junk_pool = self.create_junk_pool()
|
||||
weights = [data for data in self.junk_pool.values()]
|
||||
filler = self.multiworld.random.choices([filler for filler in self.junk_pool.keys()], weights,
|
||||
k=1)[0]
|
||||
return filler
|
||||
|
||||
def create_junk_pool(self) -> Dict:
|
||||
# if presets are enabled generate junk_pool from the selected preset
|
||||
pool_option = self.multiworld.item_weights[self.player].value
|
||||
junk_pool: Dict[str, int] = {}
|
||||
|
@ -119,42 +169,7 @@ class RiskOfRainWorld(World):
|
|||
if not (self.multiworld.dlc_sotv[self.player] or pool_option == ItemWeights.option_void):
|
||||
junk_pool.pop("Void Item")
|
||||
|
||||
# Generate item pool
|
||||
itempool: List = []
|
||||
# Add revive items for the player
|
||||
itempool += ["Dio's Best Friend"] * self.total_revivals
|
||||
itempool += ["Beads of Fealty"]
|
||||
|
||||
for env_name, _ in environments_pool.items():
|
||||
itempool += [env_name]
|
||||
|
||||
nonjunk_item_count = len(itempool)
|
||||
if self.multiworld.goal[self.player] == "classic":
|
||||
# classic mode
|
||||
total_locations = self.multiworld.total_locations[self.player].value
|
||||
else:
|
||||
# explore mode
|
||||
total_locations = len(
|
||||
orderedstage_location.get_locations(
|
||||
chests=self.multiworld.chests_per_stage[self.player].value,
|
||||
shrines=self.multiworld.shrines_per_stage[self.player].value,
|
||||
scavengers=self.multiworld.scavengers_per_stage[self.player].value,
|
||||
scanners=self.multiworld.scanner_per_stage[self.player].value,
|
||||
altars=self.multiworld.altars_per_stage[self.player].value,
|
||||
dlc_sotv=self.multiworld.dlc_sotv[self.player].value
|
||||
)
|
||||
)
|
||||
junk_item_count = total_locations - nonjunk_item_count
|
||||
# Fill remaining items with randomly generated junk
|
||||
itempool += self.multiworld.random.choices(list(junk_pool.keys()), weights=list(junk_pool.values()),
|
||||
k=junk_item_count)
|
||||
|
||||
# Convert itempool into real items
|
||||
itempool = list(map(lambda name: self.create_item(name), itempool))
|
||||
self.multiworld.itempool += itempool
|
||||
|
||||
def set_rules(self) -> None:
|
||||
set_rules(self.multiworld, self.player)
|
||||
return junk_pool
|
||||
|
||||
def create_regions(self) -> None:
|
||||
|
||||
|
@ -213,7 +228,7 @@ class RiskOfRainWorld(World):
|
|||
classification = ItemClassification.trap
|
||||
|
||||
# Only check for an item to be a environment unlock if those are known to be in the pool.
|
||||
# This should shave down comparions.
|
||||
# This should shave down comparisons.
|
||||
|
||||
elif name in environment_ALL_table.keys():
|
||||
if name in {"Hidden Realm: Bulwark's Ambry", "Hidden Realm: Gilded Coast,"}:
|
||||
|
|
Loading…
Reference in New Issue