From 215c80eb4a005f6cdca7d514b2f3e9ec72bfb0be Mon Sep 17 00:00:00 2001 From: aerinon Date: Wed, 15 Nov 2023 13:36:09 -0700 Subject: [PATCH] fix(algorithm): District algorithm fails if unable to comply with restriction --- Fill.py | 3 ++- source/item/FillUtil.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Fill.py b/Fill.py index b55e620c..2c5e4f01 100644 --- a/Fill.py +++ b/Fill.py @@ -280,9 +280,10 @@ def recovery_placement(item_to_place, locations, world, state, base_state, itemp return spot_to_fill return None # explicitly fail these cases - elif world.algorithm in ['dungeon_only', 'major_only']: + elif world.algorithm in ['dungeon_only', 'major_only', 'district']: raise FillError(f'Rare placement for {world.algorithm} detected. {item_to_place} unable to be placed.' f' Try a different seed') + # I don't think any algorithm uses fallback placement anymore, vanilla is special. Others simply fail. else: other_locations = [x for x in locations if x not in attempted] for location in other_locations: diff --git a/source/item/FillUtil.py b/source/item/FillUtil.py index 1a5c5692..3fbdfe86 100644 --- a/source/item/FillUtil.py +++ b/source/item/FillUtil.py @@ -416,11 +416,11 @@ def filter_locations(item_to_place, locations, world, vanilla_skip=False, potion return filtered if world.algorithm == 'district': config = world.item_pool_config - if ((isinstance(item_to_place,str) and item_to_place == 'Placeholder') + if ((isinstance(item_to_place, str) and item_to_place == 'Placeholder') or item_to_place.name in config.item_pool[item_to_place.player]): restricted = config.location_groups[0].locations filtered = [l for l in locations if l.name in restricted and l.player in restricted[l.name]] - return filtered if len(filtered) > 0 else locations + return filtered elif potion: restricted = config.location_groups[0].locations filtered = [l for l in locations if l.name not in restricted or l.player not in restricted[l.name]]