mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
Lingo: Fix Basement access with THE MASTER (#3231)
This commit is contained in:

committed by
GitHub

parent
cff7327558
commit
fb2c194e37
@@ -18,19 +18,23 @@ class AccessRequirements:
|
|||||||
rooms: Set[str]
|
rooms: Set[str]
|
||||||
doors: Set[RoomAndDoor]
|
doors: Set[RoomAndDoor]
|
||||||
colors: Set[str]
|
colors: Set[str]
|
||||||
|
the_master: bool
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.rooms = set()
|
self.rooms = set()
|
||||||
self.doors = set()
|
self.doors = set()
|
||||||
self.colors = set()
|
self.colors = set()
|
||||||
|
self.the_master = False
|
||||||
|
|
||||||
def merge(self, other: "AccessRequirements"):
|
def merge(self, other: "AccessRequirements"):
|
||||||
self.rooms |= other.rooms
|
self.rooms |= other.rooms
|
||||||
self.doors |= other.doors
|
self.doors |= other.doors
|
||||||
self.colors |= other.colors
|
self.colors |= other.colors
|
||||||
|
self.the_master |= other.the_master
|
||||||
|
|
||||||
def __str__(self):
|
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):
|
class PlayerLocation(NamedTuple):
|
||||||
@@ -463,6 +467,9 @@ class LingoPlayerLogic:
|
|||||||
req_panel.panel, world)
|
req_panel.panel, world)
|
||||||
access_reqs.merge(sub_access_reqs)
|
access_reqs.merge(sub_access_reqs)
|
||||||
|
|
||||||
|
if panel == "THE MASTER":
|
||||||
|
access_reqs.the_master = True
|
||||||
|
|
||||||
self.panel_reqs[room][panel] = access_reqs
|
self.panel_reqs[room][panel] = access_reqs
|
||||||
|
|
||||||
return self.panel_reqs[room][panel]
|
return self.panel_reqs[room][panel]
|
||||||
@@ -502,15 +509,17 @@ class LingoPlayerLogic:
|
|||||||
unhindered_panels_by_color: dict[Optional[str], int] = {}
|
unhindered_panels_by_color: dict[Optional[str], int] = {}
|
||||||
|
|
||||||
for panel_name, panel_data in room_data.items():
|
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.
|
# We won't count non-counting panels.
|
||||||
if panel_data.non_counting or panel_name == "THE MASTER":
|
if panel_data.non_counting:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# We won't coalesce any panels that have requirements beyond colors. To simplify things for now, we will
|
# 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\
|
if len(panel_data.required_panels) > 0 or len(panel_data.required_doors) > 0\
|
||||||
or len(panel_data.required_rooms) > 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.counting_panel_reqs.setdefault(room_name, []).append(
|
||||||
(self.calculate_panel_requirements(room_name, panel_name, world), 1))
|
(self.calculate_panel_requirements(room_name, panel_name, world), 1))
|
||||||
else:
|
else:
|
||||||
|
@@ -49,8 +49,15 @@ def connect_entrance(regions: Dict[str, Region], source_region: Region, target_r
|
|||||||
if door is not None:
|
if door is not None:
|
||||||
effective_room = target_region.name if door.room is None else door.room
|
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, {}):
|
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)
|
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)\
|
if not pilgrimage and world.options.enable_pilgrimage and is_acceptable_pilgrimage_entrance(entrance_type, world)\
|
||||||
and source_region.name != "Menu":
|
and source_region.name != "Menu":
|
||||||
|
@@ -42,12 +42,6 @@ def lingo_can_use_level_2_location(state: CollectionState, world: "LingoWorld"):
|
|||||||
counted_panels += panel_count
|
counted_panels += panel_count
|
||||||
if counted_panels >= world.options.level_2_requirement.value - 1:
|
if counted_panels >= world.options.level_2_requirement.value - 1:
|
||||||
return True
|
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
|
return False
|
||||||
|
|
||||||
|
|
||||||
@@ -65,6 +59,9 @@ def _lingo_can_satisfy_requirements(state: CollectionState, access: AccessRequir
|
|||||||
if not state.has(color.capitalize(), world.player):
|
if not state.has(color.capitalize(), world.player):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
if access.the_master and not lingo_can_use_mastery_location(state, world):
|
||||||
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@@ -36,4 +36,21 @@ class TestMasteryWhenVictoryIsTheMaster(LingoTestBase):
|
|||||||
self.assertFalse(self.can_reach_location("Orange Tower Seventh Floor - Mastery Achievements"))
|
self.assertFalse(self.can_reach_location("Orange Tower Seventh Floor - Mastery Achievements"))
|
||||||
|
|
||||||
self.collect_by_name(["Green", "Gray", "Brown", "Yellow"])
|
self.collect_by_name(["Green", "Gray", "Brown", "Yellow"])
|
||||||
self.assertTrue(self.can_reach_location("Orange Tower Seventh Floor - Mastery Achievements"))
|
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"))
|
||||||
|
Reference in New Issue
Block a user