Core: Make fill failure error more human parseable (#3023)

This commit is contained in:
Aaron Wagener 2024-03-28 21:48:40 -05:00 committed by GitHub
parent 301d9de975
commit bb481256de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 24 additions and 9 deletions

33
Fill.py
View File

@ -198,10 +198,16 @@ def fill_restrictive(multiworld: MultiWorld, base_state: CollectionState, locati
# There are leftover unplaceable items and locations that won't accept them # There are leftover unplaceable items and locations that won't accept them
if multiworld.can_beat_game(): if multiworld.can_beat_game():
logging.warning( logging.warning(
f'Not all items placed. Game beatable anyway. (Could not place {unplaced_items})') f"Not all items placed. Game beatable anyway.\nCould not place:\n"
f"{', '.join(str(item) for item in unplaced_items)}")
else: else:
raise FillError(f'No more spots to place {unplaced_items}, locations {locations} are invalid. ' raise FillError(f"No more spots to place {len(unplaced_items)} items. Remaining locations are invalid.\n"
f'Already placed {len(placements)}: {", ".join(str(place) for place in placements)}') f"Unplaced items:\n"
f"{', '.join(str(item) for item in unplaced_items)}\n"
f"Unfilled locations:\n"
f"{', '.join(str(location) for location in locations)}\n"
f"Already placed {len(placements)}:\n"
f"{', '.join(str(place) for place in placements)}")
item_pool.extend(unplaced_items) item_pool.extend(unplaced_items)
@ -273,8 +279,13 @@ def remaining_fill(multiworld: MultiWorld,
if unplaced_items and locations: if unplaced_items and locations:
# There are leftover unplaceable items and locations that won't accept them # There are leftover unplaceable items and locations that won't accept them
raise FillError(f'No more spots to place {unplaced_items}, locations {locations} are invalid. ' raise FillError(f"No more spots to place {len(unplaced_items)} items. Remaining locations are invalid.\n"
f'Already placed {len(placements)}: {", ".join(str(place) for place in placements)}') f"Unplaced items:\n"
f"{', '.join(str(item) for item in unplaced_items)}\n"
f"Unfilled locations:\n"
f"{', '.join(str(location) for location in locations)}\n"
f"Already placed {len(placements)}:\n"
f"{', '.join(str(place) for place in placements)}")
itempool.extend(unplaced_items) itempool.extend(unplaced_items)
@ -457,7 +468,9 @@ def distribute_items_restrictive(multiworld: MultiWorld) -> None:
fill_restrictive(multiworld, multiworld.state, defaultlocations, progitempool, name="Progression") fill_restrictive(multiworld, multiworld.state, defaultlocations, progitempool, name="Progression")
if progitempool: if progitempool:
raise FillError( raise FillError(
f'Not enough locations for progress items. There are {len(progitempool)} more items than locations') f"Not enough locations for progression items. "
f"There are {len(progitempool)} more progression items than there are available locations."
)
accessibility_corrections(multiworld, multiworld.state, defaultlocations) accessibility_corrections(multiworld, multiworld.state, defaultlocations)
for location in lock_later: for location in lock_later:
@ -470,7 +483,9 @@ def distribute_items_restrictive(multiworld: MultiWorld) -> None:
remaining_fill(multiworld, excludedlocations, filleritempool, "Remaining Excluded") remaining_fill(multiworld, excludedlocations, filleritempool, "Remaining Excluded")
if excludedlocations: if excludedlocations:
raise FillError( raise FillError(
f"Not enough filler items for excluded locations. There are {len(excludedlocations)} more locations than items") f"Not enough filler items for excluded locations. "
f"There are {len(excludedlocations)} more excluded locations than filler or trap items."
)
restitempool = filleritempool + usefulitempool restitempool = filleritempool + usefulitempool
@ -481,13 +496,13 @@ def distribute_items_restrictive(multiworld: MultiWorld) -> None:
if unplaced or unfilled: if unplaced or unfilled:
logging.warning( logging.warning(
f'Unplaced items({len(unplaced)}): {unplaced} - Unfilled Locations({len(unfilled)}): {unfilled}') f"Unplaced items({len(unplaced)}): {unplaced} - Unfilled Locations({len(unfilled)}): {unfilled}")
items_counter = Counter(location.item.player for location in multiworld.get_locations() if location.item) items_counter = Counter(location.item.player for location in multiworld.get_locations() if location.item)
locations_counter = Counter(location.player for location in multiworld.get_locations()) locations_counter = Counter(location.player for location in multiworld.get_locations())
items_counter.update(item.player for item in unplaced) items_counter.update(item.player for item in unplaced)
locations_counter.update(location.player for location in unfilled) locations_counter.update(location.player for location in unfilled)
print_data = {"items": items_counter, "locations": locations_counter} print_data = {"items": items_counter, "locations": locations_counter}
logging.info(f'Per-Player counts: {print_data})') logging.info(f"Per-Player counts: {print_data})")
def flood_items(multiworld: MultiWorld) -> None: def flood_items(multiworld: MultiWorld) -> None: