diff --git a/worlds/sc2/options.py b/worlds/sc2/options.py index f3db0b1749a3..1a48402a6102 100644 --- a/worlds/sc2/options.py +++ b/worlds/sc2/options.py @@ -364,7 +364,7 @@ class VanillaItemsOnly(Toggle): # Current maximum number of upgrades for a unit -MAX_UPGRADES_OPTION = 12 +MAX_UPGRADES_OPTION = 14 class EnsureGenericItems(Range): diff --git a/worlds/sc2/test/test_items.py b/worlds/sc2/test/test_items.py index e2073b6f6922..a1324bd34f48 100644 --- a/worlds/sc2/test/test_items.py +++ b/worlds/sc2/test/test_items.py @@ -66,3 +66,60 @@ def test_number_distinct_in_item_type(self) -> None: item_numbers: Set[int] = {items.get_full_item_list()[item_name] for item_name in item_names} self.assertEqual(len(item_names), len(item_numbers)) + + def test_progressive_has_quantity(self) -> None: + progressive_groups: List[items.ItemTypeEnum] = [ + items.TerranItemType.Progressive, + items.TerranItemType.Progressive_2, + items.ProtossItemType.Progressive + ] + + quantities: List[int] = [ + items.get_full_item_list()[item].quantity for item in items.get_full_item_list() + if items.get_full_item_list()[item].type in progressive_groups + ] + + self.assertNotIn(1, quantities) + + def test_non_progressive_quantity(self) -> None: + non_progressive_single_entity_groups: List[items.ItemTypeEnum] = [ + # Terran + items.TerranItemType.Unit, + items.TerranItemType.Mercenary, + items.TerranItemType.Armory_1, + items.TerranItemType.Armory_2, + items.TerranItemType.Armory_3, + items.TerranItemType.Armory_4, + items.TerranItemType.Armory_5, + items.TerranItemType.Armory_6, + items.TerranItemType.Building, + items.TerranItemType.Laboratory, + items.TerranItemType.Nova_Gear, + # Zerg + items.ZergItemType.Unit, + items.ZergItemType.Mercenary, + items.ZergItemType.Morph, + items.ZergItemType.Strain, + items.ZergItemType.Mutation_1, + items.ZergItemType.Mutation_2, + items.ZergItemType.Mutation_3, + items.ZergItemType.Evolution_Pit, + items.ZergItemType.Ability, + # Protoss + items.ProtossItemType.Unit, + items.ProtossItemType.Unit_2, + items.ProtossItemType.Building, + items.ProtossItemType.Forge_1, + items.ProtossItemType.Forge_2, + items.ProtossItemType.Forge_3, + items.ProtossItemType.Solarite_Core, + items.ProtossItemType.Spear_Of_Adun + ] + + quantities: List[int] = [ + items.get_full_item_list()[item].quantity for item in items.get_full_item_list() + if items.get_full_item_list()[item].type in non_progressive_single_entity_groups + ] + + for quantity in quantities: + self.assertLessEqual(quantity, 1) diff --git a/worlds/sc2/test/test_options.py b/worlds/sc2/test/test_options.py index b8a04e0f0b44..793a6b5313bb 100644 --- a/worlds/sc2/test/test_options.py +++ b/worlds/sc2/test/test_options.py @@ -1,8 +1,29 @@ import unittest +from typing import Set, Dict, List + from .test_base import Sc2TestBase -from .. import mission_tables, options +from .. import mission_tables, options, items class TestOptions(unittest.TestCase): - def test_campaign_size_option_max_matches_number_of_missions(self): + def test_campaign_size_option_max_matches_number_of_missions(self) -> None: self.assertEqual(options.MaximumCampaignSize.range_end, len(mission_tables.SC2Mission)) + + def test_unit_max_upgrades_matching_items(self) -> None: + base_items: Set[str] = { + items.get_full_item_list()[item].parent_item for item in items.get_full_item_list() + if items.get_full_item_list()[item].parent_item is not None + } + + upgrade_items: Dict[str, List[str]] = dict() + for item in base_items: + upgrade_items[item] = [ + upgrade_item for upgrade_item in items.get_full_item_list() + if items.get_full_item_list()[upgrade_item].parent_item == item + ] + upgrade_counter: List[int] = list() + for item in base_items: + quantities: List[int] = [items.get_full_item_list()[upgrade_item].quantity for upgrade_item in upgrade_items[item]] + upgrade_counter.append(sum(quantities)) + + self.assertEqual(options.MAX_UPGRADES_OPTION, max(upgrade_counter))