Core: some typing and documentation in BaseClasses.py (#2589)

This commit is contained in:
Doug Hoskisson 2023-12-09 21:43:17 -08:00 committed by GitHub
parent c3184e7b19
commit b0a09f67f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 4 deletions

View File

@ -491,7 +491,7 @@ class MultiWorld():
else: else:
return all((self.has_beaten_game(state, p) for p in range(1, self.players + 1))) return all((self.has_beaten_game(state, p) for p in range(1, self.players + 1)))
def can_beat_game(self, starting_state: Optional[CollectionState] = None): def can_beat_game(self, starting_state: Optional[CollectionState] = None) -> bool:
if starting_state: if starting_state:
if self.has_beaten_game(starting_state): if self.has_beaten_game(starting_state):
return True return True
@ -504,7 +504,7 @@ class MultiWorld():
and location.item.advancement and location not in state.locations_checked} and location.item.advancement and location not in state.locations_checked}
while prog_locations: while prog_locations:
sphere = set() sphere: Set[Location] = set()
# build up spheres of collection radius. # build up spheres of collection radius.
# Everything in each sphere is independent from each other in dependencies and only depends on lower spheres # Everything in each sphere is independent from each other in dependencies and only depends on lower spheres
for location in prog_locations: for location in prog_locations:
@ -524,12 +524,19 @@ class MultiWorld():
return False return False
def get_spheres(self): def get_spheres(self) -> Iterator[Set[Location]]:
"""
yields a set of locations for each logical sphere
If there are unreachable locations, the last sphere of reachable
locations is followed by an empty set, and then a set of all of the
unreachable locations.
"""
state = CollectionState(self) state = CollectionState(self)
locations = set(self.get_filled_locations()) locations = set(self.get_filled_locations())
while locations: while locations:
sphere = set() sphere: Set[Location] = set()
for location in locations: for location in locations:
if location.can_reach(state): if location.can_reach(state):