From 4b65e45ecc21b154860f3db3b5cb938469a379a1 Mon Sep 17 00:00:00 2001 From: Jarno Westhof Date: Mon, 24 Feb 2025 22:59:40 +0100 Subject: [PATCH] Fixed some bugs --- test/general/test_ids.py | 17 ++++++++++++++++- worlds/satisfactory/Locations.py | 14 ++++++++------ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/test/general/test_ids.py b/test/general/test_ids.py index e51a070c1f..b09170d1a9 100644 --- a/test/general/test_ids.py +++ b/test/general/test_ids.py @@ -52,8 +52,23 @@ class TestIDs(unittest.TestCase): def test_duplicate_location_ids(self): """Test that a game doesn't have location id overlap within its own datapackage""" for gamename, world_type in AutoWorldRegister.world_types.items(): + self.maxDiff = None + with self.subTest(game=gamename): - self.assertEqual(len(world_type.location_id_to_name), len(world_type.location_name_to_id)) + len_location_id_to_name = len(world_type.location_id_to_name) + len_location_name_to_id = len(world_type.location_name_to_id) + + if len_location_id_to_name != len_location_name_to_id: + self.assertCountEqual( + world_type.location_id_to_name.values(), + world_type.location_name_to_id.keys(), + "\nThese locations have overlapping ids with other locations in its own world") + self.assertCountEqual( + world_type.location_id_to_name.keys(), + world_type.location_name_to_id.values(), + "\nThese locations have overlapping names with other locations in its own world") + + self.assertEqual(len_location_id_to_name, len_location_name_to_id) def test_postgen_datapackage(self): """Generates a solo multiworld and checks that the datapackage is still valid""" diff --git a/worlds/satisfactory/Locations.py b/worlds/satisfactory/Locations.py index 55ddbe7879..9b5f75e532 100644 --- a/worlds/satisfactory/Locations.py +++ b/worlds/satisfactory/Locations.py @@ -342,8 +342,8 @@ class Locations(): number_of_slots_per_milestone_for_game = self.game_logic.slots_per_milestone hub_location_id = self.hub_location_start - for tier in range(1, self.max_tiers + 1): - for milestone in range(1, max_tier + 1): + for tier in range(1, max_tier + 1): + for milestone in range(1, self.max_milestones + 1): for slot in range(1, number_of_slots_per_milestone_for_game + 1): if for_data_package: location_table.append(HubSlot(tier, milestone, slot, hub_location_id)) @@ -371,14 +371,16 @@ class Locations(): location_table.extend( part for part_name, recipes in self.game_logic.recipes.items() - for part in Part.get_parts(self.state_logic, recipes, part_name, self.items) - if part in self.critical_path.potential_required_parts) + if part_name in self.critical_path.potential_required_parts + for part in Part.get_parts(self.state_logic, recipes, part_name, self.items)) location_table.extend( EventBuilding(self.game_logic, self.state_logic, name, building) - for name, building in self.game_logic.buildings.items()) + for name, building in self.game_logic.buildings.items() + if name in self.critical_path.potential_required_buildings) location_table.extend( PowerInfrastructure(self.game_logic, self.state_logic, power_level, recipes) - for power_level, recipes in self.game_logic.requirement_per_powerlevel.items()) + for power_level, recipes in self.game_logic.requirement_per_powerlevel.items() + if power_level <= self.critical_path.potential_required_power) return location_table