diff --git a/worlds/raft/__init__.py b/worlds/raft/__init__.py index 1ecf3ede12e9..62816cb09f67 100644 --- a/worlds/raft/__init__.py +++ b/worlds/raft/__init__.py @@ -50,9 +50,16 @@ def create_items(self): 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 @@ def create_items(self): 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 @@ def collect_item(self, state, item, remove=False): 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 @@ def pre_fill(self): 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 @@ def pre_fill(self): 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 @@ def pre_fill(self): 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)