LTTP: Update to options API (#4134)

Co-authored-by: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com>
This commit is contained in:
Nicholas Saylor
2025-04-18 17:41:38 -04:00
committed by GitHub
parent 1b51714f3b
commit 57a716b57a
22 changed files with 532 additions and 554 deletions

View File

@@ -226,25 +226,25 @@ def generate_itempool(world):
player = world.player
multiworld = world.multiworld
if multiworld.item_pool[player].current_key not in difficulties:
raise NotImplementedError(f"Diffulty {multiworld.item_pool[player]}")
if multiworld.goal[player] not in ('ganon', 'pedestal', 'bosses', 'triforce_hunt', 'local_triforce_hunt',
'ganon_triforce_hunt', 'local_ganon_triforce_hunt', 'crystals',
'ganon_pedestal'):
raise NotImplementedError(f"Goal {multiworld.goal[player]} for player {player}")
if multiworld.mode[player] not in ('open', 'standard', 'inverted'):
raise NotImplementedError(f"Mode {multiworld.mode[player]} for player {player}")
if multiworld.timer[player] not in (False, 'display', 'timed', 'timed_ohko', 'ohko', 'timed_countdown'):
raise NotImplementedError(f"Timer {multiworld.timer[player]} for player {player}")
if world.options.item_pool.current_key not in difficulties:
raise NotImplementedError(f"Diffulty {world.options.item_pool}")
if world.options.goal not in ('ganon', 'pedestal', 'bosses', 'triforce_hunt', 'local_triforce_hunt',
'ganon_triforce_hunt', 'local_ganon_triforce_hunt', 'crystals',
'ganon_pedestal'):
raise NotImplementedError(f"Goal {world.options.goal} for player {player}")
if world.options.mode not in ('open', 'standard', 'inverted'):
raise NotImplementedError(f"Mode {world.options.mode} for player {player}")
if world.options.timer not in (False, 'display', 'timed', 'timed_ohko', 'ohko', 'timed_countdown'):
raise NotImplementedError(f"Timer {world.options.timer} for player {player}")
if multiworld.timer[player] in ['ohko', 'timed_ohko']:
if world.options.timer in ['ohko', 'timed_ohko']:
world.can_take_damage = False
if multiworld.goal[player] in ['pedestal', 'triforce_hunt', 'local_triforce_hunt']:
if world.options.goal in ['pedestal', 'triforce_hunt', 'local_triforce_hunt']:
multiworld.push_item(multiworld.get_location('Ganon', player), item_factory('Nothing', world), False)
else:
multiworld.push_item(multiworld.get_location('Ganon', player), item_factory('Triforce', world), False)
if multiworld.goal[player] in ['triforce_hunt', 'local_triforce_hunt']:
if world.options.goal in ['triforce_hunt', 'local_triforce_hunt']:
region = multiworld.get_region('Light World', player)
loc = ALttPLocation(player, "Murahdahla", parent=region)
@@ -288,7 +288,7 @@ def generate_itempool(world):
for item in precollected_items:
multiworld.push_precollected(item_factory(item, world))
if multiworld.mode[player] == 'standard' and not has_melee_weapon(multiworld.state, player):
if world.options.mode == 'standard' and not has_melee_weapon(multiworld.state, player):
if "Link's Uncle" not in placed_items:
found_sword = False
found_bow = False
@@ -304,10 +304,10 @@ def generate_itempool(world):
elif item in ['Hammer', 'Fire Rod', 'Cane of Somaria', 'Cane of Byrna']:
if item not in possible_weapons:
possible_weapons.append(item)
elif (item == 'Bombs (10)' and (not multiworld.bombless_start[player]) and item not in
elif (item == 'Bombs (10)' and (not world.options.bombless_start) and item not in
possible_weapons):
possible_weapons.append(item)
elif (item in ['Bomb Upgrade (+10)', 'Bomb Upgrade (50)'] and multiworld.bombless_start[player] and item
elif (item in ['Bomb Upgrade (+10)', 'Bomb Upgrade (50)'] and world.options.bombless_start and item
not in possible_weapons):
possible_weapons.append(item)
@@ -315,21 +315,21 @@ def generate_itempool(world):
placed_items["Link's Uncle"] = starting_weapon
pool.remove(starting_weapon)
if (placed_items["Link's Uncle"] in ['Bow', 'Progressive Bow', 'Bombs (10)', 'Bomb Upgrade (+10)',
'Bomb Upgrade (50)', 'Cane of Somaria', 'Cane of Byrna'] and multiworld.enemy_health[player] not in ['default', 'easy']):
if multiworld.bombless_start[player] and "Bomb Upgrade" not in placed_items["Link's Uncle"]:
'Bomb Upgrade (50)', 'Cane of Somaria', 'Cane of Byrna'] and world.options.enemy_health not in ['default', 'easy']):
if world.options.bombless_start and "Bomb Upgrade" not in placed_items["Link's Uncle"]:
if 'Bow' in placed_items["Link's Uncle"]:
multiworld.worlds[player].escape_assist.append('arrows')
world.escape_assist.append('arrows')
elif 'Cane' in placed_items["Link's Uncle"]:
multiworld.worlds[player].escape_assist.append('magic')
world.escape_assist.append('magic')
else:
multiworld.worlds[player].escape_assist.append('bombs')
world.escape_assist.append('bombs')
for (location, item) in placed_items.items():
multiworld.get_location(location, player).place_locked_item(item_factory(item, world))
items = item_factory(pool, world)
# convert one Progressive Bow into Progressive Bow (Alt), in ID only, for ganon silvers hint text
if multiworld.worlds[player].has_progressive_bows:
if world.has_progressive_bows:
for item in items:
if item.code == 0x64: # Progressive Bow
item.code = 0x65 # Progressive Bow (Alt)
@@ -338,21 +338,21 @@ def generate_itempool(world):
if clock_mode:
world.clock_mode = clock_mode
multiworld.worlds[player].treasure_hunt_required = treasure_hunt_required % 999
multiworld.worlds[player].treasure_hunt_total = treasure_hunt_total
world.treasure_hunt_required = treasure_hunt_required % 999
world.treasure_hunt_total = treasure_hunt_total
dungeon_items = [item for item in get_dungeon_item_pool_player(world)
if item.name not in multiworld.worlds[player].dungeon_local_item_names]
if item.name not in world.dungeon_local_item_names]
for key_loc in key_drop_data:
key_data = key_drop_data[key_loc]
drop_item = item_factory(key_data[3], world)
if not multiworld.key_drop_shuffle[player]:
if not world.options.key_drop_shuffle:
if drop_item in dungeon_items:
dungeon_items.remove(drop_item)
else:
dungeon = drop_item.name.split("(")[1].split(")")[0]
if multiworld.mode[player] == 'inverted':
if world.options.mode == 'inverted':
if dungeon == "Agahnims Tower":
dungeon = "Inverted Agahnims Tower"
if dungeon == "Ganons Tower":
@@ -365,7 +365,7 @@ def generate_itempool(world):
loc = multiworld.get_location(key_loc, player)
loc.place_locked_item(drop_item)
loc.address = None
elif "Small" in key_data[3] and multiworld.small_key_shuffle[player] == small_key_shuffle.option_universal:
elif "Small" in key_data[3] and world.options.small_key_shuffle == small_key_shuffle.option_universal:
# key drop shuffle and universal keys are on. Add universal keys in place of key drop keys.
multiworld.itempool.append(item_factory(GetBeemizerItem(multiworld, player, 'Small Key (Universal)'), world))
dungeon_item_replacements = sum(difficulties[world.options.item_pool.current_key].extras, []) * 2
@@ -373,10 +373,10 @@ def generate_itempool(world):
for x in range(len(dungeon_items)-1, -1, -1):
item = dungeon_items[x]
if ((multiworld.small_key_shuffle[player] == small_key_shuffle.option_start_with and item.type == 'SmallKey')
or (multiworld.big_key_shuffle[player] == big_key_shuffle.option_start_with and item.type == 'BigKey')
or (multiworld.compass_shuffle[player] == compass_shuffle.option_start_with and item.type == 'Compass')
or (multiworld.map_shuffle[player] == map_shuffle.option_start_with and item.type == 'Map')):
if ((world.options.small_key_shuffle == small_key_shuffle.option_start_with and item.type == 'SmallKey')
or (world.options.big_key_shuffle == big_key_shuffle.option_start_with and item.type == 'BigKey')
or (world.options.compass_shuffle == compass_shuffle.option_start_with and item.type == 'Compass')
or (world.options.map_shuffle == map_shuffle.option_start_with and item.type == 'Map')):
dungeon_items.pop(x)
multiworld.push_precollected(item)
multiworld.itempool.append(item_factory(dungeon_item_replacements.pop(), world))
@@ -384,7 +384,7 @@ def generate_itempool(world):
set_up_shops(multiworld, player)
if multiworld.retro_bow[player]:
if world.options.retro_bow:
shop_items = 0
shop_locations = [location for shop_locations in (shop.region.locations for shop in multiworld.shops if
shop.type == ShopType.Shop and shop.region.player == player) for location in shop_locations if
@@ -395,12 +395,12 @@ def generate_itempool(world):
else:
shop_items += 1
else:
shop_items = min(multiworld.shop_item_slots[player], 30 if multiworld.include_witch_hut[player] else 27)
shop_items = min(world.options.shop_item_slots, 30 if world.options.include_witch_hut else 27)
if multiworld.shuffle_capacity_upgrades[player]:
if world.options.shuffle_capacity_upgrades:
shop_items += 2
chance_100 = int(multiworld.retro_bow[player]) * 0.25 + int(
multiworld.small_key_shuffle[player] == small_key_shuffle.option_universal) * 0.5
chance_100 = int(world.options.retro_bow) * 0.25 + int(
world.options.small_key_shuffle == small_key_shuffle.option_universal) * 0.5
for _ in range(shop_items):
if multiworld.random.random() < chance_100:
items.append(item_factory(GetBeemizerItem(multiworld, player, "Rupees (100)"), world))
@@ -410,19 +410,19 @@ def generate_itempool(world):
multiworld.random.shuffle(items)
pool_count = len(items)
new_items = ["Triforce Piece" for _ in range(additional_triforce_pieces)]
if multiworld.shuffle_capacity_upgrades[player] or multiworld.bombless_start[player]:
progressive = multiworld.progressive[player]
if world.options.shuffle_capacity_upgrades or world.options.bombless_start:
progressive = world.options.progressive
progressive = multiworld.random.choice([True, False]) if progressive == 'grouped_random' else progressive == 'on'
if multiworld.shuffle_capacity_upgrades[player] == "on_combined":
if world.options.shuffle_capacity_upgrades == "on_combined":
new_items.append("Bomb Upgrade (50)")
elif multiworld.shuffle_capacity_upgrades[player] == "on":
elif world.options.shuffle_capacity_upgrades == "on":
new_items += ["Bomb Upgrade (+5)"] * 6
new_items.append("Bomb Upgrade (+5)" if progressive else "Bomb Upgrade (+10)")
if multiworld.shuffle_capacity_upgrades[player] != "on_combined" and multiworld.bombless_start[player]:
if world.options.shuffle_capacity_upgrades != "on_combined" and world.options.bombless_start:
new_items.append("Bomb Upgrade (+5)" if progressive else "Bomb Upgrade (+10)")
if multiworld.shuffle_capacity_upgrades[player] and not multiworld.retro_bow[player]:
if multiworld.shuffle_capacity_upgrades[player] == "on_combined":
if world.options.shuffle_capacity_upgrades and not world.options.retro_bow:
if world.options.shuffle_capacity_upgrades == "on_combined":
new_items += ["Arrow Upgrade (70)"]
else:
new_items += ["Arrow Upgrade (+5)"] * 6
@@ -481,7 +481,7 @@ def generate_itempool(world):
if len(items) < pool_count:
items += removed_filler[len(items) - pool_count:]
if multiworld.randomize_cost_types[player]:
if world.options.randomize_cost_types:
# Heart and Arrow costs require all Heart Container/Pieces and Arrow Upgrades to be advancement items for logic
for item in items:
if item.name in ("Boss Heart Container", "Sanctuary Heart Container", "Piece of Heart"):
@@ -490,21 +490,21 @@ def generate_itempool(world):
# Otherwise, logic has some branches where having 4 hearts is one possible requirement (of several alternatives)
# rather than making all hearts/heart pieces progression items (which slows down generation considerably)
# We mark one random heart container as an advancement item (or 4 heart pieces in expert mode)
if multiworld.item_pool[player] in ['easy', 'normal', 'hard'] and not (multiworld.custom and multiworld.customitemarray[30] == 0):
if world.options.item_pool in ['easy', 'normal', 'hard'] and not (multiworld.custom and multiworld.customitemarray[30] == 0):
next(item for item in items if item.name == 'Boss Heart Container').classification = ItemClassification.progression
elif multiworld.item_pool[player] in ['expert'] and not (multiworld.custom and multiworld.customitemarray[29] < 4):
elif world.options.item_pool in ['expert'] and not (multiworld.custom and multiworld.customitemarray[29] < 4):
adv_heart_pieces = (item for item in items if item.name == 'Piece of Heart')
for i in range(4):
next(adv_heart_pieces).classification = ItemClassification.progression
world.required_medallions = (multiworld.misery_mire_medallion[player].current_key.title(),
multiworld.turtle_rock_medallion[player].current_key.title())
world.required_medallions = (world.options.misery_mire_medallion.current_key.title(),
world.options.turtle_rock_medallion.current_key.title())
place_bosses(world)
multiworld.itempool += items
if multiworld.retro_caves[player]:
if world.options.retro_caves:
set_up_take_anys(multiworld, world, player) # depends on world.itempool to be set
@@ -527,7 +527,7 @@ take_any_locations.sort()
def set_up_take_anys(multiworld, world, player):
# these are references, do not modify these lists in-place
if multiworld.mode[player] == 'inverted':
if world.options.mode == 'inverted':
take_any_locs = take_any_locations_inverted
else:
take_any_locs = take_any_locations
@@ -578,14 +578,14 @@ def set_up_take_anys(multiworld, world, player):
def get_pool_core(world, player: int):
shuffle = world.entrance_shuffle[player].current_key
difficulty = world.item_pool[player].current_key
timer = world.timer[player].current_key
goal = world.goal[player].current_key
mode = world.mode[player].current_key
swordless = world.swordless[player]
retro_bow = world.retro_bow[player]
logic = world.glitches_required[player]
shuffle = world.worlds[player].options.entrance_shuffle.current_key
difficulty = world.worlds[player].options.item_pool.current_key
timer = world.worlds[player].options.timer.current_key
goal = world.worlds[player].options.goal.current_key
mode = world.worlds[player].options.mode.current_key
swordless = world.worlds[player].options.swordless
retro_bow = world.worlds[player].options.retro_bow
logic = world.worlds[player].options.glitches_required
pool = []
placed_items = {}
@@ -602,11 +602,11 @@ def get_pool_core(world, player: int):
placed_items[loc] = item
# provide boots to major glitch dependent seeds
if logic.current_key in {'overworld_glitches', 'hybrid_major_glitches', 'no_logic'} and world.glitch_boots[player]:
if logic.current_key in {'overworld_glitches', 'hybrid_major_glitches', 'no_logic'} and world.worlds[player].options.glitch_boots:
precollected_items.append('Pegasus Boots')
pool.remove('Pegasus Boots')
pool.append('Rupees (20)')
want_progressives = world.progressive[player].want_progressives
want_progressives = world.worlds[player].options.progressive.want_progressives
if want_progressives(world.random):
pool.extend(diff.progressiveglove)
@@ -680,22 +680,22 @@ def get_pool_core(world, player: int):
additional_pieces_to_place = 0
if 'triforce_hunt' in goal:
if world.triforce_pieces_mode[player].value == TriforcePiecesMode.option_extra:
treasure_hunt_total = (world.triforce_pieces_required[player].value
+ world.triforce_pieces_extra[player].value)
elif world.triforce_pieces_mode[player].value == TriforcePiecesMode.option_percentage:
percentage = float(world.triforce_pieces_percentage[player].value) / 100
treasure_hunt_total = int(round(world.triforce_pieces_required[player].value * percentage, 0))
if world.worlds[player].options.triforce_pieces_mode.value == TriforcePiecesMode.option_extra:
treasure_hunt_total = (world.worlds[player].options.triforce_pieces_required.value
+ world.worlds[player].options.triforce_pieces_extra.value)
elif world.worlds[player].options.triforce_pieces_mode.value == TriforcePiecesMode.option_percentage:
percentage = float(world.worlds[player].options.triforce_pieces_percentage.value) / 100
treasure_hunt_total = int(round(world.worlds[player].options.triforce_pieces_required.value * percentage, 0))
else: # available
treasure_hunt_total = world.triforce_pieces_available[player].value
treasure_hunt_total = world.worlds[player].options.triforce_pieces_available.value
triforce_pieces = min(90, max(treasure_hunt_total, world.triforce_pieces_required[player].value))
triforce_pieces = min(90, max(treasure_hunt_total, world.worlds[player].options.triforce_pieces_required.value))
pieces_in_core = min(extraitems, triforce_pieces)
additional_pieces_to_place = triforce_pieces - pieces_in_core
pool.extend(["Triforce Piece"] * pieces_in_core)
extraitems -= pieces_in_core
treasure_hunt_required = world.triforce_pieces_required[player].value
treasure_hunt_required = world.worlds[player].options.triforce_pieces_required.value
for extra in diff.extras:
if extraitems >= len(extra):
@@ -714,10 +714,10 @@ def get_pool_core(world, player: int):
if retro_bow:
replace = {'Single Arrow', 'Arrows (10)', 'Arrow Upgrade (+5)', 'Arrow Upgrade (+10)', 'Arrow Upgrade (70)'}
pool = ['Rupees (5)' if item in replace else item for item in pool]
if world.small_key_shuffle[player] == small_key_shuffle.option_universal:
if world.worlds[player].options.small_key_shuffle == small_key_shuffle.option_universal:
pool.extend(diff.universal_keys)
if mode == 'standard':
if world.key_drop_shuffle[player]:
if world.worlds[player].options.key_drop_shuffle:
key_locations = ['Secret Passage', 'Hyrule Castle - Map Guard Key Drop']
key_location = world.random.choice(key_locations)
key_locations.remove(key_location)
@@ -741,11 +741,11 @@ def get_pool_core(world, player: int):
def make_custom_item_pool(world, player):
shuffle = world.entrance_shuffle[player]
difficulty = world.item_pool[player]
timer = world.timer[player]
goal = world.goal[player]
mode = world.mode[player]
shuffle = world.worlds[player].options.entrance_shuffle
difficulty = world.worlds[player].options.item_pool
timer = world.worlds[player].options.timer
goal = world.worlds[player].options.goal
mode = world.worlds[player].options.mode
customitemarray = world.customitemarray
pool = []
@@ -845,10 +845,10 @@ def make_custom_item_pool(world, player):
thisbottle = world.random.choice(diff.bottles)
pool.append(thisbottle)
if "triforce" in world.goal[player]:
pool.extend(["Triforce Piece"] * world.triforce_pieces_available[player])
itemtotal += world.triforce_pieces_available[player]
treasure_hunt_required = world.triforce_pieces_required[player]
if "triforce" in world.worlds[player].options.goal:
pool.extend(["Triforce Piece"] * world.worlds[player].options.triforce_pieces_available)
itemtotal += world.worlds[player].options.triforce_pieces_available
treasure_hunt_required = world.worlds[player].options.triforce_pieces_required
if timer in ['display', 'timed', 'timed_countdown']:
clock_mode = 'countdown' if timer == 'timed_countdown' else 'stopwatch'
@@ -862,7 +862,7 @@ def make_custom_item_pool(world, player):
itemtotal = itemtotal + 1
if mode == 'standard':
if world.small_key_shuffle[player] == small_key_shuffle.option_universal:
if world.worlds[player].options.small_key_shuffle == small_key_shuffle.option_universal:
key_location = world.random.choice(
['Secret Passage', 'Hyrule Castle - Boomerang Chest', 'Hyrule Castle - Map Chest',
'Hyrule Castle - Zelda\'s Chest', 'Sewers - Dark Cross'])
@@ -885,9 +885,9 @@ def make_custom_item_pool(world, player):
pool.extend(['Magic Mirror'] * customitemarray[22])
pool.extend(['Moon Pearl'] * customitemarray[28])
if world.small_key_shuffle[player] == small_key_shuffle.option_universal:
if world.worlds[player].options.small_key_shuffle == small_key_shuffle.option_universal:
itemtotal = itemtotal - 28 # Corrects for small keys not being in item pool in universal Mode
if world.key_drop_shuffle[player]:
if world.worlds[player].options.key_drop_shuffle:
itemtotal = itemtotal - (len(key_drop_data) - 1)
if itemtotal < total_items_to_place:
pool.extend(['Nothing'] * (total_items_to_place - itemtotal))