remove some duplicate code

This commit is contained in:
Fabian Dill 2021-01-17 22:08:28 +01:00
parent 0286a81755
commit a87a79eb00
1 changed files with 7 additions and 5 deletions

12
Fill.py
View File

@ -257,6 +257,11 @@ def balance_multiworld_progression(world):
reachable_locations_count = {player: 0 for player in range(1, world.players + 1)}
def event_key(location):
return location.event and (
world.keyshuffle[location.item.player] or not location.item.smallkey) and (
world.bigkeyshuffle[location.item.player] or not location.item.bigkey)
def get_sphere_locations(sphere_state, locations):
sphere_state.sweep_for_events(key_only=True, locations=locations)
return [loc for loc in locations if sphere_state.can_reach(loc)]
@ -279,9 +284,7 @@ def balance_multiworld_progression(world):
candidate_items = []
while True:
for location in balancing_sphere:
if location.event and (
world.keyshuffle[location.item.player] or not location.item.smallkey) and (
world.bigkeyshuffle[location.item.player] or not location.item.bigkey):
if event_key(location):
balancing_state.collect(location.item, True, location)
if location.item.player in balancing_players and not location.locked:
candidate_items.append(location)
@ -342,8 +345,7 @@ def balance_multiworld_progression(world):
sphere_locations.append(location)
for location in sphere_locations:
if location.event and (world.keyshuffle[location.item.player] or not location.item.smallkey) and (
world.bigkeyshuffle[location.item.player] or not location.item.bigkey):
if event_key(location):
state.collect(location.item, True, location)
checked_locations.extend(sphere_locations)