Skip to content

Commit 06e6f45

Browse files
nicholassaylorExempt-Medic
authored andcommitted
LTTP: Update to options API (ArchipelagoMW#4134)
Co-authored-by: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com>
1 parent b7c64e8 commit 06e6f45

File tree

22 files changed

+534
-556
lines changed

22 files changed

+534
-556
lines changed

worlds/alttp/Bosses.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def KholdstareDefeatRule(state, player: int) -> bool:
102102
state.has('Fire Rod', player) or
103103
(
104104
state.has('Bombos', player) and
105-
(has_sword(state, player) or state.multiworld.swordless[player])
105+
(has_sword(state, player) or state.multiworld.worlds[player].options.swordless)
106106
)
107107
) and
108108
(
@@ -111,7 +111,7 @@ def KholdstareDefeatRule(state, player: int) -> bool:
111111
(
112112
state.has('Fire Rod', player) and
113113
state.has('Bombos', player) and
114-
state.multiworld.swordless[player] and
114+
state.multiworld.worlds[player].options.swordless and
115115
can_extend_magic(state, player, 16)
116116
)
117117
)
@@ -137,7 +137,7 @@ def AgahnimDefeatRule(state, player: int) -> bool:
137137

138138

139139
def GanonDefeatRule(state, player: int) -> bool:
140-
if state.multiworld.swordless[player]:
140+
if state.multiworld.worlds[player].options.swordless:
141141
return state.has('Hammer', player) and \
142142
has_fire_source(state, player) and \
143143
state.has('Silver Bow', player) and \
@@ -146,7 +146,7 @@ def GanonDefeatRule(state, player: int) -> bool:
146146
can_hurt = has_beam_sword(state, player)
147147
common = can_hurt and has_fire_source(state, player)
148148
# silverless ganon may be needed in anything higher than no glitches
149-
if state.multiworld.glitches_required[player] != 'no_glitches':
149+
if state.multiworld.worlds[player].options.glitches_required != 'no_glitches':
150150
# need to light torch a sufficient amount of times
151151
return common and (state.has('Tempered Sword', player) or state.has('Golden Sword', player) or (
152152
state.has('Silver Bow', player) and can_shoot_arrows(state, player)) or
@@ -248,7 +248,7 @@ def can_place_boss(boss: str, dungeon_name: str, level: Optional[str] = None) ->
248248

249249
def place_boss(world: "ALTTPWorld", boss: str, location: str, level: Optional[str]) -> None:
250250
player = world.player
251-
if location == 'Ganons Tower' and world.multiworld.mode[player] == 'inverted':
251+
if location == 'Ganons Tower' and world.options.mode == 'inverted':
252252
location = 'Inverted Ganons Tower'
253253
logging.debug('Placing boss %s at %s', boss, location + (' (' + level + ')' if level else ''))
254254
world.dungeons[location].bosses[level] = BossFactory(boss, player)
@@ -260,9 +260,8 @@ def format_boss_location(location_name: str, level: str) -> str:
260260

261261
def place_bosses(world: "ALTTPWorld") -> None:
262262
multiworld = world.multiworld
263-
player = world.player
264263
# will either be an int or a lower case string with ';' between options
265-
boss_shuffle: Union[str, int] = multiworld.boss_shuffle[player].value
264+
boss_shuffle: Union[str, int] = world.options.boss_shuffle.value
266265
already_placed_bosses: List[str] = []
267266
remaining_locations: List[Tuple[str, str]] = []
268267
# handle plando

worlds/alttp/Dungeons.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def create_dungeons(world: "ALTTPWorld"):
6666

6767
def make_dungeon(name, default_boss, dungeon_regions, big_key, small_keys, dungeon_items):
6868
dungeon = Dungeon(name, dungeon_regions, big_key,
69-
[] if multiworld.small_key_shuffle[player] == small_key_shuffle.option_universal else small_keys,
69+
[] if multiworld.worlds[player].options.small_key_shuffle == small_key_shuffle.option_universal else small_keys,
7070
dungeon_items, player)
7171
for item in dungeon.all_items:
7272
item.dungeon = dungeon
@@ -143,7 +143,7 @@ def make_dungeon(name, default_boss, dungeon_regions, big_key, small_keys, dunge
143143
item_factory(['Small Key (Turtle Rock)'] * 6, world),
144144
item_factory(['Map (Turtle Rock)', 'Compass (Turtle Rock)'], world))
145145

146-
if multiworld.mode[player] != 'inverted':
146+
if multiworld.worlds[player].options.mode != 'inverted':
147147
AT = make_dungeon('Agahnims Tower', 'Agahnim', ['Agahnims Tower', 'Agahnim 1'], None,
148148
item_factory(['Small Key (Agahnims Tower)'] * 4, world), [])
149149
GT = make_dungeon('Ganons Tower', 'Agahnim2',

worlds/alttp/EntranceShuffle.py

Lines changed: 50 additions & 50 deletions
Large diffs are not rendered by default.

worlds/alttp/ItemPool.py

Lines changed: 85 additions & 85 deletions
Large diffs are not rendered by default.

worlds/alttp/Items.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ def GetBeemizerItem(world, player: int, item):
1111
return item
1212

1313
# first roll - replaceable item should be replaced, within beemizer_total_chance
14-
if not world.beemizer_total_chance[player] or world.random.random() > (world.beemizer_total_chance[player] / 100):
14+
if not world.worlds[player].options.beemizer_total_chance or world.random.random() > (world.worlds[player].options.beemizer_total_chance / 100):
1515
return item
1616

1717
# second roll - bee replacement should be trap, within beemizer_trap_chance
18-
if not world.beemizer_trap_chance[player] or world.random.random() > (world.beemizer_trap_chance[player] / 100):
18+
if not world.worlds[player].options.beemizer_trap_chance or world.random.random() > (world.worlds[player].options.beemizer_trap_chance / 100):
1919
return "Bee" if isinstance(item, str) else world.create_item("Bee", player)
2020
else:
2121
return "Bee Trap" if isinstance(item, str) else world.create_item("Bee Trap", player)

worlds/alttp/Options.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ class OpenPyramid(Choice):
156156

157157
def to_bool(self, world: MultiWorld, player: int) -> bool:
158158
if self.value == self.option_goal:
159-
return world.goal[player].current_key in {'crystals', 'ganon_triforce_hunt', 'local_ganon_triforce_hunt', 'ganon_pedestal'}
159+
return world.worlds[player].options.goal.current_key in {'crystals', 'ganon_triforce_hunt', 'local_ganon_triforce_hunt', 'ganon_pedestal'}
160160
elif self.value == self.option_auto:
161-
return world.goal[player].current_key in {'crystals', 'ganon_triforce_hunt', 'local_ganon_triforce_hunt', 'ganon_pedestal'} \
162-
and (world.entrance_shuffle[player].current_key in {'vanilla', 'dungeons_simple', 'dungeons_full', 'dungeons_crossed'} or not
161+
return world.worlds[player].options.goal.current_key in {'crystals', 'ganon_triforce_hunt', 'local_ganon_triforce_hunt', 'ganon_pedestal'} \
162+
and (world.worlds[player].options.entrance_shuffle.current_key in {'vanilla', 'dungeons_simple', 'dungeons_full', 'dungeons_crossed'} or not
163163
world.shuffle_ganon)
164164
elif self.value == self.option_open:
165165
return True

worlds/alttp/OverworldGlitchRules.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,14 @@ def get_invalid_bunny_revival_dungeons():
220220

221221
def overworld_glitch_connections(world, player):
222222
# Boots-accessible locations.
223-
create_owg_connections(player, world, get_boots_clip_exits_lw(world.mode[player] == 'inverted'))
224-
create_owg_connections(player, world, get_boots_clip_exits_dw(world.mode[player] == 'inverted', player))
223+
create_owg_connections(player, world, get_boots_clip_exits_lw(world.worlds[player].options.mode == 'inverted'))
224+
create_owg_connections(player, world, get_boots_clip_exits_dw(world.worlds[player].options.mode == 'inverted', player))
225225

226226
# Glitched speed drops.
227-
create_owg_connections(player, world, get_glitched_speed_drops_dw(world.mode[player] == 'inverted'))
227+
create_owg_connections(player, world, get_glitched_speed_drops_dw(world.worlds[player].options.mode == 'inverted'))
228228

229229
# Mirror clip spots.
230-
if world.mode[player] != 'inverted':
230+
if world.worlds[player].options.mode != 'inverted':
231231
create_owg_connections(player, world, get_mirror_clip_spots_dw())
232232
create_owg_connections(player, world, get_mirror_offset_spots_dw())
233233
else:
@@ -237,24 +237,24 @@ def overworld_glitch_connections(world, player):
237237
def overworld_glitches_rules(world, player):
238238

239239
# Boots-accessible locations.
240-
set_owg_connection_rules(player, world, get_boots_clip_exits_lw(world.mode[player] == 'inverted'), lambda state: can_boots_clip_lw(state, player))
241-
set_owg_connection_rules(player, world, get_boots_clip_exits_dw(world.mode[player] == 'inverted', player), lambda state: can_boots_clip_dw(state, player))
240+
set_owg_connection_rules(player, world, get_boots_clip_exits_lw(world.worlds[player].options.mode == 'inverted'), lambda state: can_boots_clip_lw(state, player))
241+
set_owg_connection_rules(player, world, get_boots_clip_exits_dw(world.worlds[player].options.mode == 'inverted', player), lambda state: can_boots_clip_dw(state, player))
242242

243243
# Glitched speed drops.
244-
set_owg_connection_rules(player, world, get_glitched_speed_drops_dw(world.mode[player] == 'inverted'), lambda state: can_get_glitched_speed_dw(state, player))
244+
set_owg_connection_rules(player, world, get_glitched_speed_drops_dw(world.worlds[player].options.mode == 'inverted'), lambda state: can_get_glitched_speed_dw(state, player))
245245
# Dark Death Mountain Ledge Clip Spot also accessible with mirror.
246-
if world.mode[player] != 'inverted':
246+
if world.worlds[player].options.mode != 'inverted':
247247
add_alternate_rule(world.get_entrance('Dark Death Mountain Ledge Clip Spot', player), lambda state: state.has('Magic Mirror', player))
248248

249249
# Mirror clip spots.
250-
if world.mode[player] != 'inverted':
250+
if world.worlds[player].options.mode != 'inverted':
251251
set_owg_connection_rules(player, world, get_mirror_clip_spots_dw(), lambda state: state.has('Magic Mirror', player))
252252
set_owg_connection_rules(player, world, get_mirror_offset_spots_dw(), lambda state: state.has('Magic Mirror', player) and can_boots_clip_lw(state, player))
253253
else:
254254
set_owg_connection_rules(player, world, get_mirror_offset_spots_lw(player), lambda state: state.has('Magic Mirror', player) and can_boots_clip_dw(state, player))
255255

256256
# Regions that require the boots and some other stuff.
257-
if world.mode[player] != 'inverted':
257+
if world.worlds[player].options.mode != 'inverted':
258258
world.get_entrance('Turtle Rock Teleporter', player).access_rule = lambda state: (can_boots_clip_lw(state, player) or can_lift_heavy_rocks(state, player)) and state.has('Hammer', player)
259259
add_alternate_rule(world.get_entrance('Waterfall of Wishing', player), lambda state: state.has('Moon Pearl', player) or state.has('Pegasus Boots', player))
260260
else:

0 commit comments

Comments
 (0)