From b372b9da20390450fe53bfbcaa5dd4810a408df5 Mon Sep 17 00:00:00 2001 From: Alchav <59858495+Alchav@users.noreply.github.com> Date: Thu, 18 Apr 2024 15:33:41 -0400 Subject: [PATCH] LTTP: ToH Crystal Switch Logic (#3172) --- worlds/alttp/Rules.py | 9 ++++++--- worlds/alttp/StateHelpers.py | 7 +++++++ worlds/alttp/test/dungeons/TestTowerOfHera.py | 10 +++++++--- worlds/alttp/test/inverted_owg/TestDungeons.py | 3 ++- worlds/alttp/test/owg/TestDungeons.py | 8 ++++---- 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/worlds/alttp/Rules.py b/worlds/alttp/Rules.py index 9a13c2c5d02f..5e4635fa2754 100644 --- a/worlds/alttp/Rules.py +++ b/worlds/alttp/Rules.py @@ -18,7 +18,8 @@ can_shoot_arrows, has_beam_sword, has_crystals, has_fire_source, has_hearts, has_melee_weapon, has_misery_mire_medallion, has_sword, has_turtle_rock_medallion, - has_triforce_pieces, can_use_bombs, can_bomb_or_bonk) + has_triforce_pieces, can_use_bombs, can_bomb_or_bonk, + can_activate_crystal_switch) from .UnderworldGlitchRules import underworld_glitches_rules @@ -357,8 +358,10 @@ def global_rules(multiworld: MultiWorld, player: int): if not (multiworld.small_key_shuffle[player] and multiworld.big_key_shuffle[player]): add_rule(multiworld.get_location('Desert Palace - Prize', player), lambda state: state.multiworld.get_region('Desert Palace Main (Outer)', player).can_reach(state)) - set_rule(multiworld.get_entrance('Tower of Hera Small Key Door', player), lambda state: state._lttp_has_key('Small Key (Tower of Hera)', player) or location_item_name(state, 'Tower of Hera - Big Key Chest', player) == ('Small Key (Tower of Hera)', player)) - set_rule(multiworld.get_entrance('Tower of Hera Big Key Door', player), lambda state: state.has('Big Key (Tower of Hera)', player)) + set_rule(multiworld.get_location('Tower of Hera - Basement Cage', player), lambda state: can_activate_crystal_switch(state, player)) + set_rule(multiworld.get_location('Tower of Hera - Map Chest', player), lambda state: can_activate_crystal_switch(state, player)) + set_rule(multiworld.get_entrance('Tower of Hera Small Key Door', player), lambda state: can_activate_crystal_switch(state, player) and (state._lttp_has_key('Small Key (Tower of Hera)', player) or location_item_name(state, 'Tower of Hera - Big Key Chest', player) == ('Small Key (Tower of Hera)', player))) + set_rule(multiworld.get_entrance('Tower of Hera Big Key Door', player), lambda state: can_activate_crystal_switch(state, player) and state.has('Big Key (Tower of Hera)', player)) if multiworld.enemy_shuffle[player]: add_rule(multiworld.get_entrance('Tower of Hera Big Key Door', player), lambda state: can_kill_most_things(state, player, 3)) else: diff --git a/worlds/alttp/StateHelpers.py b/worlds/alttp/StateHelpers.py index 80bf3c1ad77f..fe3a43ee0f55 100644 --- a/worlds/alttp/StateHelpers.py +++ b/worlds/alttp/StateHelpers.py @@ -106,6 +106,12 @@ def can_bomb_or_bonk(state: CollectionState, player: int) -> bool: return state.has("Pegasus Boots", player) or can_use_bombs(state, player) +def can_activate_crystal_switch(state: CollectionState, player: int) -> bool: + return (has_melee_weapon(state, player) or can_use_bombs(state, player) or can_shoot_arrows(state, player) + or state.has_any(["Hookshot", "Cane of Somaria", "Cane of Byrna", "Fire Rod", "Ice Rod", "Blue Boomerang", + "Red Boomerang"], player)) + + def can_kill_most_things(state: CollectionState, player: int, enemies: int = 5) -> bool: if state.multiworld.enemy_shuffle[player]: # I don't fully understand Enemizer's logic for placing enemies in spots where they need to be killable, if any. @@ -173,6 +179,7 @@ def can_melt_things(state: CollectionState, player: int) -> bool: def has_misery_mire_medallion(state: CollectionState, player: int) -> bool: return state.has(state.multiworld.worlds[player].required_medallions[0], player) + def has_turtle_rock_medallion(state: CollectionState, player: int) -> bool: return state.has(state.multiworld.worlds[player].required_medallions[1], player) diff --git a/worlds/alttp/test/dungeons/TestTowerOfHera.py b/worlds/alttp/test/dungeons/TestTowerOfHera.py index 3299e20291b0..29cbcbf91fe2 100644 --- a/worlds/alttp/test/dungeons/TestTowerOfHera.py +++ b/worlds/alttp/test/dungeons/TestTowerOfHera.py @@ -9,12 +9,16 @@ def testTowerOfHera(self): ["Tower of Hera - Big Key Chest", False, []], ["Tower of Hera - Big Key Chest", False, [], ['Small Key (Tower of Hera)']], ["Tower of Hera - Big Key Chest", False, [], ['Lamp', 'Fire Rod']], - ["Tower of Hera - Big Key Chest", True, ['Small Key (Tower of Hera)', 'Lamp']], + ["Tower of Hera - Big Key Chest", True, ['Small Key (Tower of Hera)', 'Lamp', 'Bomb Upgrade (50)']], ["Tower of Hera - Big Key Chest", True, ['Small Key (Tower of Hera)', 'Fire Rod']], - ["Tower of Hera - Basement Cage", True, []], + ["Tower of Hera - Basement Cage", False, []], + ["Tower of Hera - Basement Cage", True, ['Bomb Upgrade (50)']], + ["Tower of Hera - Basement Cage", True, ['Progressive Sword']], - ["Tower of Hera - Map Chest", True, []], + ["Tower of Hera - Map Chest", False, []], + ["Tower of Hera - Map Chest", True, ['Bomb Upgrade (50)']], + ["Tower of Hera - Map Chest", True, ['Progressive Sword']], ["Tower of Hera - Compass Chest", False, []], ["Tower of Hera - Compass Chest", False, [], ['Big Key (Tower of Hera)']], diff --git a/worlds/alttp/test/inverted_owg/TestDungeons.py b/worlds/alttp/test/inverted_owg/TestDungeons.py index 53b12bdf89d1..ada1b92fca49 100644 --- a/worlds/alttp/test/inverted_owg/TestDungeons.py +++ b/worlds/alttp/test/inverted_owg/TestDungeons.py @@ -41,7 +41,8 @@ def testFirstDungeonChests(self): ["Tower of Hera - Basement Cage", False, []], ["Tower of Hera - Basement Cage", False, [], ['Moon Pearl']], - ["Tower of Hera - Basement Cage", True, ['Pegasus Boots', 'Moon Pearl']], + ["Tower of Hera - Basement Cage", True, ['Pegasus Boots', 'Moon Pearl', 'Bomb Upgrade (50)']], + ["Tower of Hera - Basement Cage", True, ['Pegasus Boots', 'Moon Pearl', 'Progressive Sword']], ["Castle Tower - Room 03", False, []], ["Castle Tower - Room 03", False, [], ['Bomb Upgrade (+5)', 'Bomb Upgrade (+10)', 'Bomb Upgrade (50)', 'Progressive Sword', 'Hammer', 'Progressive Bow', 'Fire Rod', 'Ice Rod', 'Cane of Somaria', 'Cane of Byrna']], diff --git a/worlds/alttp/test/owg/TestDungeons.py b/worlds/alttp/test/owg/TestDungeons.py index e43e18d16cf2..2e55b308d327 100644 --- a/worlds/alttp/test/owg/TestDungeons.py +++ b/worlds/alttp/test/owg/TestDungeons.py @@ -34,11 +34,11 @@ def testFirstDungeonChests(self): ["Tower of Hera - Basement Cage", False, [], ['Pegasus Boots', "Flute", "Lamp"]], ["Tower of Hera - Basement Cage", False, [], ['Pegasus Boots', "Magic Mirror", "Hammer"]], ["Tower of Hera - Basement Cage", False, [], ['Pegasus Boots', "Magic Mirror", "Hookshot"]], - ["Tower of Hera - Basement Cage", True, ['Pegasus Boots']], - ["Tower of Hera - Basement Cage", True, ["Flute", "Magic Mirror"]], - ["Tower of Hera - Basement Cage", True, ["Progressive Glove", "Lamp", "Magic Mirror"]], + ["Tower of Hera - Basement Cage", True, ['Pegasus Boots', 'Bomb Upgrade (50)']], + ["Tower of Hera - Basement Cage", True, ["Flute", "Magic Mirror", 'Bomb Upgrade (50)']], + ["Tower of Hera - Basement Cage", True, ["Progressive Glove", "Lamp", "Magic Mirror", 'Bomb Upgrade (50)']], ["Tower of Hera - Basement Cage", True, ["Flute", "Hookshot", "Hammer"]], - ["Tower of Hera - Basement Cage", True, ["Progressive Glove", "Lamp", "Magic Mirror"]], + ["Tower of Hera - Basement Cage", True, ["Progressive Glove", "Lamp", "Magic Mirror", 'Bomb Upgrade (50)']], ["Castle Tower - Room 03", False, []], ["Castle Tower - Room 03", False, ['Progressive Sword'], ['Progressive Sword', 'Cape', 'Beat Agahnim 1']],