From a87a79eb005132711c8d4b706e12484ce101f678 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Sun, 17 Jan 2021 22:08:28 +0100 Subject: [PATCH] remove some duplicate code --- Fill.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Fill.py b/Fill.py index 47038a31..0c694898 100644 --- a/Fill.py +++ b/Fill.py @@ -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)