Core: make fulfills_accessibility deterministic and fix some typing
This commit is contained in:
parent
bea8d37a3c
commit
2db55ac50b
|
@ -541,9 +541,11 @@ class MultiWorld():
|
||||||
"""Check if accessibility rules are fulfilled with current or supplied state."""
|
"""Check if accessibility rules are fulfilled with current or supplied state."""
|
||||||
if not state:
|
if not state:
|
||||||
state = CollectionState(self)
|
state = CollectionState(self)
|
||||||
players = {"minimal": set(),
|
players: Dict[str, Set[int]] = {
|
||||||
|
"minimal": set(),
|
||||||
"items": set(),
|
"items": set(),
|
||||||
"locations": set()}
|
"locations": set()
|
||||||
|
}
|
||||||
for player, access in self.accessibility.items():
|
for player, access in self.accessibility.items():
|
||||||
players[access.current_key].add(player)
|
players[access.current_key].add(player)
|
||||||
|
|
||||||
|
@ -563,20 +565,22 @@ class MultiWorld():
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def all_done():
|
def all_done() -> bool:
|
||||||
"""Check if all access rules are fulfilled"""
|
"""Check if all access rules are fulfilled"""
|
||||||
if beatable_fulfilled:
|
if not beatable_fulfilled:
|
||||||
|
return False
|
||||||
if any(location_condition(location) for location in locations):
|
if any(location_condition(location) for location in locations):
|
||||||
return False # still locations required to be collected
|
return False # still locations required to be collected
|
||||||
return True
|
return True
|
||||||
|
|
||||||
locations = {location for location in self.get_locations() if location_relevant(location)}
|
locations = [location for location in self.get_locations() if location_relevant(location)]
|
||||||
|
|
||||||
while locations:
|
while locations:
|
||||||
sphere = set()
|
sphere: List[Location] = []
|
||||||
for location in locations:
|
for location in locations:
|
||||||
if location.can_reach(state):
|
if location.can_reach(state):
|
||||||
sphere.add(location)
|
assert location not in sphere
|
||||||
|
sphere.append(location)
|
||||||
|
|
||||||
if not sphere:
|
if not sphere:
|
||||||
# ran out of places and did not finish yet, quit
|
# ran out of places and did not finish yet, quit
|
||||||
|
@ -586,6 +590,7 @@ class MultiWorld():
|
||||||
|
|
||||||
for location in sphere:
|
for location in sphere:
|
||||||
locations.remove(location)
|
locations.remove(location)
|
||||||
|
if location.item:
|
||||||
state.collect(location.item, True, location)
|
state.collect(location.item, True, location)
|
||||||
|
|
||||||
if self.has_beaten_game(state):
|
if self.has_beaten_game(state):
|
||||||
|
|
Loading…
Reference in New Issue