ALttP: fix dungeon fill failures properly (#1812)
This commit is contained in:
parent
f401702e7c
commit
899de428df
|
@ -1,6 +1,6 @@
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
from BaseClasses import Dungeon
|
from BaseClasses import CollectionState, Dungeon
|
||||||
from Fill import fill_restrictive
|
from Fill import fill_restrictive
|
||||||
|
|
||||||
from .Bosses import BossFactory
|
from .Bosses import BossFactory
|
||||||
|
@ -154,7 +154,6 @@ def fill_dungeons_restrictive(world):
|
||||||
(not (item.player, item.name) in dungeon_specific or item.dungeon is dungeon) and orig_rule(item)
|
(not (item.player, item.name) in dungeon_specific or item.dungeon is dungeon) and orig_rule(item)
|
||||||
|
|
||||||
world.random.shuffle(locations)
|
world.random.shuffle(locations)
|
||||||
all_state_base = world.get_all_state(use_cache=True)
|
|
||||||
# Dungeon-locked items have to be placed first, to not run out of spaces for dungeon-locked items
|
# Dungeon-locked items have to be placed first, to not run out of spaces for dungeon-locked items
|
||||||
# subsort in the order Big Key, Small Key, Other before placing dungeon items
|
# subsort in the order Big Key, Small Key, Other before placing dungeon items
|
||||||
|
|
||||||
|
@ -162,8 +161,25 @@ def fill_dungeons_restrictive(world):
|
||||||
in_dungeon_items.sort(
|
in_dungeon_items.sort(
|
||||||
key=lambda item: sort_order.get(item.type, 1) +
|
key=lambda item: sort_order.get(item.type, 1) +
|
||||||
(5 if (item.player, item.name) in dungeon_specific else 0))
|
(5 if (item.player, item.name) in dungeon_specific else 0))
|
||||||
|
|
||||||
|
# Construct a partial all_state which contains only the items from get_pre_fill_items which aren't in_dungeon
|
||||||
|
in_dungeon_player_ids = {item.player for item in in_dungeon_items}
|
||||||
|
all_state_base = CollectionState(world)
|
||||||
|
for item in world.itempool:
|
||||||
|
world.worlds[item.player].collect(all_state_base, item)
|
||||||
|
pre_fill_items = []
|
||||||
|
for player in in_dungeon_player_ids:
|
||||||
|
pre_fill_items += world.worlds[player].get_pre_fill_items()
|
||||||
for item in in_dungeon_items:
|
for item in in_dungeon_items:
|
||||||
all_state_base.remove(item)
|
try:
|
||||||
|
pre_fill_items.remove(item)
|
||||||
|
except ValueError:
|
||||||
|
# pre_fill_items should be a subset of in_dungeon_items, but just in case
|
||||||
|
pass
|
||||||
|
for item in pre_fill_items:
|
||||||
|
world.worlds[item.player].collect(all_state_base, item)
|
||||||
|
all_state_base.sweep_for_events()
|
||||||
|
|
||||||
|
|
||||||
# Remove completion condition so that minimal-accessibility worlds place keys properly
|
# Remove completion condition so that minimal-accessibility worlds place keys properly
|
||||||
for player in {item.player for item in in_dungeon_items}:
|
for player in {item.player for item in in_dungeon_items}:
|
||||||
|
|
Loading…
Reference in New Issue