Log which player's plando has caused a placement failure
This commit is contained in:
parent
1e0b44bdc5
commit
59a56c803a
127
Fill.py
127
Fill.py
|
@ -367,69 +367,72 @@ def distribute_planned(world: MultiWorld):
|
||||||
world_name_lookup = world.world_name_lookup
|
world_name_lookup = world.world_name_lookup
|
||||||
|
|
||||||
for player in world.player_ids:
|
for player in world.player_ids:
|
||||||
placement: PlandoItem
|
try:
|
||||||
for placement in world.plando_items[player]:
|
placement: PlandoItem
|
||||||
if placement.location in key_drop_data:
|
for placement in world.plando_items[player]:
|
||||||
placement.warn(
|
if placement.location in key_drop_data:
|
||||||
f"Can't place '{placement.item}' at '{placement.location}', as key drop shuffle locations are not supported yet.")
|
placement.warn(
|
||||||
continue
|
f"Can't place '{placement.item}' at '{placement.location}', as key drop shuffle locations are not supported yet.")
|
||||||
item = ItemFactory(placement.item, player)
|
continue
|
||||||
target_world: int = placement.world
|
item = ItemFactory(placement.item, player)
|
||||||
if target_world is False or world.players == 1:
|
target_world: int = placement.world
|
||||||
target_world = player # in own world
|
if target_world is False or world.players == 1:
|
||||||
elif target_world is True: # in any other world
|
target_world = player # in own world
|
||||||
unfilled = list(location for location in world.get_unfilled_locations_for_players(
|
elif target_world is True: # in any other world
|
||||||
placement.location,
|
unfilled = list(location for location in world.get_unfilled_locations_for_players(
|
||||||
set(world.player_ids) - {player}) if location.item_rule(item)
|
placement.location,
|
||||||
)
|
set(world.player_ids) - {player}) if location.item_rule(item)
|
||||||
if not unfilled:
|
)
|
||||||
placement.failed(f"Could not find a world with an unfilled location {placement.location}",
|
if not unfilled:
|
||||||
FillError)
|
placement.failed(f"Could not find a world with an unfilled location {placement.location}",
|
||||||
|
FillError)
|
||||||
|
continue
|
||||||
|
|
||||||
|
target_world = world.random.choice(unfilled).player
|
||||||
|
|
||||||
|
elif target_world is None: # any random world
|
||||||
|
unfilled = list(location for location in world.get_unfilled_locations_for_players(
|
||||||
|
placement.location,
|
||||||
|
set(world.player_ids)) if location.item_rule(item)
|
||||||
|
)
|
||||||
|
if not unfilled:
|
||||||
|
placement.failed(f"Could not find a world with an unfilled location {placement.location}",
|
||||||
|
FillError)
|
||||||
|
continue
|
||||||
|
|
||||||
|
target_world = world.random.choice(unfilled).player
|
||||||
|
|
||||||
|
elif type(target_world) == int: # target world by player id
|
||||||
|
if target_world not in range(1, world.players + 1):
|
||||||
|
placement.failed(
|
||||||
|
f"Cannot place item in world {target_world} as it is not in range of (1, {world.players})",
|
||||||
|
ValueError)
|
||||||
|
continue
|
||||||
|
else: # find world by name
|
||||||
|
if target_world not in world_name_lookup:
|
||||||
|
placement.failed(f"Cannot place item to {target_world}'s world as that world does not exist.",
|
||||||
|
ValueError)
|
||||||
|
continue
|
||||||
|
target_world = world_name_lookup[target_world]
|
||||||
|
|
||||||
|
location = world.get_location(placement.location, target_world)
|
||||||
|
if location.item:
|
||||||
|
placement.failed(f"Cannot place item into already filled location {location}.")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
target_world = world.random.choice(unfilled).player
|
if location.can_fill(world.state, item, False):
|
||||||
|
world.push_item(location, item, collect=False)
|
||||||
elif target_world is None: # any random world
|
location.event = True # flag location to be checked during fill
|
||||||
unfilled = list(location for location in world.get_unfilled_locations_for_players(
|
location.locked = True
|
||||||
placement.location,
|
logging.debug(f"Plando placed {item} at {location}")
|
||||||
set(world.player_ids)) if location.item_rule(item)
|
else:
|
||||||
)
|
placement.failed(f"Can't place {item} at {location} due to fill condition not met.")
|
||||||
if not unfilled:
|
|
||||||
placement.failed(f"Could not find a world with an unfilled location {placement.location}",
|
|
||||||
FillError)
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
target_world = world.random.choice(unfilled).player
|
if placement.from_pool: # Should happen AFTER the item is placed, in case it was allowed to skip failed placement.
|
||||||
|
try:
|
||||||
elif type(target_world) == int: # target world by player id
|
world.itempool.remove(item)
|
||||||
if target_world not in range(1, world.players + 1):
|
except ValueError:
|
||||||
placement.failed(
|
placement.warn(f"Could not remove {item} from pool as it's already missing from it.")
|
||||||
f"Cannot place item in world {target_world} as it is not in range of (1, {world.players})",
|
except Exception as e:
|
||||||
ValueError)
|
raise Exception(f"Error running plando for player {player} ({world.player_names[player]})") from e
|
||||||
continue
|
|
||||||
else: # find world by name
|
|
||||||
if target_world not in world_name_lookup:
|
|
||||||
placement.failed(f"Cannot place item to {target_world}'s world as that world does not exist.",
|
|
||||||
ValueError)
|
|
||||||
continue
|
|
||||||
target_world = world_name_lookup[target_world]
|
|
||||||
|
|
||||||
location = world.get_location(placement.location, target_world)
|
|
||||||
if location.item:
|
|
||||||
placement.failed(f"Cannot place item into already filled location {location}.")
|
|
||||||
continue
|
|
||||||
|
|
||||||
if location.can_fill(world.state, item, False):
|
|
||||||
world.push_item(location, item, collect=False)
|
|
||||||
location.event = True # flag location to be checked during fill
|
|
||||||
location.locked = True
|
|
||||||
logging.debug(f"Plando placed {item} at {location}")
|
|
||||||
else:
|
|
||||||
placement.failed(f"Can't place {item} at {location} due to fill condition not met.")
|
|
||||||
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:
|
|
||||||
placement.warn(f"Could not remove {item} from pool as it's already missing from it.")
|
|
||||||
|
|
Loading…
Reference in New Issue