Archipelago/worlds/messenger/test/TestShopChest.py

80 lines
3.3 KiB
Python
Raw Normal View History

The Messenger: implement new game (#1494) * initial commit of messenger integration * setup no_logic and needed slot_data * fix some typos and determinism * make all of it deterministic * add documentation * swapped to non local items so change the fed data * ~~deathlink~~ * satisfy the docs test * update doc test to show expected name * split custom classes into a separate file and fix an errant rule * make access dependency test give more useful errors * implement tests * remove some unneccessary back entrances and make names clearer * fix some big dumbs * successful unit tests are good also some slight reorganizing * add astral tea quest line, and potentially power seals as items * if TYPE_CHECKING... aahhhhhh * oop forgot to remove legacy code * having the seed and leaves as actual items doesn't seem to do anything so remove them. locations still work though * update setup guide with some changes * Tower HQ was creating duplicate locations * allow self locking items * cleanup * move self_locking_items function to core * docstring * implement choice of notes needed for music box * test the default value * don't create any starting inventory items * make item creation faster * change default accessibility and power seals options * improve documentation * precollected_items is a dict of Items... * implement shop chest goal * tests * always assign total and required seals * add new goals and set music box as requiring shop chest on shop chest goals instead of just setting it as the completion * fix dumb test quirk * implement music box skip as an option * world rewrite/cleanup * default to apworld and add game to readme * revert bleeding commits from other PRs * more bleeds * fix some errors in options docstrings * ??? * make my set rules method not have an awful name * test cleanup * add a test for item accessibility * fix issues with tests * make the self locking item behavior work correctly * misc cleanup * more general cleanup to be a good example * quick rules rewrite * more general cleanup and typing * more speed, more clean * bump data version * make sure the locked item belongs to current player * fix bad name and indent. call MessengerItem directly for events * add poptracker pack to docs * doc cleanup and "known issues" section that I probably won't be able to fix any time soon. * missed some spots * add another bug i forgot about * be consistently wrong
2023-03-12 14:05:50 +00:00
from BaseClasses import ItemClassification, CollectionState
from . import MessengerTestBase
class NoLogicTest(MessengerTestBase):
options = {
"enable_logic": "false",
"goal": "power_seal_hunt",
}
def testChestAccess(self):
"""Test to make sure we can win even though we can't reach the chest."""
self.assertEqual(self.can_reach_location("Shop Chest"), False)
self.assertBeatable(True)
class AllSealsRequired(MessengerTestBase):
options = {
"shuffle_seals": "false",
"goal": "power_seal_hunt",
}
def testSealsShuffled(self) -> None:
"""Shuffle seals should be forced on when shop chest is the goal so test it."""
self.assertTrue(self.multiworld.shuffle_seals[self.player])
def testChestAccess(self) -> None:
"""Defaults to a total of 45 power seals in the pool and required."""
with self.subTest("Access Dependency"):
self.assertEqual(len([seal for seal in self.multiworld.itempool if seal.name == "Power Seal"]),
self.multiworld.total_seals[self.player])
locations = ["Shop Chest"]
items = [["Power Seal"]]
self.assertAccessDependency(locations, items)
self.multiworld.state = CollectionState(self.multiworld)
self.assertEqual(self.can_reach_location("Shop Chest"), False)
self.assertBeatable(False)
self.collect_all_but(["Power Seal", "Shop Chest", "Rescue Phantom"])
self.assertEqual(self.can_reach_location("Shop Chest"), False)
self.assertBeatable(False)
self.collect_by_name("Power Seal")
self.assertEqual(self.can_reach_location("Shop Chest"), True)
self.assertBeatable(True)
class HalfSealsRequired(MessengerTestBase):
options = {
"goal": "power_seal_hunt",
"percent_seals_required": 50,
}
def testSealsAmount(self) -> None:
"""Should have 45 power seals in the item pool and half that required"""
self.assertEqual(self.multiworld.total_seals[self.player], 45)
self.assertEqual(self.multiworld.worlds[self.player].total_seals, 45)
self.assertEqual(self.multiworld.worlds[self.player].required_seals, 22)
total_seals = [seal for seal in self.multiworld.itempool if seal.name == "Power Seal"]
required_seals = [seal for seal in total_seals if seal.classification == ItemClassification.progression_skip_balancing]
self.assertEqual(len(total_seals), 45)
self.assertEqual(len(required_seals), 22)
class ThirtyThirtySeals(MessengerTestBase):
options = {
"goal": "power_seal_hunt",
"total_seals": 30,
"percent_seals_required": 34,
}
def testSealsAmount(self) -> None:
"""Should have 30 power seals in the pool and 33 percent of that required."""
self.assertEqual(self.multiworld.total_seals[self.player], 30)
self.assertEqual(self.multiworld.worlds[self.player].total_seals, 30)
self.assertEqual(self.multiworld.worlds[self.player].required_seals, 10)
total_seals = [seal for seal in self.multiworld.itempool if seal.name == "Power Seal"]
required_seals = [seal for seal in total_seals if seal.classification == ItemClassification.progression_skip_balancing]
self.assertEqual(len(total_seals), 30)
self.assertEqual(len(required_seals), 10)