summary refs log tree commit diff stats
path: root/player_logic.py
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2024-06-03 04:51:27 -0400
committerGitHub <noreply@github.com>2024-06-03 03:51:27 -0500
commite75c4b6b26ae2406a40718e084ad15421c9ce3be (patch)
treee94414fc9b3c3d8ca292222b18460b174f2f2e34 /player_logic.py
parent50e452717500aaaa8ea056f127cc2c4b353c310a (diff)
downloadlingo-apworld-e75c4b6b26ae2406a40718e084ad15421c9ce3be.tar.gz
lingo-apworld-e75c4b6b26ae2406a40718e084ad15421c9ce3be.tar.bz2
lingo-apworld-e75c4b6b26ae2406a40718e084ad15421c9ce3be.zip
Lingo: Fix Basement access with THE MASTER (#3231)
Diffstat (limited to 'player_logic.py')
-rw-r--r--player_logic.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/player_logic.py b/player_logic.py index b6941f3..1621620 100644 --- a/player_logic.py +++ b/player_logic.py
@@ -18,19 +18,23 @@ class AccessRequirements:
18 rooms: Set[str] 18 rooms: Set[str]
19 doors: Set[RoomAndDoor] 19 doors: Set[RoomAndDoor]
20 colors: Set[str] 20 colors: Set[str]
21 the_master: bool
21 22
22 def __init__(self): 23 def __init__(self):
23 self.rooms = set() 24 self.rooms = set()
24 self.doors = set() 25 self.doors = set()
25 self.colors = set() 26 self.colors = set()
27 self.the_master = False
26 28
27 def merge(self, other: "AccessRequirements"): 29 def merge(self, other: "AccessRequirements"):
28 self.rooms |= other.rooms 30 self.rooms |= other.rooms
29 self.doors |= other.doors 31 self.doors |= other.doors
30 self.colors |= other.colors 32 self.colors |= other.colors
33 self.the_master |= other.the_master
31 34
32 def __str__(self): 35 def __str__(self):
33 return f"AccessRequirements(rooms={self.rooms}, doors={self.doors}, colors={self.colors})" 36 return f"AccessRequirements(rooms={self.rooms}, doors={self.doors}, colors={self.colors})," \
37 f" the_master={self.the_master}"
34 38
35 39
36class PlayerLocation(NamedTuple): 40class PlayerLocation(NamedTuple):
@@ -463,6 +467,9 @@ class LingoPlayerLogic:
463 req_panel.panel, world) 467 req_panel.panel, world)
464 access_reqs.merge(sub_access_reqs) 468 access_reqs.merge(sub_access_reqs)
465 469
470 if panel == "THE MASTER":
471 access_reqs.the_master = True
472
466 self.panel_reqs[room][panel] = access_reqs 473 self.panel_reqs[room][panel] = access_reqs
467 474
468 return self.panel_reqs[room][panel] 475 return self.panel_reqs[room][panel]
@@ -502,15 +509,17 @@ class LingoPlayerLogic:
502 unhindered_panels_by_color: dict[Optional[str], int] = {} 509 unhindered_panels_by_color: dict[Optional[str], int] = {}
503 510
504 for panel_name, panel_data in room_data.items(): 511 for panel_name, panel_data in room_data.items():
505 # We won't count non-counting panels. THE MASTER has special access rules and is handled separately. 512 # We won't count non-counting panels.
506 if panel_data.non_counting or panel_name == "THE MASTER": 513 if panel_data.non_counting:
507 continue 514 continue
508 515
509 # We won't coalesce any panels that have requirements beyond colors. To simplify things for now, we will 516 # We won't coalesce any panels that have requirements beyond colors. To simplify things for now, we will
510 # only coalesce single-color panels. Chains/stacks/combo puzzles will be separate. 517 # only coalesce single-color panels. Chains/stacks/combo puzzles will be separate. THE MASTER has
518 # special access rules and is handled separately.
511 if len(panel_data.required_panels) > 0 or len(panel_data.required_doors) > 0\ 519 if len(panel_data.required_panels) > 0 or len(panel_data.required_doors) > 0\
512 or len(panel_data.required_rooms) > 0\ 520 or len(panel_data.required_rooms) > 0\
513 or (world.options.shuffle_colors and len(panel_data.colors) > 1): 521 or (world.options.shuffle_colors and len(panel_data.colors) > 1)\
522 or panel_name == "THE MASTER":
514 self.counting_panel_reqs.setdefault(room_name, []).append( 523 self.counting_panel_reqs.setdefault(room_name, []).append(
515 (self.calculate_panel_requirements(room_name, panel_name, world), 1)) 524 (self.calculate_panel_requirements(room_name, panel_name, world), 1))
516 else: 525 else: