From cc0540d3fb06c51652248363748e30a8f12fddf6 Mon Sep 17 00:00:00 2001 From: lordlou <87331798+lordlou@users.noreply.github.com> Date: Mon, 6 Feb 2023 21:14:03 -0500 Subject: [PATCH] SMZ3: keysanity accessibility fix (#1428) --- worlds/smz3/__init__.py | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/worlds/smz3/__init__.py b/worlds/smz3/__init__.py index 5e91b533b..35e7ea663 100644 --- a/worlds/smz3/__init__.py +++ b/worlds/smz3/__init__.py @@ -244,12 +244,12 @@ def set_rules(self): if self.multiworld.accessibility[self.player] != 'locations': l.always_allow = lambda state, item, loc=loc: \ item.game == "SMZ3" and \ - loc.alwaysAllow(TotalSMZ3Item.Item(TotalSMZ3Item.ItemType[item.name], self.smz3World), state.smz3state[self.player]) + loc.alwaysAllow(item.item, state.smz3state[self.player]) old_rule = l.item_rule l.item_rule = lambda item, loc=loc, region=region: (\ item.game != "SMZ3" or \ - loc.allow(TotalSMZ3Item.Item(TotalSMZ3Item.ItemType[item.name], self.smz3World), None) and \ - region.CanFill(TotalSMZ3Item.Item(TotalSMZ3Item.ItemType[item.name], self.smz3World))) and old_rule(item) + loc.allow(item.item, None) and \ + region.CanFill(item.item)) and old_rule(item) set_rule(l, lambda state, loc=loc: loc.Available(state.smz3state[self.player])) def create_regions(self): @@ -502,17 +502,6 @@ def pre_fill(self): all_dungeonItems = self.smz3DungeonItems[:] fill_restrictive(self.multiworld, all_state, locations, all_dungeonItems, True, True) - # some small or big keys (those always_allow) can be unreachable in-game - # while logic still collects some of them (probably to simulate the player collecting pot keys in the logic), some others don't - # so we need to remove those exceptions as progression items - if self.multiworld.accessibility[self.player] != 'locations': - exception_item = [TotalSMZ3Item.ItemType.BigKeySW, TotalSMZ3Item.ItemType.BigKeySP, TotalSMZ3Item.ItemType.KeyTH] - for item in self.smz3DungeonItems: - if item.item.Type in exception_item and item.location.always_allow(all_state, item) and not all_state.can_reach(item.location): - item.classification = ItemClassification.filler - item.item.Progression = False - item.location.event = False - self.unreachable.append(item.location) self.JunkFillGT(0.5) def get_pre_fill_items(self): @@ -520,6 +509,22 @@ def get_pre_fill_items(self): return self.smz3DungeonItems else: return [] + + def post_fill(self): + # some small or big keys (those always_allow) can be unreachable in-game + # while logic still collects some of them (probably to simulate the player collecting pot keys in the logic), some others don't + # so we need to remove those exceptions as progression items + if self.multiworld.accessibility[self.player] == 'items': + state = CollectionState(self.multiworld) + locs = [self.multiworld.get_location("Swamp Palace - Big Chest", self.player), + self.multiworld.get_location("Skull Woods - Big Chest", self.player), + self.multiworld.get_location("Tower of Hera - Big Key Chest", self.player)] + for loc in locs: + if (loc.item.player == self.player and loc.always_allow(state, loc.item)): + loc.item.classification = ItemClassification.filler + loc.item.item.Progression = False + loc.item.location.event = False + self.unreachable.append(loc) def get_filler_item_name(self) -> str: return self.multiworld.random.choice(self.junkItemsNames)