From 5fecb7f0433c306b8ddb4b368eb14fdbd0454e3b Mon Sep 17 00:00:00 2001 From: Aaron Wagener Date: Mon, 11 Mar 2024 04:00:28 -0500 Subject: [PATCH] LTTP: fix some hashed string comparisons (#2927) --- worlds/alttp/ItemPool.py | 2 +- worlds/alttp/Options.py | 2 +- worlds/alttp/Rules.py | 2 +- worlds/alttp/__init__.py | 21 ++++++++++--------- .../TestInvertedMinor.py | 5 +++-- .../test/inverted_owg/TestInvertedOWG.py | 5 +++-- worlds/alttp/test/minor_glitches/TestMinor.py | 3 ++- worlds/alttp/test/owg/TestVanillaOWG.py | 3 ++- worlds/alttp/test/vanilla/TestVanilla.py | 3 ++- 9 files changed, 26 insertions(+), 20 deletions(-) diff --git a/worlds/alttp/ItemPool.py b/worlds/alttp/ItemPool.py index 0e799a61..3929342a 100644 --- a/worlds/alttp/ItemPool.py +++ b/worlds/alttp/ItemPool.py @@ -605,7 +605,7 @@ def get_pool_core(world, player: int): placed_items[loc] = item # provide boots to major glitch dependent seeds - if logic 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.glitch_boots[player]: precollected_items.append('Pegasus Boots') pool.remove('Pegasus Boots') pool.append('Rupees (20)') diff --git a/worlds/alttp/Options.py b/worlds/alttp/Options.py index afd52955..2b23dc34 100644 --- a/worlds/alttp/Options.py +++ b/worlds/alttp/Options.py @@ -156,7 +156,7 @@ class OpenPyramid(Choice): return world.goal[player].current_key in {'crystals', 'ganon_triforce_hunt', 'local_ganon_triforce_hunt', 'ganon_pedestal'} elif self.value == self.option_auto: return world.goal[player].current_key in {'crystals', 'ganon_triforce_hunt', 'local_ganon_triforce_hunt', 'ganon_pedestal'} \ - and (world.entrance_shuffle[player] in {'vanilla', 'dungeons_simple', 'dungeons_full', 'dungeons_crossed'} or not + and (world.entrance_shuffle[player].current_key in {'vanilla', 'dungeons_simple', 'dungeons_full', 'dungeons_crossed'} or not world.shuffle_ganon) elif self.value == self.option_open: return True diff --git a/worlds/alttp/Rules.py b/worlds/alttp/Rules.py index c3156116..320f9fe6 100644 --- a/worlds/alttp/Rules.py +++ b/worlds/alttp/Rules.py @@ -89,7 +89,7 @@ def set_rules(world): if world.mode[player] != 'inverted': set_big_bomb_rules(world, player) - if world.glitches_required[player] in {'overworld_glitches', 'hybrid_major_glitches', 'no_logic'} and world.entrance_shuffle[player] not in {'insanity', 'insanity_legacy', 'madness'}: + if world.glitches_required[player].current_key in {'overworld_glitches', 'hybrid_major_glitches', 'no_logic'} and world.entrance_shuffle[player].current_key not in {'insanity', 'insanity_legacy', 'madness'}: path_to_courtyard = mirrorless_path_to_castle_courtyard(world, player) add_rule(world.get_entrance('Pyramid Fairy', player), lambda state: state.multiworld.get_entrance('Dark Death Mountain Offset Mirror', player).can_reach(state) and all(rule(state) for rule in path_to_courtyard), 'or') else: diff --git a/worlds/alttp/__init__.py b/worlds/alttp/__init__.py index a7ade61c..63c53007 100644 --- a/worlds/alttp/__init__.py +++ b/worlds/alttp/__init__.py @@ -642,17 +642,18 @@ class ALTTPWorld(World): return ALttPItem(name, self.player, **item_init_table[name]) @classmethod - def stage_fill_hook(cls, world, progitempool, usefulitempool, filleritempool, fill_locations): + def stage_fill_hook(cls, multiworld, progitempool, usefulitempool, filleritempool, fill_locations): trash_counts = {} - for player in world.get_game_players("A Link to the Past"): - if not world.ganonstower_vanilla[player] or \ - world.glitches_required[player] in {'overworld_glitches', 'hybrid_major_glitches', "no_logic"}: + for player in multiworld.get_game_players("A Link to the Past"): + world = multiworld.worlds[player] + if not multiworld.ganonstower_vanilla[player] or \ + world.options.glitches_required.current_key in {'overworld_glitches', 'hybrid_major_glitches', "no_logic"}: pass - elif 'triforce_hunt' in world.goal[player].current_key and ('local' in world.goal[player].current_key or world.players == 1): - trash_counts[player] = world.random.randint(world.crystals_needed_for_gt[player] * 2, - world.crystals_needed_for_gt[player] * 4) + elif 'triforce_hunt' in world.options.goal.current_key and ('local' in world.options.goal.current_key or world.players == 1): + trash_counts[player] = multiworld.random.randint(world.options.crystals_needed_for_gt * 2, + world.options.crystals_needed_for_gt * 4) else: - trash_counts[player] = world.random.randint(0, world.crystals_needed_for_gt[player] * 2) + trash_counts[player] = multiworld.random.randint(0, world.options.crystals_needed_for_gt * 2) if trash_counts: locations_mapping = {player: [] for player in trash_counts} @@ -662,14 +663,14 @@ class ALTTPWorld(World): for player, trash_count in trash_counts.items(): gtower_locations = locations_mapping[player] - world.random.shuffle(gtower_locations) + multiworld.random.shuffle(gtower_locations) while gtower_locations and filleritempool and trash_count > 0: spot_to_fill = gtower_locations.pop() for index, item in enumerate(filleritempool): if spot_to_fill.item_rule(item): filleritempool.pop(index) # remove from outer fill - world.push_item(spot_to_fill, item, False) + multiworld.push_item(spot_to_fill, item, False) fill_locations.remove(spot_to_fill) # very slow, unfortunately trash_count -= 1 break diff --git a/worlds/alttp/test/inverted_minor_glitches/TestInvertedMinor.py b/worlds/alttp/test/inverted_minor_glitches/TestInvertedMinor.py index 21dbae69..912cca43 100644 --- a/worlds/alttp/test/inverted_minor_glitches/TestInvertedMinor.py +++ b/worlds/alttp/test/inverted_minor_glitches/TestInvertedMinor.py @@ -1,8 +1,9 @@ -from worlds.alttp.Dungeons import create_dungeons, get_dungeon_item_pool +from worlds.alttp.Dungeons import get_dungeon_item_pool from worlds.alttp.EntranceShuffle import link_inverted_entrances from worlds.alttp.InvertedRegions import create_inverted_regions from worlds.alttp.ItemPool import difficulties from worlds.alttp.Items import item_factory +from worlds.alttp.Options import GlitchesRequired from worlds.alttp.Regions import mark_light_world_regions from worlds.alttp.Shops import create_shops from test.TestBase import TestBase @@ -14,7 +15,7 @@ class TestInvertedMinor(TestBase, LTTPTestBase): def setUp(self): self.world_setup() self.multiworld.mode[1].value = 2 - self.multiworld.glitches_required[1] = "minor_glitches" + self.multiworld.glitches_required[1] = GlitchesRequired.from_any("minor_glitches") self.multiworld.bombless_start[1].value = True self.multiworld.shuffle_capacity_upgrades[1].value = True self.multiworld.difficulty_requirements[1] = difficulties['normal'] diff --git a/worlds/alttp/test/inverted_owg/TestInvertedOWG.py b/worlds/alttp/test/inverted_owg/TestInvertedOWG.py index 138324a9..fc38437e 100644 --- a/worlds/alttp/test/inverted_owg/TestInvertedOWG.py +++ b/worlds/alttp/test/inverted_owg/TestInvertedOWG.py @@ -1,8 +1,9 @@ -from worlds.alttp.Dungeons import create_dungeons, get_dungeon_item_pool +from worlds.alttp.Dungeons import get_dungeon_item_pool from worlds.alttp.EntranceShuffle import link_inverted_entrances from worlds.alttp.InvertedRegions import create_inverted_regions from worlds.alttp.ItemPool import difficulties from worlds.alttp.Items import item_factory +from worlds.alttp.Options import GlitchesRequired from worlds.alttp.Regions import mark_light_world_regions from worlds.alttp.Shops import create_shops from test.TestBase import TestBase @@ -13,7 +14,7 @@ from worlds.alttp.test import LTTPTestBase class TestInvertedOWG(TestBase, LTTPTestBase): def setUp(self): self.world_setup() - self.multiworld.glitches_required[1] = "overworld_glitches" + self.multiworld.glitches_required[1] = GlitchesRequired.from_any("overworld_glitches") self.multiworld.mode[1].value = 2 self.multiworld.bombless_start[1].value = True self.multiworld.shuffle_capacity_upgrades[1].value = True diff --git a/worlds/alttp/test/minor_glitches/TestMinor.py b/worlds/alttp/test/minor_glitches/TestMinor.py index 547509d5..a7b52938 100644 --- a/worlds/alttp/test/minor_glitches/TestMinor.py +++ b/worlds/alttp/test/minor_glitches/TestMinor.py @@ -3,6 +3,7 @@ from worlds.alttp.InvertedRegions import mark_dark_world_regions from worlds.alttp.ItemPool import difficulties from worlds.alttp.Items import item_factory from test.TestBase import TestBase +from worlds.alttp.Options import GlitchesRequired from worlds.alttp.test import LTTPTestBase @@ -10,7 +11,7 @@ from worlds.alttp.test import LTTPTestBase class TestMinor(TestBase, LTTPTestBase): def setUp(self): self.world_setup() - self.multiworld.glitches_required[1] = "minor_glitches" + self.multiworld.glitches_required[1] = GlitchesRequired.from_any("minor_glitches") self.multiworld.bombless_start[1].value = True self.multiworld.shuffle_capacity_upgrades[1].value = True self.multiworld.difficulty_requirements[1] = difficulties['normal'] diff --git a/worlds/alttp/test/owg/TestVanillaOWG.py b/worlds/alttp/test/owg/TestVanillaOWG.py index aafc04a7..35061545 100644 --- a/worlds/alttp/test/owg/TestVanillaOWG.py +++ b/worlds/alttp/test/owg/TestVanillaOWG.py @@ -3,6 +3,7 @@ from worlds.alttp.InvertedRegions import mark_dark_world_regions from worlds.alttp.ItemPool import difficulties from worlds.alttp.Items import item_factory from test.TestBase import TestBase +from worlds.alttp.Options import GlitchesRequired from worlds.alttp.test import LTTPTestBase @@ -11,7 +12,7 @@ class TestVanillaOWG(TestBase, LTTPTestBase): def setUp(self): self.world_setup() self.multiworld.difficulty_requirements[1] = difficulties['normal'] - self.multiworld.glitches_required[1] = "overworld_glitches" + self.multiworld.glitches_required[1] = GlitchesRequired.from_any("overworld_glitches") self.multiworld.bombless_start[1].value = True self.multiworld.shuffle_capacity_upgrades[1].value = True self.multiworld.worlds[1].er_seed = 0 diff --git a/worlds/alttp/test/vanilla/TestVanilla.py b/worlds/alttp/test/vanilla/TestVanilla.py index e79b4f2e..5865ddf9 100644 --- a/worlds/alttp/test/vanilla/TestVanilla.py +++ b/worlds/alttp/test/vanilla/TestVanilla.py @@ -3,13 +3,14 @@ from worlds.alttp.InvertedRegions import mark_dark_world_regions from worlds.alttp.ItemPool import difficulties from worlds.alttp.Items import item_factory from test.TestBase import TestBase +from worlds.alttp.Options import GlitchesRequired from worlds.alttp.test import LTTPTestBase class TestVanilla(TestBase, LTTPTestBase): def setUp(self): self.world_setup() - self.multiworld.glitches_required[1] = "no_glitches" + self.multiworld.glitches_required[1] = GlitchesRequired.from_any("no_glitches") self.multiworld.difficulty_requirements[1] = difficulties['normal'] self.multiworld.bombless_start[1].value = True self.multiworld.shuffle_capacity_upgrades[1].value = True