Fill: fix placing non_local + non advancement items

This commit is contained in:
Fabian Dill
2021-08-30 22:20:44 +02:00
parent 4520051ec9
commit fd6e009c4b
3 changed files with 16 additions and 3 deletions

13
Fill.py
View File

@@ -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)