From fd6e009c4bbc31531911a9af197672aaee7c81ab Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Mon, 30 Aug 2021 22:20:44 +0200 Subject: [PATCH] Fill: fix placing non_local + non advancement items --- Fill.py | 13 ++++++++++++- worlds/AutoWorld.py | 3 ++- worlds/alttp/__init__.py | 3 ++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Fill.py b/Fill.py index 20c3e54d..62d45668 100644 --- a/Fill.py +++ b/Fill.py @@ -81,6 +81,7 @@ def distribute_items_restrictive(world: MultiWorld, fill_locations=None): progitempool = [] nonexcludeditempool = [] localrestitempool = {player: [] for player in range(1, world.players + 1)} + nonlocalrestitempool = [] restitempool = [] for item in world.itempool: @@ -90,11 +91,13 @@ def distribute_items_restrictive(world: MultiWorld, fill_locations=None): nonexcludeditempool.append(item) elif item.name in world.local_items[item.player]: localrestitempool[item.player].append(item) + elif item.name in world.non_local_items[item.player]: + nonlocalrestitempool.append(item) else: restitempool.append(item) world.random.shuffle(fill_locations) - call_all(world, "fill_hook", progitempool, nonexcludeditempool, localrestitempool, restitempool, fill_locations) + call_all(world, "fill_hook", progitempool, nonexcludeditempool, localrestitempool, nonlocalrestitempool, restitempool, fill_locations) fill_restrictive(world, world.state, fill_locations, progitempool) @@ -120,6 +123,14 @@ def distribute_items_restrictive(world: MultiWorld, fill_locations=None): world.push_item(spot_to_fill, item_to_place, False) fill_locations.remove(spot_to_fill) + for item_to_place in nonlocalrestitempool: + for i, location in enumerate(fill_locations): + if location.player != item_to_place.player: + world.push_item(fill_locations.pop(i), item_to_place, False) + break + else: + logging.warning(f"Could not place non_local_item {item_to_place} among {fill_locations}, tossing.") + world.random.shuffle(fill_locations) restitempool, fill_locations = fast_fill(world, restitempool, fill_locations) diff --git a/worlds/AutoWorld.py b/worlds/AutoWorld.py index cc1ac665..96358fd6 100644 --- a/worlds/AutoWorld.py +++ b/worlds/AutoWorld.py @@ -133,7 +133,8 @@ class World(metaclass=AutoWorldRegister): pass def fill_hook(cls, progitempool: List[Item], nonexcludeditempool: List[Item], - localrestitempool: Dict[int, List[Item]], restitempool: List[Item], fill_locations: List[Location]): + localrestitempool: Dict[int, List[Item]], nonlocalrestitempool: Dict[int, List[Item]], + restitempool: List[Item], fill_locations: List[Location]): """Special method that gets called as part of distribute_items_restrictive (main fill). This gets called once per present world type.""" pass diff --git a/worlds/alttp/__init__.py b/worlds/alttp/__init__.py index 61fdaff6..10006daf 100644 --- a/worlds/alttp/__init__.py +++ b/worlds/alttp/__init__.py @@ -320,7 +320,8 @@ class ALTTPWorld(World): return ALttPItem(name, self.player, **as_dict_item_table[name]) @classmethod - def stage_fill_hook(cls, world, progitempool, nonexcludeditempool, localrestitempool, restitempool, fill_locations): + def stage_fill_hook(cls, world, progitempool, nonexcludeditempool, localrestitempool, nonlocalrestitempool, + restitempool, fill_locations): trash_counts = {} standard_keyshuffle_players = set() for player in world.get_game_players("A Link to the Past"):