Core: replace Location.event with advancement property (#2871)

This commit is contained in:
Aaron Wagener
2024-04-14 13:37:48 -05:00
committed by GitHub
parent f67e8497e0
commit 842a15fd3c
35 changed files with 79 additions and 144 deletions

View File

@@ -371,8 +371,7 @@ class TestLocationGeneration(SVTestBase):
def test_all_location_created_are_in_location_table(self):
for location in self.get_real_locations():
if not location.event:
self.assertIn(location.name, location_table)
self.assertIn(location.name, location_table)
class TestMinLocationAndMaxItem(SVTestBase):
@@ -771,11 +770,10 @@ class TestShipsanityNone(SVTestBase):
}
def test_no_shipsanity_locations(self):
for location in self.multiworld.get_locations(self.player):
if not location.event:
with self.subTest(location.name):
self.assertFalse("Shipsanity" in location.name)
self.assertNotIn(LocationTags.SHIPSANITY, location_table[location.name].tags)
for location in self.get_real_locations():
with self.subTest(location.name):
self.assertFalse("Shipsanity" in location.name)
self.assertNotIn(LocationTags.SHIPSANITY, location_table[location.name].tags)
class TestShipsanityCrops(SVTestBase):
@@ -785,8 +783,8 @@ class TestShipsanityCrops(SVTestBase):
}
def test_only_crop_shipsanity_locations(self):
for location in self.multiworld.get_locations(self.player):
if not location.event and LocationTags.SHIPSANITY in location_table[location.name].tags:
for location in self.get_real_locations():
if LocationTags.SHIPSANITY in location_table[location.name].tags:
with self.subTest(location.name):
self.assertIn(LocationTags.SHIPSANITY_CROP, location_table[location.name].tags)
@@ -808,8 +806,8 @@ class TestShipsanityCropsExcludeIsland(SVTestBase):
}
def test_only_crop_shipsanity_locations(self):
for location in self.multiworld.get_locations(self.player):
if not location.event and LocationTags.SHIPSANITY in location_table[location.name].tags:
for location in self.get_real_locations():
if LocationTags.SHIPSANITY in location_table[location.name].tags:
with self.subTest(location.name):
self.assertIn(LocationTags.SHIPSANITY_CROP, location_table[location.name].tags)
@@ -831,8 +829,8 @@ class TestShipsanityCropsNoQiCropWithoutSpecialOrders(SVTestBase):
}
def test_only_crop_shipsanity_locations(self):
for location in self.multiworld.get_locations(self.player):
if not location.event and LocationTags.SHIPSANITY in location_table[location.name].tags:
for location in self.get_real_locations():
if LocationTags.SHIPSANITY in location_table[location.name].tags:
with self.subTest(location.name):
self.assertIn(LocationTags.SHIPSANITY_CROP, location_table[location.name].tags)
@@ -854,8 +852,8 @@ class TestShipsanityFish(SVTestBase):
}
def test_only_fish_shipsanity_locations(self):
for location in self.multiworld.get_locations(self.player):
if not location.event and LocationTags.SHIPSANITY in location_table[location.name].tags:
for location in self.get_real_locations():
if LocationTags.SHIPSANITY in location_table[location.name].tags:
with self.subTest(location.name):
self.assertIn(LocationTags.SHIPSANITY_FISH, location_table[location.name].tags)
@@ -878,8 +876,8 @@ class TestShipsanityFishExcludeIsland(SVTestBase):
}
def test_only_fish_shipsanity_locations(self):
for location in self.multiworld.get_locations(self.player):
if not location.event and LocationTags.SHIPSANITY in location_table[location.name].tags:
for location in self.get_real_locations():
if LocationTags.SHIPSANITY in location_table[location.name].tags:
with self.subTest(location.name):
self.assertIn(LocationTags.SHIPSANITY_FISH, location_table[location.name].tags)
@@ -902,8 +900,8 @@ class TestShipsanityFishExcludeQiOrders(SVTestBase):
}
def test_only_fish_shipsanity_locations(self):
for location in self.multiworld.get_locations(self.player):
if not location.event and LocationTags.SHIPSANITY in location_table[location.name].tags:
for location in self.get_real_locations():
if LocationTags.SHIPSANITY in location_table[location.name].tags:
with self.subTest(location.name):
self.assertIn(LocationTags.SHIPSANITY_FISH, location_table[location.name].tags)
@@ -926,8 +924,8 @@ class TestShipsanityFullShipment(SVTestBase):
}
def test_only_full_shipment_shipsanity_locations(self):
for location in self.multiworld.get_locations(self.player):
if not location.event and LocationTags.SHIPSANITY in location_table[location.name].tags:
for location in self.get_real_locations():
if LocationTags.SHIPSANITY in location_table[location.name].tags:
with self.subTest(location.name):
self.assertIn(LocationTags.SHIPSANITY_FULL_SHIPMENT, location_table[location.name].tags)
self.assertNotIn(LocationTags.SHIPSANITY_FISH, location_table[location.name].tags)
@@ -953,8 +951,8 @@ class TestShipsanityFullShipmentExcludeIsland(SVTestBase):
}
def test_only_full_shipment_shipsanity_locations(self):
for location in self.multiworld.get_locations(self.player):
if not location.event and LocationTags.SHIPSANITY in location_table[location.name].tags:
for location in self.get_real_locations():
if LocationTags.SHIPSANITY in location_table[location.name].tags:
with self.subTest(location.name):
self.assertIn(LocationTags.SHIPSANITY_FULL_SHIPMENT, location_table[location.name].tags)
self.assertNotIn(LocationTags.SHIPSANITY_FISH, location_table[location.name].tags)
@@ -979,8 +977,8 @@ class TestShipsanityFullShipmentExcludeQiBoard(SVTestBase):
}
def test_only_full_shipment_shipsanity_locations(self):
for location in self.multiworld.get_locations(self.player):
if not location.event and LocationTags.SHIPSANITY in location_table[location.name].tags:
for location in self.get_real_locations():
if LocationTags.SHIPSANITY in location_table[location.name].tags:
with self.subTest(location.name):
self.assertIn(LocationTags.SHIPSANITY_FULL_SHIPMENT, location_table[location.name].tags)
self.assertNotIn(LocationTags.SHIPSANITY_FISH, location_table[location.name].tags)
@@ -1006,8 +1004,8 @@ class TestShipsanityFullShipmentWithFish(SVTestBase):
}
def test_only_full_shipment_and_fish_shipsanity_locations(self):
for location in self.multiworld.get_locations(self.player):
if not location.event and LocationTags.SHIPSANITY in location_table[location.name].tags:
for location in self.get_real_locations():
if LocationTags.SHIPSANITY in location_table[location.name].tags:
with self.subTest(location.name):
self.assertTrue(LocationTags.SHIPSANITY_FULL_SHIPMENT in location_table[location.name].tags or
LocationTags.SHIPSANITY_FISH in location_table[location.name].tags)
@@ -1041,8 +1039,8 @@ class TestShipsanityFullShipmentWithFishExcludeIsland(SVTestBase):
}
def test_only_full_shipment_and_fish_shipsanity_locations(self):
for location in self.multiworld.get_locations(self.player):
if not location.event and LocationTags.SHIPSANITY in location_table[location.name].tags:
for location in self.get_real_locations():
if LocationTags.SHIPSANITY in location_table[location.name].tags:
with self.subTest(location.name):
self.assertTrue(LocationTags.SHIPSANITY_FULL_SHIPMENT in location_table[location.name].tags or
LocationTags.SHIPSANITY_FISH in location_table[location.name].tags)
@@ -1075,8 +1073,8 @@ class TestShipsanityFullShipmentWithFishExcludeQiBoard(SVTestBase):
}
def test_only_full_shipment_and_fish_shipsanity_locations(self):
for location in self.multiworld.get_locations(self.player):
if not location.event and LocationTags.SHIPSANITY in location_table[location.name].tags:
for location in self.get_real_locations():
if LocationTags.SHIPSANITY in location_table[location.name].tags:
with self.subTest(location.name):
self.assertTrue(LocationTags.SHIPSANITY_FULL_SHIPMENT in location_table[location.name].tags or
LocationTags.SHIPSANITY_FISH in location_table[location.name].tags)

View File

@@ -557,8 +557,8 @@ class TestDonationLogicRandomized(SVTestBase):
railroad_item = "Railroad Boulder Removed"
swap_museum_and_bathhouse(self.multiworld, self.player)
collect_all_except(self.multiworld, railroad_item)
donation_locations = [location for location in self.multiworld.get_locations() if
not location.event and LocationTags.MUSEUM_DONATIONS in location_table[location.name].tags]
donation_locations = [location for location in self.get_real_locations() if
LocationTags.MUSEUM_DONATIONS in location_table[location.name].tags]
for donation in donation_locations:
self.assertFalse(self.world.logic.region.can_reach_location(donation.name)(self.multiworld.state))
@@ -713,10 +713,9 @@ class TestShipsanityNone(SVTestBase):
}
def test_no_shipsanity_locations(self):
for location in self.multiworld.get_locations(self.player):
if not location.event:
self.assertFalse("Shipsanity" in location.name)
self.assertNotIn(LocationTags.SHIPSANITY, location_table[location.name].tags)
for location in self.get_real_locations():
self.assertFalse("Shipsanity" in location.name)
self.assertNotIn(LocationTags.SHIPSANITY, location_table[location.name].tags)
class TestShipsanityCrops(SVTestBase):
@@ -725,8 +724,8 @@ class TestShipsanityCrops(SVTestBase):
}
def test_only_crop_shipsanity_locations(self):
for location in self.multiworld.get_locations(self.player):
if not location.event and LocationTags.SHIPSANITY in location_table[location.name].tags:
for location in self.get_real_locations():
if LocationTags.SHIPSANITY in location_table[location.name].tags:
self.assertIn(LocationTags.SHIPSANITY_CROP, location_table[location.name].tags)
@@ -736,8 +735,8 @@ class TestShipsanityFish(SVTestBase):
}
def test_only_fish_shipsanity_locations(self):
for location in self.multiworld.get_locations(self.player):
if not location.event and LocationTags.SHIPSANITY in location_table[location.name].tags:
for location in self.get_real_locations():
if LocationTags.SHIPSANITY in location_table[location.name].tags:
self.assertIn(LocationTags.SHIPSANITY_FISH, location_table[location.name].tags)
@@ -747,8 +746,8 @@ class TestShipsanityFullShipment(SVTestBase):
}
def test_only_full_shipment_shipsanity_locations(self):
for location in self.multiworld.get_locations(self.player):
if not location.event and LocationTags.SHIPSANITY in location_table[location.name].tags:
for location in self.get_real_locations():
if LocationTags.SHIPSANITY in location_table[location.name].tags:
self.assertIn(LocationTags.SHIPSANITY_FULL_SHIPMENT, location_table[location.name].tags)
self.assertNotIn(LocationTags.SHIPSANITY_FISH, location_table[location.name].tags)
@@ -759,8 +758,8 @@ class TestShipsanityFullShipmentWithFish(SVTestBase):
}
def test_only_full_shipment_and_fish_shipsanity_locations(self):
for location in self.multiworld.get_locations(self.player):
if not location.event and LocationTags.SHIPSANITY in location_table[location.name].tags:
for location in self.get_real_locations():
if LocationTags.SHIPSANITY in location_table[location.name].tags:
self.assertTrue(LocationTags.SHIPSANITY_FULL_SHIPMENT in location_table[location.name].tags or
LocationTags.SHIPSANITY_FISH in location_table[location.name].tags)
@@ -774,8 +773,8 @@ class TestShipsanityEverything(SVTestBase):
def test_all_shipsanity_locations_require_shipping_bin(self):
bin_name = "Shipping Bin"
collect_all_except(self.multiworld, bin_name)
shipsanity_locations = [location for location in self.multiworld.get_locations() if
not location.event and LocationTags.SHIPSANITY in location_table[location.name].tags]
shipsanity_locations = [location for location in self.get_real_locations() if
LocationTags.SHIPSANITY in location_table[location.name].tags]
bin_item = self.world.create_item(bin_name)
for location in shipsanity_locations:
with self.subTest(location.name):

View File

@@ -277,10 +277,10 @@ class SVTestBase(RuleAssertMixin, WorldTestBase, SVTestCase):
self.multiworld.state.collect(self.world.create_item("Stardrop"), event=False)
def get_real_locations(self) -> List[Location]:
return [location for location in self.multiworld.get_locations(self.player) if not location.event]
return [location for location in self.multiworld.get_locations(self.player) if location.address is not None]
def get_real_location_names(self) -> List[str]:
return [location.name for location in self.multiworld.get_locations(self.player) if not location.event]
return [location.name for location in self.get_real_locations()]
pre_generated_worlds = {}

View File

@@ -20,7 +20,7 @@ class ModAssertMixin(TestCase):
self.assertTrue(item.mod_name is None or item.mod_name in chosen_mods,
f"Item {item.name} has is from mod {item.mod_name}. Allowed mods are {chosen_mods}.")
for multiworld_location in multiworld.get_locations():
if multiworld_location.event:
if multiworld_location.address is None:
continue
location = location_table[multiworld_location.name]
self.assertTrue(location.mod_name is None or location.mod_name in chosen_mods)

View File

@@ -13,7 +13,7 @@ def get_all_item_names(multiworld: MultiWorld) -> List[str]:
def get_all_location_names(multiworld: MultiWorld) -> List[str]:
return [location.name for location in multiworld.get_locations() if not location.event]
return [location.name for location in multiworld.get_locations() if location.address is not None]
class WorldAssertMixin(RuleAssertMixin, TestCase):
@@ -48,7 +48,7 @@ class WorldAssertMixin(RuleAssertMixin, TestCase):
self.assert_can_reach_victory(multiworld)
def assert_same_number_items_locations(self, multiworld: MultiWorld):
non_event_locations = [location for location in multiworld.get_locations() if not location.event]
non_event_locations = [location for location in multiworld.get_locations() if location.address is not None]
self.assertEqual(len(multiworld.itempool), len(non_event_locations))
def assert_can_reach_everything(self, multiworld: MultiWorld):