From c73b994305e866642eedce3db1221067323181c1 Mon Sep 17 00:00:00 2001 From: espeon65536 Date: Wed, 1 Sep 2021 14:01:54 -0500 Subject: [PATCH] use_cache argument to get_all_state --- BaseClasses.py | 6 +++--- worlds/alttp/Dungeons.py | 2 +- worlds/alttp/Rules.py | 2 +- worlds/alttp/__init__.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/BaseClasses.py b/BaseClasses.py index dc3db0c4..55f88efe 100644 --- a/BaseClasses.py +++ b/BaseClasses.py @@ -213,9 +213,9 @@ class MultiWorld(): except KeyError as e: raise KeyError('No such dungeon %s for player %d' % (dungeonname, player)) from e - def get_all_state(self, save_cache=True) -> CollectionState: + def get_all_state(self, use_cache: bool) -> CollectionState: cached = getattr(self, "_all_state", None) - if cached: + if use_cache and cached: return cached.copy() ret = CollectionState(self) @@ -229,7 +229,7 @@ class MultiWorld(): subworld.collect(ret, item) ret.sweep_for_events() - if save_cache: + if use_cache: self._all_state = ret return ret diff --git a/worlds/alttp/Dungeons.py b/worlds/alttp/Dungeons.py index 000af504..4b0814d3 100644 --- a/worlds/alttp/Dungeons.py +++ b/worlds/alttp/Dungeons.py @@ -149,7 +149,7 @@ def fill_dungeons_restrictive(autoworld, world): (not (item.player, item.name) in dungeon_specific or item.dungeon is dungeon) and orig_rule(item) world.random.shuffle(locations) - all_state_base = world.get_all_state() + all_state_base = world.get_all_state(use_cache=True) # Dungeon-locked items have to be placed first, to not run out of spaces for dungeon-locked items # subsort in the order Big Key, Small Key, Other before placing dungeon items diff --git a/worlds/alttp/Rules.py b/worlds/alttp/Rules.py index 2fd452ab..ca0857cd 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(save_cache=False) + all_state = world.get_all_state(use_cache=False) all_state.reachable_regions[player] = set() # wipe reachable regions so that the locked doors actually work all_state.stale[player] = True diff --git a/worlds/alttp/__init__.py b/worlds/alttp/__init__.py index b7bdb348..fd04cd47 100644 --- a/worlds/alttp/__init__.py +++ b/worlds/alttp/__init__.py @@ -212,7 +212,7 @@ class ALTTPWorld(World): attempts = 5 world = self.world player = self.player - all_state = world.get_all_state() + all_state = world.get_all_state(use_cache=True) crystals = [self.create_item(name) for name in ['Red Pendant', 'Blue Pendant', 'Green Pendant', 'Crystal 1', 'Crystal 2', 'Crystal 3', 'Crystal 4', 'Crystal 7', 'Crystal 5', 'Crystal 6']] crystal_locations = [world.get_location('Turtle Rock - Prize', player), world.get_location('Eastern Palace - Prize', player),