Skip to content

Commit

Permalink
Expand the unit test for forbidden doors
Browse files Browse the repository at this point in the history
  • Loading branch information
NewSoupVi committed Dec 10, 2024
1 parent 7710e0c commit f970d8a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 12 deletions.
6 changes: 2 additions & 4 deletions worlds/witness/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ def generate_early(self) -> None:
)
self.player_regions: WitnessPlayerRegions = WitnessPlayerRegions(self.player_locations, self)

self.log_ids_to_hints = {}
self.log_ids_to_hints: Dict[int, CompactHintData] = {}
self.laser_ids_to_hints: Dict[int, CompactHintData] = {}

self.determine_sufficient_progression()

Expand Down Expand Up @@ -326,9 +327,6 @@ def create_items(self) -> None:
self.options.local_items.value.add(item_name)

def fill_slot_data(self) -> Dict[str, Any]:
self.log_ids_to_hints: Dict[int, CompactHintData] = {}
self.laser_ids_to_hints: Dict[int, CompactHintData] = {}

already_hinted_locations = set()

# Laser hints
Expand Down
47 changes: 39 additions & 8 deletions worlds/witness/test/test_door_shuffle.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from typing import cast

from .. import WitnessWorld
from ..test import WitnessMultiworldTestBase, WitnessTestBase


Expand Down Expand Up @@ -32,6 +35,10 @@ class TestForbiddenDoors(WitnessMultiworldTestBase):
{
"early_caves": "add_to_pool",
},
{
"early_caves": "add_to_pool",
"door_groupings": "regional",
},
]

common_options = {
Expand All @@ -40,11 +47,35 @@ class TestForbiddenDoors(WitnessMultiworldTestBase):
}

def test_forbidden_doors(self) -> None:
self.assertTrue(
self.get_items_by_name("Caves Mountain Shortcut (Panel)", 1),
"Caves Mountain Shortcut (Panel) should exist in panels shuffle, but it didn't."
)
self.assertFalse(
self.get_items_by_name("Caves Mountain Shortcut (Panel)", 2),
"Caves Mountain Shortcut (Panel) should be removed when Early Caves is enabled, but it still exists."
)
with self.subTest("Test that Caves Mountain Shortcut (Panel) exists if Early Caves is off"):
self.assertTrue(
self.get_items_by_name("Caves Mountain Shortcut (Panel)", 1),
"Caves Mountain Shortcut (Panel) should exist in panels shuffle, but it didn't."
)

with self.subTest("Test that Caves Mountain Shortcut (Panel) doesn't exist if Early Caves is start_to_pool"):
self.assertFalse(
self.get_items_by_name("Caves Mountain Shortcut (Panel)", 2),
"Caves Mountain Shortcut (Panel) should be removed when Early Caves is enabled, but it still exists."
)

with self.subTest("Test that slot data is set up correctly for a panels seed with Early Caves"):
slot_data = cast(WitnessWorld, self.multiworld.worlds[3])._get_slot_data()

self.assertIn(
WitnessWorld.item_name_to_id["Caves Panels"],
slot_data["door_items_in_the_pool"],
'Caves Panels should still exist in slot_data under "door_items_in_the_pool".'
)

self.assertIn(
0x021D7,
slot_data["item_id_to_door_hexes"][WitnessWorld.item_name_to_id["Caves Panels"]],
"Caves Panels should still contain Caves Mountain Shortcut Panel as a door they unlock.",
)

self.assertIn(
0x021D7,
slot_data["doors_that_shouldnt_be_locked"],
"Caves Mountain Shortcut Panel should be marked as \"shouldn't be locked\".",
)

0 comments on commit f970d8a

Please sign in to comment.