The Witness: Add info about which door items exist in the pool to slot data (#3583)

* This feature is just broken lol

* simplify

* mypy

* Expand the unit test for forbidden doors
This commit is contained in:
NewSoupVi 2024-12-25 21:55:15 +01:00 committed by GitHub
parent fe81053521
commit 62942704bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 49 additions and 26 deletions

View File

@ -84,7 +84,8 @@ class WitnessWorld(World):
"victory_location": int(self.player_logic.VICTORY_LOCATION, 16),
"panelhex_to_id": self.player_locations.CHECK_PANELHEX_TO_ID,
"item_id_to_door_hexes": static_witness_items.get_item_to_door_mappings(),
"door_hexes_in_the_pool": self.player_items.get_door_ids_in_pool(),
"door_items_in_the_pool": self.player_items.get_door_item_ids_in_pool(),
"doors_that_shouldnt_be_locked": [int(h, 16) for h in self.player_logic.FORBIDDEN_DOORS],
"symbols_not_in_the_game": self.player_items.get_symbol_ids_not_in_pool(),
"disabled_entities": [int(h, 16) for h in self.player_logic.COMPLETELY_DISABLED_ENTITIES],
"hunt_entities": [int(h, 16) for h in self.player_logic.HUNT_ENTITIES],
@ -150,7 +151,8 @@ class WitnessWorld(World):
)
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()
@ -325,9 +327,6 @@ class WitnessWorld(World):
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

View File

@ -222,20 +222,15 @@ class WitnessPlayerItems:
# Sort the output for consistency across versions if the implementation changes but the logic does not.
return sorted(output)
def get_door_ids_in_pool(self) -> List[int]:
def get_door_item_ids_in_pool(self) -> List[int]:
"""
Returns the total set of all door IDs that are controlled by items in the pool.
Returns the ids of all door items that exist in the pool.
"""
output: List[int] = []
for item_name, item_data in self.item_data.items():
if not isinstance(item_data.definition, DoorItemDefinition):
continue
output += [int(hex_string, 16) for hex_string in item_data.definition.panel_id_hexes
if hex_string not in self._logic.FORBIDDEN_DOORS]
return output
return [
cast_not_none(item_data.ap_code) for item_data in self.item_data.values()
if isinstance(item_data.definition, DoorItemDefinition)
]
def get_symbol_ids_not_in_pool(self) -> List[int]:
"""
@ -257,5 +252,3 @@ class WitnessPlayerItems:
output[cast_not_none(item.ap_code)] = [cast_not_none(static_witness_items.ITEM_DATA[child_item].ap_code)
for child_item in item.definition.child_item_names]
return output

View File

@ -1,3 +1,6 @@
from typing import cast
from .. import WitnessWorld
from ..test import WitnessMultiworldTestBase, WitnessTestBase
@ -32,6 +35,10 @@ class TestForbiddenDoors(WitnessMultiworldTestBase):
{
"early_caves": "add_to_pool",
},
{
"early_caves": "add_to_pool",
"door_groupings": "regional",
},
]
common_options = {
@ -40,11 +47,35 @@ class TestForbiddenDoors(WitnessMultiworldTestBase):
}
def test_forbidden_doors(self) -> None:
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\".",
)