Skip to content

Commit

Permalink
ALTTP: Triforce Pieces and Condense Items fixes (#3166)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alchav authored Apr 17, 2024
1 parent 801d122 commit f19a842
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions worlds/alttp/ItemPool.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,6 @@ def cut_item(items, item_to_cut, minimum_items):
while len(items) > pool_count:
items_were_cut = False
for reduce_item in items_reduction_table:
if len(items) <= pool_count:
break
if len(reduce_item) == 2:
items_were_cut = items_were_cut or cut_item(items, *reduce_item)
elif len(reduce_item) == 4:
Expand All @@ -477,7 +475,10 @@ def cut_item(items, item_to_cut, minimum_items):
items.remove(bottle)
removed_filler.append(bottle)
items_were_cut = True
assert items_were_cut, f"Failed to limit item pool size for player {player}"
if items_were_cut:
break
else:
raise Exception(f"Failed to limit item pool size for player {player}")
if len(items) < pool_count:
items += removed_filler[len(items) - pool_count:]

Expand Down Expand Up @@ -684,12 +685,12 @@ def place_item(loc, item):
if world.triforce_pieces_mode[player].value == TriforcePiecesMode.option_extra:
triforce_pieces = world.triforce_pieces_available[player].value + world.triforce_pieces_extra[player].value
elif world.triforce_pieces_mode[player].value == TriforcePiecesMode.option_percentage:
percentage = float(max(100, world.triforce_pieces_percentage[player].value)) / 100
triforce_pieces = int(round(world.triforce_pieces_required[player].value * percentage, 0))
percentage = float(world.triforce_pieces_percentage[player].value) / 100
triforce_pieces = round(world.triforce_pieces_required[player].value * percentage, 0)
else: # available
triforce_pieces = world.triforce_pieces_available[player].value

triforce_pieces = max(triforce_pieces, world.triforce_pieces_required[player].value)
triforce_pieces = min(90, max(triforce_pieces, world.triforce_pieces_required[player].value))

pieces_in_core = min(extraitems, triforce_pieces)
additional_pieces_to_place = triforce_pieces - pieces_in_core
Expand Down

0 comments on commit f19a842

Please sign in to comment.