From 88451d42397340bb52192e0cac525678862216e5 Mon Sep 17 00:00:00 2001 From: espeon65536 Date: Wed, 1 Sep 2021 13:20:43 -0500 Subject: [PATCH] Skip caching get_all_state while setting rules Since rules have not been set for later worlds, the cache believes the completion condition is freely available if it had been placed previously, which breaks beatable-only key placement. --- BaseClasses.py | 5 +++-- worlds/alttp/Rules.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/BaseClasses.py b/BaseClasses.py index a041df9a..dc3db0c4 100644 --- a/BaseClasses.py +++ b/BaseClasses.py @@ -213,7 +213,7 @@ class MultiWorld(): except KeyError as e: raise KeyError('No such dungeon %s for player %d' % (dungeonname, player)) from e - def get_all_state(self) -> CollectionState: + def get_all_state(self, save_cache=True) -> CollectionState: cached = getattr(self, "_all_state", None) if cached: return cached.copy() @@ -229,7 +229,8 @@ class MultiWorld(): subworld.collect(ret, item) ret.sweep_for_events() - self._all_state = ret + if save_cache: + self._all_state = ret return ret def get_items(self) -> list: diff --git a/worlds/alttp/Rules.py b/worlds/alttp/Rules.py index 4e986c0d..2fd452ab 100644 --- a/worlds/alttp/Rules.py +++ b/worlds/alttp/Rules.py @@ -853,7 +853,7 @@ def set_trock_key_rules(world, player): for entrance in ['Turtle Rock Dark Room Staircase', 'Turtle Rock (Chain Chomp Room) (North)', 'Turtle Rock (Chain Chomp Room) (South)', 'Turtle Rock Pokey Room', 'Turtle Rock Big Key Door']: set_rule(world.get_entrance(entrance, player), lambda state: False) - all_state = world.get_all_state() + all_state = world.get_all_state(save_cache=False) all_state.reachable_regions[player] = set() # wipe reachable regions so that the locked doors actually work all_state.stale[player] = True