mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 12:11:33 -06:00
Add option to hard require plando item placement.
This commit is contained in:
42
Fill.py
42
Fill.py
@@ -359,7 +359,11 @@ def distribute_planned(world):
|
||||
set(world.player_ids) - {player}) if location.item_rule(item)
|
||||
)
|
||||
if not unfilled:
|
||||
raise FillError(f"Could not find a world with an unfilled location {placement.location}")
|
||||
if placement.force:
|
||||
raise FillError(f"Could not find a world with an unfilled location {placement.location}")
|
||||
else:
|
||||
logging.warning(f"Could not find a world with an unfilled location {placement.location}, skipping.")
|
||||
continue
|
||||
|
||||
target_world = world.random.choice(unfilled).player
|
||||
|
||||
@@ -369,24 +373,32 @@ def distribute_planned(world):
|
||||
set(world.player_ids)) if location.item_rule(item)
|
||||
)
|
||||
if not unfilled:
|
||||
raise FillError(f"Could not find a world with an unfilled location {placement.location}")
|
||||
if placement.force:
|
||||
raise FillError(f"Could not find a world with an unfilled location {placement.location}")
|
||||
else:
|
||||
logging.warning(f"Could not find a world with an unfilled location {placement.location}, skipping.")
|
||||
continue
|
||||
|
||||
target_world = world.random.choice(unfilled).player
|
||||
|
||||
elif type(target_world) == int: # target world by player id
|
||||
pass
|
||||
else: # find world by name
|
||||
if target_world not in world_name_lookup:
|
||||
if placement.force:
|
||||
raise Exception(f"Cannot place item to {target_world}'s world as that world does not exist.")
|
||||
else:
|
||||
logging.warning(f"Cannot place item to {target_world}'s world as that world does not exist. Skipping.")
|
||||
continue
|
||||
target_world = world_name_lookup[target_world]
|
||||
|
||||
location = world.get_location(placement.location, target_world)
|
||||
if location.item:
|
||||
raise Exception(f"Cannot place item into already filled location {location}.")
|
||||
|
||||
if placement.from_pool:
|
||||
try:
|
||||
world.itempool.remove(item)
|
||||
except ValueError:
|
||||
logging.warning(f"Could not remove {item} from pool as it's already missing from it.")
|
||||
if placement.force:
|
||||
raise Exception(f"Cannot place item into already filled location {location}.")
|
||||
else:
|
||||
logging.warning(f"Cannot place item into already filled location {location}. Skipping.")
|
||||
continue
|
||||
|
||||
if location.can_fill(world.state, item, False):
|
||||
world.push_item(location, item, collect=False)
|
||||
@@ -394,4 +406,14 @@ def distribute_planned(world):
|
||||
location.locked = True
|
||||
logging.debug(f"Plando placed {item} at {location}")
|
||||
else:
|
||||
raise Exception(f"Can't place {item} at {location} due to fill condition not met.")
|
||||
if placement.force:
|
||||
raise Exception(f"Can't place {item} at {location} due to fill condition not met.")
|
||||
else:
|
||||
logging.warning(f"Can't place {item} at {location} due to fill condition not met. Skipping.")
|
||||
continue
|
||||
|
||||
if placement.from_pool: # Should happen AFTER the item is placed, in case it was allowed to skip failed placement.
|
||||
try:
|
||||
world.itempool.remove(item)
|
||||
except ValueError:
|
||||
logging.warning(f"Could not remove {item} from pool as it's already missing from it.")
|
||||
|
Reference in New Issue
Block a user