Raft: Fix item prefilling (#1878)
This commit is contained in:
parent
a75159b57e
commit
afe9e12ef4
|
@ -50,9 +50,16 @@ class RaftWorld(World):
|
|||
maximumResourcePackAmount = max(minRPSpecified, maxRPSpecified)
|
||||
# Generate item pool
|
||||
pool = []
|
||||
frequencyItems = []
|
||||
for item in item_table:
|
||||
raft_item = self.create_item_replaceAsNecessary(item["name"])
|
||||
if "Frequency" in item["name"]:
|
||||
frequencyItems.append(raft_item)
|
||||
pool.append(raft_item)
|
||||
if self.multiworld.island_frequency_locations[self.player].value <= 3:
|
||||
if not hasattr(self.multiworld, "raft_frequencyItemsPerPlayer"):
|
||||
self.multiworld.raft_frequencyItemsPerPlayer = {}
|
||||
self.multiworld.raft_frequencyItemsPerPlayer[self.player] = frequencyItems
|
||||
|
||||
extraItemNamePool = []
|
||||
extras = len(location_table) - len(item_table) - 1 # Victory takes up 1 unaccounted-for slot
|
||||
|
@ -66,6 +73,16 @@ class RaftWorld(World):
|
|||
dupeItemPool = item_table.copy()
|
||||
# Remove frequencies if necessary
|
||||
if self.multiworld.island_frequency_locations[self.player].value != 5: # Not completely random locations
|
||||
# If we let frequencies stay in with progressive-frequencies, the progressive-frequency item
|
||||
# will be included 7 times. This is a massive flood of progressive-frequency items, so we
|
||||
# instead add progressive-frequency as its own item a smaller amount of times to prevent
|
||||
# flooding the duplicate item pool with them.
|
||||
if self.multiworld.island_frequency_locations[self.player].value == 4:
|
||||
for _ in range(2):
|
||||
# Progressives are not in item_pool, need to create faux item for duplicate item pool
|
||||
# This can still be filtered out later by duplicate_items setting
|
||||
dupeItemPool.append({ "name": "progressive-frequency", "progression": True }) # Progressive frequencies need to be included
|
||||
# Always remove non-progressive Frequency items
|
||||
dupeItemPool = (itm for itm in dupeItemPool if "Frequency" not in itm["name"])
|
||||
|
||||
# Remove progression or non-progression items if necessary
|
||||
|
@ -129,7 +146,7 @@ class RaftWorld(World):
|
|||
return super(RaftWorld, self).collect_item(state, item, remove)
|
||||
|
||||
def pre_fill(self):
|
||||
if self.multiworld.island_frequency_locations[self.player] == 0:
|
||||
if self.multiworld.island_frequency_locations[self.player] == 0: # Vanilla
|
||||
self.setLocationItem("Radio Tower Frequency to Vasagatan", "Vasagatan Frequency")
|
||||
self.setLocationItem("Vasagatan Frequency to Balboa", "Balboa Island Frequency")
|
||||
self.setLocationItem("Relay Station quest", "Caravan Island Frequency")
|
||||
|
@ -137,7 +154,7 @@ class RaftWorld(World):
|
|||
self.setLocationItem("Tangaroa Frequency to Varuna Point", "Varuna Point Frequency")
|
||||
self.setLocationItem("Varuna Point Frequency to Temperance", "Temperance Frequency")
|
||||
self.setLocationItem("Temperance Frequency to Utopia", "Utopia Frequency")
|
||||
elif self.multiworld.island_frequency_locations[self.player] == 1:
|
||||
elif self.multiworld.island_frequency_locations[self.player] == 1: # Random on island
|
||||
self.setLocationItemFromRegion("RadioTower", "Vasagatan Frequency")
|
||||
self.setLocationItemFromRegion("Vasagatan", "Balboa Island Frequency")
|
||||
self.setLocationItemFromRegion("BalboaIsland", "Caravan Island Frequency")
|
||||
|
@ -173,9 +190,9 @@ class RaftWorld(World):
|
|||
else:
|
||||
currentLocation = availableLocationList[0] # Utopia (only one left in list)
|
||||
availableLocationList.remove(currentLocation)
|
||||
if self.multiworld.island_frequency_locations[self.player] == 2:
|
||||
if self.multiworld.island_frequency_locations[self.player] == 2: # Random island order
|
||||
self.setLocationItem(locationToVanillaFrequencyLocationMap[previousLocation], locationToFrequencyItemMap[currentLocation])
|
||||
elif self.multiworld.island_frequency_locations[self.player] == 3:
|
||||
elif self.multiworld.island_frequency_locations[self.player] == 3: # Random on island random order
|
||||
self.setLocationItemFromRegion(previousLocation, locationToFrequencyItemMap[currentLocation])
|
||||
previousLocation = currentLocation
|
||||
|
||||
|
@ -184,12 +201,14 @@ class RaftWorld(World):
|
|||
RaftItem("Victory", ItemClassification.progression, None, player=self.player))
|
||||
|
||||
def setLocationItem(self, location: str, itemName: str):
|
||||
itemToUse = next(filter(lambda itm: itm.name == itemName, self.multiworld.itempool))
|
||||
itemToUse = next(filter(lambda itm: itm.name == itemName, self.multiworld.raft_frequencyItemsPerPlayer[self.player]))
|
||||
self.multiworld.raft_frequencyItemsPerPlayer[self.player].remove(itemToUse)
|
||||
self.multiworld.itempool.remove(itemToUse)
|
||||
self.multiworld.get_location(location, self.player).place_locked_item(itemToUse)
|
||||
|
||||
def setLocationItemFromRegion(self, region: str, itemName: str):
|
||||
itemToUse = next(filter(lambda itm: itm.name == itemName, self.multiworld.itempool))
|
||||
itemToUse = next(filter(lambda itm: itm.name == itemName, self.multiworld.raft_frequencyItemsPerPlayer[self.player]))
|
||||
self.multiworld.raft_frequencyItemsPerPlayer[self.player].remove(itemToUse)
|
||||
self.multiworld.itempool.remove(itemToUse)
|
||||
location = random.choice(list(loc for loc in location_table if loc["region"] == region))
|
||||
self.multiworld.get_location(location["name"], self.player).place_locked_item(itemToUse)
|
||||
|
|
Loading…
Reference in New Issue