From d481ab5311b5163e30dbd58c57f5d9439e74b2aa Mon Sep 17 00:00:00 2001 From: EnvyDragon <138727357+EnvyDragon@users.noreply.github.com> Date: Sun, 30 Jun 2024 17:55:58 -0400 Subject: [PATCH] SC2: Fixing epilogue exclusion bug --- worlds/sc2/options.py | 7 +++++-- worlds/sc2/test/test_usecases.py | 32 ++++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/worlds/sc2/options.py b/worlds/sc2/options.py index 1a48402a6102..4a7d3f7e0158 100644 --- a/worlds/sc2/options.py +++ b/worlds/sc2/options.py @@ -965,7 +965,7 @@ def get_enabled_races(world: 'SC2World') -> Set[SC2Race]: selection = get_option_value(world, 'selected_races') if selection == SelectRaces.option_all: return set(SC2Race) - enabled = set() + enabled = {SC2Race.ANY} if selection & MissionFlag.Terran: enabled.add(SC2Race.TERRAN) if selection & MissionFlag.Zerg: @@ -987,7 +987,10 @@ def get_enabled_campaigns(world: 'SC2World') -> Set[SC2Campaign]: enabled_campaigns.add(SC2Campaign.PROLOGUE) if get_option_value(world, "enable_lotv_missions"): enabled_campaigns.add(SC2Campaign.LOTV) - if get_option_value(world, "enable_epilogue_missions"): + # Force-disable epilogue missions if vanilla mission order with at least 1 disabled faction + if get_option_value(world, "enable_epilogue_missions") \ + and (get_option_value(world, "mission_order") != MissionOrder.option_vanilla + or get_option_value(world, "selected_races") == SelectRaces.option_all): enabled_campaigns.add(SC2Campaign.EPILOGUE) if get_option_value(world, "enable_nco_missions"): enabled_campaigns.add(SC2Campaign.NCO) diff --git a/worlds/sc2/test/test_usecases.py b/worlds/sc2/test/test_usecases.py index 05873afd7ec6..adea595fe595 100644 --- a/worlds/sc2/test/test_usecases.py +++ b/worlds/sc2/test/test_usecases.py @@ -164,7 +164,7 @@ def test_excluding_protoss_excludes_campaigns_and_items(self) -> None: 'enable_lotv_prologue_missions': True, 'enable_lotv_missions': True, 'enable_epilogue_missions': True, - 'mission_order': options.MissionOrder.option_vanilla_shuffled, + 'mission_order': options.MissionOrder.option_grid, } self.generate_world(world_options) world_item_names = [item.name for item in self.multiworld.itempool] @@ -174,7 +174,7 @@ def test_excluding_protoss_excludes_campaigns_and_items(self) -> None: self.assertNotEqual(items.item_table[item_name].race, mission_tables.SC2Race.PROTOSS, f"{item_name} is a PROTOSS item!") for region in world_regions: self.assertNotIn(mission_tables.lookup_name_to_mission[region].campaign, - (mission_tables.SC2Campaign.LOTV, mission_tables.SC2Campaign.PROPHECY, mission_tables.SC2Campaign.PROLOGUE, mission_tables.SC2Campaign.EPILOGUE), + (mission_tables.SC2Campaign.LOTV, mission_tables.SC2Campaign.PROPHECY, mission_tables.SC2Campaign.PROLOGUE), f"{region} is a PROTOSS mission!") def test_excluding_terran_excludes_campaigns_and_items(self) -> None: @@ -187,7 +187,7 @@ def test_excluding_terran_excludes_campaigns_and_items(self) -> None: 'enable_lotv_prologue_missions': True, 'enable_lotv_missions': True, 'enable_epilogue_missions': True, - 'mission_order': options.MissionOrder.option_vanilla_shuffled, + 'mission_order': options.MissionOrder.option_grid, } self.generate_world(world_options) world_item_names = [item.name for item in self.multiworld.itempool] @@ -198,7 +198,7 @@ def test_excluding_terran_excludes_campaigns_and_items(self) -> None: f"{item_name} is a TERRAN item!") for region in world_regions: self.assertNotIn(mission_tables.lookup_name_to_mission[region].campaign, - (mission_tables.SC2Campaign.WOL, mission_tables.SC2Campaign.NCO, mission_tables.SC2Campaign.EPILOGUE), + (mission_tables.SC2Campaign.WOL, mission_tables.SC2Campaign.NCO), f"{region} is a TERRAN mission!") def test_excluding_zerg_excludes_campaigns_and_items(self) -> None: @@ -211,7 +211,7 @@ def test_excluding_zerg_excludes_campaigns_and_items(self) -> None: 'enable_lotv_prologue_missions': True, 'enable_lotv_missions': True, 'enable_epilogue_missions': True, - 'mission_order': options.MissionOrder.option_vanilla_shuffled, + 'mission_order': options.MissionOrder.option_grid, } self.generate_world(world_options) world_item_names = [item.name for item in self.multiworld.itempool] @@ -222,5 +222,25 @@ def test_excluding_zerg_excludes_campaigns_and_items(self) -> None: f"{item_name} is a ZERG item!") for region in world_regions: self.assertNotIn(mission_tables.lookup_name_to_mission[region].campaign, - (mission_tables.SC2Campaign.HOTS, mission_tables.SC2Campaign.EPILOGUE), + ([mission_tables.SC2Campaign.HOTS]), f"{region} is a ZERG mission!") + + def test_excluding_faction_on_vanilla_order_excludes_epilogue(self) -> None: + world_options = { + 'selected_races': options.SelectRaces.option_terran_and_protoss, + 'enable_wol_missions': True, + 'enable_nco_missions': True, + 'enable_prophecy_missions': True, + 'enable_hots_missions': True, + 'enable_lotv_prologue_missions': True, + 'enable_lotv_missions': True, + 'enable_epilogue_missions': True, + 'mission_order': options.MissionOrder.option_vanilla, + } + self.generate_world(world_options) + world_regions = [region.name for region in self.multiworld.regions] + world_regions.remove('Menu') + for region in world_regions: + self.assertNotIn(mission_tables.lookup_name_to_mission[region].campaign, + ([mission_tables.SC2Campaign.EPILOGUE]), + f"{region} is an epilogue mission!")