Skip to content

Commit bb48125

Browse files
Core: Make fill failure error more human parseable (#3023)
1 parent 301d9de commit bb48125

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

Fill.py

+24-9
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,16 @@ def fill_restrictive(multiworld: MultiWorld, base_state: CollectionState, locati
198198
# There are leftover unplaceable items and locations that won't accept them
199199
if multiworld.can_beat_game():
200200
logging.warning(
201-
f'Not all items placed. Game beatable anyway. (Could not place {unplaced_items})')
201+
f"Not all items placed. Game beatable anyway.\nCould not place:\n"
202+
f"{', '.join(str(item) for item in unplaced_items)}")
202203
else:
203-
raise FillError(f'No more spots to place {unplaced_items}, locations {locations} are invalid. '
204-
f'Already placed {len(placements)}: {", ".join(str(place) for place in placements)}')
204+
raise FillError(f"No more spots to place {len(unplaced_items)} items. Remaining locations are invalid.\n"
205+
f"Unplaced items:\n"
206+
f"{', '.join(str(item) for item in unplaced_items)}\n"
207+
f"Unfilled locations:\n"
208+
f"{', '.join(str(location) for location in locations)}\n"
209+
f"Already placed {len(placements)}:\n"
210+
f"{', '.join(str(place) for place in placements)}")
205211

206212
item_pool.extend(unplaced_items)
207213

@@ -273,8 +279,13 @@ def remaining_fill(multiworld: MultiWorld,
273279

274280
if unplaced_items and locations:
275281
# There are leftover unplaceable items and locations that won't accept them
276-
raise FillError(f'No more spots to place {unplaced_items}, locations {locations} are invalid. '
277-
f'Already placed {len(placements)}: {", ".join(str(place) for place in placements)}')
282+
raise FillError(f"No more spots to place {len(unplaced_items)} items. Remaining locations are invalid.\n"
283+
f"Unplaced items:\n"
284+
f"{', '.join(str(item) for item in unplaced_items)}\n"
285+
f"Unfilled locations:\n"
286+
f"{', '.join(str(location) for location in locations)}\n"
287+
f"Already placed {len(placements)}:\n"
288+
f"{', '.join(str(place) for place in placements)}")
278289

279290
itempool.extend(unplaced_items)
280291

@@ -457,7 +468,9 @@ def mark_for_locking(location: Location):
457468
fill_restrictive(multiworld, multiworld.state, defaultlocations, progitempool, name="Progression")
458469
if progitempool:
459470
raise FillError(
460-
f'Not enough locations for progress items. There are {len(progitempool)} more items than locations')
471+
f"Not enough locations for progression items. "
472+
f"There are {len(progitempool)} more progression items than there are available locations."
473+
)
461474
accessibility_corrections(multiworld, multiworld.state, defaultlocations)
462475

463476
for location in lock_later:
@@ -470,7 +483,9 @@ def mark_for_locking(location: Location):
470483
remaining_fill(multiworld, excludedlocations, filleritempool, "Remaining Excluded")
471484
if excludedlocations:
472485
raise FillError(
473-
f"Not enough filler items for excluded locations. There are {len(excludedlocations)} more locations than items")
486+
f"Not enough filler items for excluded locations. "
487+
f"There are {len(excludedlocations)} more excluded locations than filler or trap items."
488+
)
474489

475490
restitempool = filleritempool + usefulitempool
476491

@@ -481,13 +496,13 @@ def mark_for_locking(location: Location):
481496

482497
if unplaced or unfilled:
483498
logging.warning(
484-
f'Unplaced items({len(unplaced)}): {unplaced} - Unfilled Locations({len(unfilled)}): {unfilled}')
499+
f"Unplaced items({len(unplaced)}): {unplaced} - Unfilled Locations({len(unfilled)}): {unfilled}")
485500
items_counter = Counter(location.item.player for location in multiworld.get_locations() if location.item)
486501
locations_counter = Counter(location.player for location in multiworld.get_locations())
487502
items_counter.update(item.player for item in unplaced)
488503
locations_counter.update(location.player for location in unfilled)
489504
print_data = {"items": items_counter, "locations": locations_counter}
490-
logging.info(f'Per-Player counts: {print_data})')
505+
logging.info(f"Per-Player counts: {print_data})")
491506

492507

493508
def flood_items(multiworld: MultiWorld) -> None:

0 commit comments

Comments
 (0)