Lingo: Fix Basement access with THE MASTER (#3231)

This commit is contained in:
Star Rauchenberger 2024-06-03 04:51:27 -04:00 committed by GitHub
parent cff7327558
commit fb2c194e37
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 43 additions and 13 deletions

View File

@ -18,19 +18,23 @@ class AccessRequirements:
rooms: Set[str]
doors: Set[RoomAndDoor]
colors: Set[str]
the_master: bool
def __init__(self):
self.rooms = set()
self.doors = set()
self.colors = set()
self.the_master = False
def merge(self, other: "AccessRequirements"):
self.rooms |= other.rooms
self.doors |= other.doors
self.colors |= other.colors
self.the_master |= other.the_master
def __str__(self):
return f"AccessRequirements(rooms={self.rooms}, doors={self.doors}, colors={self.colors})"
return f"AccessRequirements(rooms={self.rooms}, doors={self.doors}, colors={self.colors})," \
f" the_master={self.the_master}"
class PlayerLocation(NamedTuple):
@ -463,6 +467,9 @@ class LingoPlayerLogic:
req_panel.panel, world)
access_reqs.merge(sub_access_reqs)
if panel == "THE MASTER":
access_reqs.the_master = True
self.panel_reqs[room][panel] = access_reqs
return self.panel_reqs[room][panel]
@ -502,15 +509,17 @@ class LingoPlayerLogic:
unhindered_panels_by_color: dict[Optional[str], int] = {}
for panel_name, panel_data in room_data.items():
# We won't count non-counting panels. THE MASTER has special access rules and is handled separately.
if panel_data.non_counting or panel_name == "THE MASTER":
# We won't count non-counting panels.
if panel_data.non_counting:
continue
# We won't coalesce any panels that have requirements beyond colors. To simplify things for now, we will
# only coalesce single-color panels. Chains/stacks/combo puzzles will be separate.
# only coalesce single-color panels. Chains/stacks/combo puzzles will be separate. THE MASTER has
# special access rules and is handled separately.
if len(panel_data.required_panels) > 0 or len(panel_data.required_doors) > 0\
or len(panel_data.required_rooms) > 0\
or (world.options.shuffle_colors and len(panel_data.colors) > 1):
or (world.options.shuffle_colors and len(panel_data.colors) > 1)\
or panel_name == "THE MASTER":
self.counting_panel_reqs.setdefault(room_name, []).append(
(self.calculate_panel_requirements(room_name, panel_name, world), 1))
else:

View File

@ -49,9 +49,16 @@ def connect_entrance(regions: Dict[str, Region], source_region: Region, target_r
if door is not None:
effective_room = target_region.name if door.room is None else door.room
if door.door not in world.player_logic.item_by_door.get(effective_room, {}):
for region in world.player_logic.calculate_door_requirements(effective_room, door.door, world).rooms:
access_reqs = world.player_logic.calculate_door_requirements(effective_room, door.door, world)
for region in access_reqs.rooms:
world.multiworld.register_indirect_condition(regions[region], connection)
# This pretty much only applies to Orange Tower Sixth Floor -> Orange Tower Basement.
if access_reqs.the_master:
for mastery_req in world.player_logic.mastery_reqs:
for region in mastery_req.rooms:
world.multiworld.register_indirect_condition(regions[region], connection)
if not pilgrimage and world.options.enable_pilgrimage and is_acceptable_pilgrimage_entrance(entrance_type, world)\
and source_region.name != "Menu":
for part in range(1, 6):

View File

@ -42,12 +42,6 @@ def lingo_can_use_level_2_location(state: CollectionState, world: "LingoWorld"):
counted_panels += panel_count
if counted_panels >= world.options.level_2_requirement.value - 1:
return True
# THE MASTER has to be handled separately, because it has special access rules.
if state.can_reach("Orange Tower Seventh Floor", "Region", world.player)\
and lingo_can_use_mastery_location(state, world):
counted_panels += 1
if counted_panels >= world.options.level_2_requirement.value - 1:
return True
return False
@ -65,6 +59,9 @@ def _lingo_can_satisfy_requirements(state: CollectionState, access: AccessRequir
if not state.has(color.capitalize(), world.player):
return False
if access.the_master and not lingo_can_use_mastery_location(state, world):
return False
return True

View File

@ -37,3 +37,20 @@ class TestMasteryWhenVictoryIsTheMaster(LingoTestBase):
self.collect_by_name(["Green", "Gray", "Brown", "Yellow"])
self.assertTrue(self.can_reach_location("Orange Tower Seventh Floor - Mastery Achievements"))
class TestMasteryBlocksDependents(LingoTestBase):
options = {
"mastery_achievements": "24",
"shuffle_colors": "true",
"location_checks": "insanity"
}
def test_requirement(self):
self.collect_all_but("Gray")
self.assertFalse(self.can_reach_location("Orange Tower Basement - THE LIBRARY"))
self.assertFalse(self.can_reach_location("Orange Tower Seventh Floor - MASTERY"))
self.collect_by_name("Gray")
self.assertTrue(self.can_reach_location("Orange Tower Basement - THE LIBRARY"))
self.assertTrue(self.can_reach_location("Orange Tower Seventh Floor - MASTERY"))