use_cache argument to get_all_state
This commit is contained in:
parent
88451d4239
commit
c73b994305
|
@ -213,9 +213,9 @@ class MultiWorld():
|
||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
raise KeyError('No such dungeon %s for player %d' % (dungeonname, player)) from 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)
|
cached = getattr(self, "_all_state", None)
|
||||||
if cached:
|
if use_cache and cached:
|
||||||
return cached.copy()
|
return cached.copy()
|
||||||
|
|
||||||
ret = CollectionState(self)
|
ret = CollectionState(self)
|
||||||
|
@ -229,7 +229,7 @@ class MultiWorld():
|
||||||
subworld.collect(ret, item)
|
subworld.collect(ret, item)
|
||||||
ret.sweep_for_events()
|
ret.sweep_for_events()
|
||||||
|
|
||||||
if save_cache:
|
if use_cache:
|
||||||
self._all_state = ret
|
self._all_state = ret
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
|
@ -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)
|
(not (item.player, item.name) in dungeon_specific or item.dungeon is dungeon) and orig_rule(item)
|
||||||
|
|
||||||
world.random.shuffle(locations)
|
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
|
# 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
|
# subsort in the order Big Key, Small Key, Other before placing dungeon items
|
||||||
|
|
||||||
|
|
|
@ -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']:
|
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)
|
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.reachable_regions[player] = set() # wipe reachable regions so that the locked doors actually work
|
||||||
all_state.stale[player] = True
|
all_state.stale[player] = True
|
||||||
|
|
||||||
|
|
|
@ -212,7 +212,7 @@ class ALTTPWorld(World):
|
||||||
attempts = 5
|
attempts = 5
|
||||||
world = self.world
|
world = self.world
|
||||||
player = self.player
|
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']]
|
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),
|
crystal_locations = [world.get_location('Turtle Rock - Prize', player),
|
||||||
world.get_location('Eastern Palace - Prize', player),
|
world.get_location('Eastern Palace - Prize', player),
|
||||||
|
|
Loading…
Reference in New Issue