Tests: Add a test for fill to WorldTestBase (#2049)
* Tests: Add a test for fill to WorldTestBase * test items and minimal accessibility, only bailing out when no reachable locations exist. * put egg shard max/goal at sane values 114 locations - 35 always-present progression items - 25 excluded locations from settings <= 74 egg shards past me can't do arithmetic * f * i'm bad at git * make fill import local to prevent circular imports --------- Co-authored-by: espeon65536 <espeon65536@gmail.com>
This commit is contained in:
parent
fd93f6e722
commit
5eeaf834cb
|
@ -6,7 +6,7 @@ from test.general import gen_steps
|
|||
from worlds import AutoWorld
|
||||
from worlds.AutoWorld import call_all
|
||||
|
||||
from BaseClasses import MultiWorld, CollectionState, ItemClassification, Item
|
||||
from BaseClasses import Location, MultiWorld, CollectionState, ItemClassification, Item
|
||||
from worlds.alttp.Items import ItemFactory
|
||||
|
||||
|
||||
|
@ -275,3 +275,37 @@ class WorldTestBase(unittest.TestCase):
|
|||
locations = self.multiworld.get_reachable_locations(state, 1)
|
||||
self.assertGreater(len(locations), 0,
|
||||
"Need to be able to reach at least one location to get started.")
|
||||
|
||||
def testFill(self):
|
||||
"""Generates a multiworld and validates placements with the defined options"""
|
||||
# don't run this test if accessibility is set manually
|
||||
if not (self.run_default_tests and self.constructed):
|
||||
return
|
||||
from Fill import distribute_items_restrictive
|
||||
|
||||
# basically a shortened reimplementation of this method from core, in order to force the check is done
|
||||
def fulfills_accessibility():
|
||||
locations = self.multiworld.get_locations(1).copy()
|
||||
state = CollectionState(self.multiworld)
|
||||
while locations:
|
||||
sphere: typing.List[Location] = []
|
||||
for n in range(len(locations) - 1, -1, -1):
|
||||
if locations[n].can_reach(state):
|
||||
sphere.append(locations.pop(n))
|
||||
self.assertTrue(sphere or self.multiworld.accessibility[1] == "minimal",
|
||||
f"Unreachable locations: {locations}")
|
||||
if not sphere:
|
||||
break
|
||||
for location in sphere:
|
||||
if location.item:
|
||||
state.collect(location.item, True, location)
|
||||
|
||||
return self.multiworld.has_beaten_game(state, 1)
|
||||
|
||||
with self.subTest("Game", game=self.game):
|
||||
distribute_items_restrictive(self.multiworld)
|
||||
call_all(self.multiworld, "post_fill")
|
||||
self.assertTrue(fulfills_accessibility(), "Collected all locations, but can't beat the game.")
|
||||
placed_items = [loc.item for loc in self.multiworld.get_locations() if loc.item and loc.item.code]
|
||||
self.assertLessEqual(len(self.multiworld.itempool), len(placed_items),
|
||||
"Unplaced Items remaining in itempool")
|
||||
|
|
|
@ -14,7 +14,7 @@ class EggShardsRequired(Range):
|
|||
"""Number of dragon egg shards to collect to spawn bosses."""
|
||||
display_name = "Egg Shards Required"
|
||||
range_start = 0
|
||||
range_end = 74
|
||||
range_end = 50
|
||||
default = 0
|
||||
|
||||
|
||||
|
@ -22,7 +22,7 @@ class EggShardsAvailable(Range):
|
|||
"""Number of dragon egg shards available to collect."""
|
||||
display_name = "Egg Shards Available"
|
||||
range_start = 0
|
||||
range_end = 74
|
||||
range_end = 50
|
||||
default = 0
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue