diff options
Diffstat (limited to 'apworld/player_logic.py')
| -rw-r--r-- | apworld/player_logic.py | 265 |
1 files changed, 226 insertions, 39 deletions
| diff --git a/apworld/player_logic.py b/apworld/player_logic.py index 42b36e6..3ee8f38 100644 --- a/apworld/player_logic.py +++ b/apworld/player_logic.py | |||
| @@ -4,7 +4,7 @@ from .generated import data_pb2 as data_pb2 | |||
| 4 | from .items import SYMBOL_ITEMS | 4 | from .items import SYMBOL_ITEMS |
| 5 | from typing import TYPE_CHECKING, NamedTuple | 5 | from typing import TYPE_CHECKING, NamedTuple |
| 6 | 6 | ||
| 7 | from .options import VictoryCondition, ShuffleLetters, CyanDoorBehavior | 7 | from .options import ShuffleLetters, CyanDoorBehavior |
| 8 | 8 | ||
| 9 | if TYPE_CHECKING: | 9 | if TYPE_CHECKING: |
| 10 | from . import Lingo2World | 10 | from . import Lingo2World |
| @@ -30,6 +30,11 @@ class AccessRequirements: | |||
| 30 | # This is an AND of ORs. | 30 | # This is an AND of ORs. |
| 31 | or_logic: list[list["AccessRequirements"]] | 31 | or_logic: list[list["AccessRequirements"]] |
| 32 | 32 | ||
| 33 | # When complete_at is set, at least that many of the requirements in possibilities must be accessible. This should | ||
| 34 | # only be used for doors with complete_at > 1, as or_logic is more efficient for complete_at == 1. | ||
| 35 | complete_at: int | None | ||
| 36 | possibilities: list["AccessRequirements"] | ||
| 37 | |||
| 33 | def __init__(self): | 38 | def __init__(self): |
| 34 | self.items = set() | 39 | self.items = set() |
| 35 | self.progressives = dict() | 40 | self.progressives = dict() |
| @@ -37,6 +42,20 @@ class AccessRequirements: | |||
| 37 | self.letters = dict() | 42 | self.letters = dict() |
| 38 | self.cyans = False | 43 | self.cyans = False |
| 39 | self.or_logic = list() | 44 | self.or_logic = list() |
| 45 | self.complete_at = None | ||
| 46 | self.possibilities = list() | ||
| 47 | |||
| 48 | def copy(self) -> "AccessRequirements": | ||
| 49 | reqs = AccessRequirements() | ||
| 50 | reqs.items = self.items.copy() | ||
| 51 | reqs.progressives = self.progressives.copy() | ||
| 52 | reqs.rooms = self.rooms.copy() | ||
| 53 | reqs.letters = self.letters.copy() | ||
| 54 | reqs.cyans = self.cyans | ||
| 55 | reqs.or_logic = [[other_req.copy() for other_req in disjunction] for disjunction in self.or_logic] | ||
| 56 | reqs.complete_at = self.complete_at | ||
| 57 | reqs.possibilities = self.possibilities.copy() | ||
| 58 | return reqs | ||
| 40 | 59 | ||
| 41 | def merge(self, other: "AccessRequirements"): | 60 | def merge(self, other: "AccessRequirements"): |
| 42 | for item in other.items: | 61 | for item in other.items: |
| @@ -54,11 +73,99 @@ class AccessRequirements: | |||
| 54 | self.cyans = self.cyans or other.cyans | 73 | self.cyans = self.cyans or other.cyans |
| 55 | 74 | ||
| 56 | for disjunction in other.or_logic: | 75 | for disjunction in other.or_logic: |
| 57 | self.or_logic.append(disjunction) | 76 | self.or_logic.append([sub_req.copy() for sub_req in disjunction]) |
| 77 | |||
| 78 | if other.complete_at is not None: | ||
| 79 | # Merging multiple requirements that use complete_at sucks, and is part of why we want to minimize use of | ||
| 80 | # it. If both requirements use complete_at, we will cheat by using the or_logic field, which supports | ||
| 81 | # conjunctions of requirements. | ||
| 82 | if self.complete_at is not None: | ||
| 83 | print("Merging requirements with complete_at > 1. This is messy and should be avoided!") | ||
| 84 | |||
| 85 | left_req = AccessRequirements() | ||
| 86 | left_req.complete_at = self.complete_at | ||
| 87 | left_req.possibilities = [sub_req.copy() for sub_req in self.possibilities] | ||
| 88 | self.or_logic.append([left_req]) | ||
| 89 | |||
| 90 | self.complete_at = None | ||
| 91 | self.possibilities = list() | ||
| 92 | |||
| 93 | right_req = AccessRequirements() | ||
| 94 | right_req.complete_at = other.complete_at | ||
| 95 | right_req.possibilities = [sub_req.copy() for sub_req in other.possibilities] | ||
| 96 | self.or_logic.append([right_req]) | ||
| 97 | else: | ||
| 98 | self.complete_at = other.complete_at | ||
| 99 | self.possibilities = [sub_req.copy() for sub_req in other.possibilities] | ||
| 58 | 100 | ||
| 59 | def is_empty(self) -> bool: | 101 | def is_empty(self) -> bool: |
| 60 | return (len(self.items) == 0 and len(self.progressives) == 0 and len(self.rooms) == 0 and len(self.letters) == 0 | 102 | return (len(self.items) == 0 and len(self.progressives) == 0 and len(self.rooms) == 0 and len(self.letters) == 0 |
| 61 | and not self.cyans and len(self.or_logic) == 0) | 103 | and not self.cyans and len(self.or_logic) == 0 and self.complete_at is None) |
| 104 | |||
| 105 | def __eq__(self, other: "AccessRequirements"): | ||
| 106 | return (self.items == other.items and self.progressives == other.progressives and self.rooms == other.rooms and | ||
| 107 | self.letters == other.letters and self.cyans == other.cyans and self.or_logic == other.or_logic and | ||
| 108 | self.complete_at == other.complete_at and self.possibilities == other.possibilities) | ||
| 109 | |||
| 110 | def simplify(self): | ||
| 111 | resimplify = False | ||
| 112 | |||
| 113 | if len(self.or_logic) > 0: | ||
| 114 | old_or_logic = self.or_logic | ||
| 115 | |||
| 116 | def remove_redundant(sub_reqs: "AccessRequirements"): | ||
| 117 | new_reqs = sub_reqs.copy() | ||
| 118 | new_reqs.letters = {l: v for l, v in new_reqs.letters.items() if self.letters.get(l, 0) < v} | ||
| 119 | if new_reqs != sub_reqs: | ||
| 120 | return new_reqs | ||
| 121 | else: | ||
| 122 | return sub_reqs | ||
| 123 | |||
| 124 | self.or_logic = [] | ||
| 125 | for disjunction in old_or_logic: | ||
| 126 | new_disjunction = [] | ||
| 127 | for ssr in disjunction: | ||
| 128 | new_ssr = remove_redundant(ssr) | ||
| 129 | if not new_ssr.is_empty(): | ||
| 130 | new_disjunction.append(new_ssr) | ||
| 131 | else: | ||
| 132 | new_disjunction.clear() | ||
| 133 | break | ||
| 134 | if len(new_disjunction) == 1: | ||
| 135 | self.merge(new_disjunction[0]) | ||
| 136 | resimplify = True | ||
| 137 | elif len(new_disjunction) > 1: | ||
| 138 | if all(cjr == new_disjunction[0] for cjr in new_disjunction): | ||
| 139 | self.merge(new_disjunction[0]) | ||
| 140 | resimplify = True | ||
| 141 | else: | ||
| 142 | self.or_logic.append(new_disjunction) | ||
| 143 | |||
| 144 | if resimplify: | ||
| 145 | self.simplify() | ||
| 146 | |||
| 147 | def get_referenced_rooms(self): | ||
| 148 | result = set(self.rooms) | ||
| 149 | |||
| 150 | for disjunction in self.or_logic: | ||
| 151 | for sub_req in disjunction: | ||
| 152 | result = result.union(sub_req.get_referenced_rooms()) | ||
| 153 | |||
| 154 | for sub_req in self.possibilities: | ||
| 155 | result = result.union(sub_req.get_referenced_rooms()) | ||
| 156 | |||
| 157 | return result | ||
| 158 | |||
| 159 | def remove_room(self, room: str): | ||
| 160 | if room in self.rooms: | ||
| 161 | self.rooms.remove(room) | ||
| 162 | |||
| 163 | for disjunction in self.or_logic: | ||
| 164 | for sub_req in disjunction: | ||
| 165 | sub_req.remove_room(room) | ||
| 166 | |||
| 167 | for sub_req in self.possibilities: | ||
| 168 | sub_req.remove_room(room) | ||
| 62 | 169 | ||
| 63 | def __repr__(self): | 170 | def __repr__(self): |
| 64 | parts = [] | 171 | parts = [] |
| @@ -74,7 +181,11 @@ class AccessRequirements: | |||
| 74 | parts.append(f"cyans=True") | 181 | parts.append(f"cyans=True") |
| 75 | if len(self.or_logic) > 0: | 182 | if len(self.or_logic) > 0: |
| 76 | parts.append(f"or_logic={self.or_logic}") | 183 | parts.append(f"or_logic={self.or_logic}") |
| 77 | return f"AccessRequirements({", ".join(parts)})" | 184 | if self.complete_at is not None: |
| 185 | parts.append(f"complete_at={self.complete_at}") | ||
| 186 | if len(self.possibilities) > 0: | ||
| 187 | parts.append(f"possibilities={self.possibilities}") | ||
| 188 | return "AccessRequirements(" + ", ".join(parts) + ")" | ||
| 78 | 189 | ||
| 79 | 190 | ||
| 80 | class PlayerLocation(NamedTuple): | 191 | class PlayerLocation(NamedTuple): |
| @@ -91,6 +202,8 @@ class LetterBehavior(IntEnum): | |||
| 91 | class Lingo2PlayerLogic: | 202 | class Lingo2PlayerLogic: |
| 92 | world: "Lingo2World" | 203 | world: "Lingo2World" |
| 93 | 204 | ||
| 205 | shuffled_maps: set[int] | ||
| 206 | |||
| 94 | locations_by_room: dict[int, list[PlayerLocation]] | 207 | locations_by_room: dict[int, list[PlayerLocation]] |
| 95 | event_loc_item_by_room: dict[int, dict[str, str]] | 208 | event_loc_item_by_room: dict[int, dict[str, str]] |
| 96 | 209 | ||
| @@ -103,6 +216,7 @@ class Lingo2PlayerLogic: | |||
| 103 | real_items: list[str] | 216 | real_items: list[str] |
| 104 | 217 | ||
| 105 | double_letter_amount: dict[str, int] | 218 | double_letter_amount: dict[str, int] |
| 219 | goal_room_id: int | ||
| 106 | 220 | ||
| 107 | def __init__(self, world: "Lingo2World"): | 221 | def __init__(self, world: "Lingo2World"): |
| 108 | self.world = world | 222 | self.world = world |
| @@ -115,18 +229,54 @@ class Lingo2PlayerLogic: | |||
| 115 | self.real_items = list() | 229 | self.real_items = list() |
| 116 | self.double_letter_amount = dict() | 230 | self.double_letter_amount = dict() |
| 117 | 231 | ||
| 232 | def should_shuffle_map(game_map) -> bool: | ||
| 233 | if game_map.type == data_pb2.MapType.NORMAL_MAP: | ||
| 234 | return True | ||
| 235 | elif game_map.type == data_pb2.MapType.ICARUS: | ||
| 236 | return bool(world.options.enable_icarus) | ||
| 237 | elif game_map.type == data_pb2.MapType.GIFT_MAP: | ||
| 238 | if game_map.name == "the_advanced": | ||
| 239 | return "The Advanced" in world.options.enable_gift_maps.value | ||
| 240 | elif game_map.name == "the_charismatic": | ||
| 241 | return "The Charismatic" in world.options.enable_gift_maps.value | ||
| 242 | elif game_map.name == "the_crystalline": | ||
| 243 | return "The Crystalline" in world.options.enable_gift_maps.value | ||
| 244 | elif game_map.name == "the_fuzzy": | ||
| 245 | return "The Fuzzy" in world.options.enable_gift_maps.value | ||
| 246 | elif game_map.name == "the_stellar": | ||
| 247 | return "The Stellar" in world.options.enable_gift_maps.value | ||
| 248 | |||
| 249 | return False | ||
| 250 | |||
| 251 | self.shuffled_maps = set(game_map.id for game_map in world.static_logic.objects.maps | ||
| 252 | if should_shuffle_map(game_map)) | ||
| 253 | |||
| 254 | maximum_masteries = 13 + len(world.options.enable_gift_maps.value) | ||
| 255 | if world.options.enable_icarus: | ||
| 256 | maximum_masteries += 1 | ||
| 257 | |||
| 258 | if world.options.masteries_requirement > maximum_masteries: | ||
| 259 | world.options.masteries_requirement.value = maximum_masteries | ||
| 260 | |||
| 261 | if "The Fuzzy" in world.options.enable_gift_maps.value: | ||
| 262 | self.real_items.append("Numbers") | ||
| 263 | |||
| 118 | if self.world.options.shuffle_doors: | 264 | if self.world.options.shuffle_doors: |
| 119 | for progressive in world.static_logic.objects.progressives: | 265 | for progressive in world.static_logic.objects.progressives: |
| 120 | for i in range(0, len(progressive.doors)): | 266 | for i in range(0, len(progressive.doors)): |
| 267 | door = world.static_logic.objects.doors[progressive.doors[i]] | ||
| 268 | if door.map_id not in self.shuffled_maps: | ||
| 269 | continue | ||
| 270 | |||
| 121 | self.item_by_door[progressive.doors[i]] = (progressive.name, i + 1) | 271 | self.item_by_door[progressive.doors[i]] = (progressive.name, i + 1) |
| 122 | self.real_items.append(progressive.name) | 272 | self.real_items.append(progressive.name) |
| 123 | 273 | ||
| 124 | for door_group in world.static_logic.objects.door_groups: | 274 | for door_group in world.static_logic.objects.door_groups: |
| 125 | if door_group.type == data_pb2.DoorGroupType.CONNECTOR: | 275 | if door_group.type == data_pb2.DoorGroupType.CONNECTOR: |
| 126 | if not self.world.options.shuffle_doors: | 276 | if not self.world.options.shuffle_doors or self.world.options.shuffle_worldports: |
| 127 | continue | 277 | continue |
| 128 | elif door_group.type == data_pb2.DoorGroupType.COLOR_CONNECTOR: | 278 | elif door_group.type == data_pb2.DoorGroupType.COLOR_CONNECTOR: |
| 129 | if not self.world.options.shuffle_control_center_colors: | 279 | if not self.world.options.shuffle_control_center_colors or self.world.options.shuffle_worldports: |
| 130 | continue | 280 | continue |
| 131 | elif door_group.type == data_pb2.DoorGroupType.SHUFFLE_GROUP: | 281 | elif door_group.type == data_pb2.DoorGroupType.SHUFFLE_GROUP: |
| 132 | if not self.world.options.shuffle_doors: | 282 | if not self.world.options.shuffle_doors: |
| @@ -134,14 +284,21 @@ class Lingo2PlayerLogic: | |||
| 134 | else: | 284 | else: |
| 135 | continue | 285 | continue |
| 136 | 286 | ||
| 137 | for door in door_group.doors: | 287 | shuffleable_doors = [door_id for door_id in door_group.doors |
| 138 | self.item_by_door[door] = (door_group.name, 1) | 288 | if world.static_logic.objects.doors[door_id].map_id in self.shuffled_maps] |
| 289 | |||
| 290 | if len(shuffleable_doors) > 0: | ||
| 291 | for door in shuffleable_doors: | ||
| 292 | self.item_by_door[door] = (door_group.name, 1) | ||
| 139 | 293 | ||
| 140 | self.real_items.append(door_group.name) | 294 | self.real_items.append(door_group.name) |
| 141 | 295 | ||
| 142 | # We iterate through the doors in two parts because it is essential that we determine which doors are shuffled | 296 | # We iterate through the doors in two parts because it is essential that we determine which doors are shuffled |
| 143 | # before we calculate any access requirements. | 297 | # before we calculate any access requirements. |
| 144 | for door in world.static_logic.objects.doors: | 298 | for door in world.static_logic.objects.doors: |
| 299 | if door.map_id not in self.shuffled_maps: | ||
| 300 | continue | ||
| 301 | |||
| 145 | if door.type in [data_pb2.DoorType.EVENT, data_pb2.DoorType.LOCATION_ONLY, data_pb2.DoorType.GRAVESTONE]: | 302 | if door.type in [data_pb2.DoorType.EVENT, data_pb2.DoorType.LOCATION_ONLY, data_pb2.DoorType.GRAVESTONE]: |
| 146 | continue | 303 | continue |
| 147 | 304 | ||
| @@ -156,6 +313,9 @@ class Lingo2PlayerLogic: | |||
| 156 | not self.world.options.shuffle_control_center_colors): | 313 | not self.world.options.shuffle_control_center_colors): |
| 157 | continue | 314 | continue |
| 158 | 315 | ||
| 316 | if door.type == data_pb2.DoorType.GALLERY_PAINTING and not self.world.options.shuffle_gallery_paintings: | ||
| 317 | continue | ||
| 318 | |||
| 159 | door_item_name = self.world.static_logic.get_door_item_name(door) | 319 | door_item_name = self.world.static_logic.get_door_item_name(door) |
| 160 | self.item_by_door[door.id] = (door_item_name, 1) | 320 | self.item_by_door[door.id] = (door_item_name, 1) |
| 161 | self.real_items.append(door_item_name) | 321 | self.real_items.append(door_item_name) |
| @@ -167,29 +327,40 @@ class Lingo2PlayerLogic: | |||
| 167 | if door_group.type != data_pb2.DoorGroupType.CYAN_DOORS: | 327 | if door_group.type != data_pb2.DoorGroupType.CYAN_DOORS: |
| 168 | continue | 328 | continue |
| 169 | 329 | ||
| 170 | for door in door_group.doors: | 330 | shuffleable_doors = [door_id for door_id in door_group.doors |
| 171 | if not door in self.item_by_door: | 331 | if world.static_logic.objects.doors[door_id].map_id in self.shuffled_maps |
| 332 | and door_id not in self.item_by_door] | ||
| 333 | |||
| 334 | if len(shuffleable_doors) > 0: | ||
| 335 | for door in shuffleable_doors: | ||
| 172 | self.item_by_door[door] = (door_group.name, 1) | 336 | self.item_by_door[door] = (door_group.name, 1) |
| 173 | 337 | ||
| 174 | self.real_items.append(door_group.name) | 338 | self.real_items.append(door_group.name) |
| 175 | 339 | ||
| 176 | for door in world.static_logic.objects.doors: | 340 | for door in world.static_logic.objects.doors: |
| 341 | if door.map_id not in self.shuffled_maps: | ||
| 342 | continue | ||
| 343 | |||
| 177 | if door.type in [data_pb2.DoorType.STANDARD, data_pb2.DoorType.LOCATION_ONLY, data_pb2.DoorType.GRAVESTONE]: | 344 | if door.type in [data_pb2.DoorType.STANDARD, data_pb2.DoorType.LOCATION_ONLY, data_pb2.DoorType.GRAVESTONE]: |
| 178 | self.locations_by_room.setdefault(door.room_id, []).append(PlayerLocation(door.ap_id, | 345 | self.locations_by_room.setdefault(door.room_id, []).append(PlayerLocation(door.ap_id, |
| 179 | self.get_door_reqs(door.id))) | 346 | self.get_door_reqs(door.id))) |
| 180 | 347 | ||
| 181 | for letter in world.static_logic.objects.letters: | 348 | for letter in world.static_logic.objects.letters: |
| 349 | if world.static_logic.get_room_object_map_id(letter) not in self.shuffled_maps: | ||
| 350 | continue | ||
| 351 | |||
| 182 | self.locations_by_room.setdefault(letter.room_id, []).append(PlayerLocation(letter.ap_id, | 352 | self.locations_by_room.setdefault(letter.room_id, []).append(PlayerLocation(letter.ap_id, |
| 183 | AccessRequirements())) | 353 | AccessRequirements())) |
| 184 | behavior = self.get_letter_behavior(letter.key, letter.level2) | 354 | behavior = self.get_letter_behavior(letter.key, letter.level2) |
| 185 | if behavior == LetterBehavior.VANILLA: | 355 | if behavior == LetterBehavior.VANILLA: |
| 186 | letter_name = f"{letter.key.upper()}{'2' if letter.level2 else '1'}" | 356 | if not world.for_tracker: |
| 187 | event_name = f"{letter_name} (Collected)" | 357 | letter_name = f"{letter.key.upper()}{'2' if letter.level2 else '1'}" |
| 188 | self.event_loc_item_by_room.setdefault(letter.room_id, {})[event_name] = letter.key.upper() | 358 | event_name = f"{letter_name} (Collected)" |
| 189 | |||
| 190 | if letter.level2: | ||
| 191 | event_name = f"{letter_name} (Double Collected)" | ||
| 192 | self.event_loc_item_by_room.setdefault(letter.room_id, {})[event_name] = letter.key.upper() | 359 | self.event_loc_item_by_room.setdefault(letter.room_id, {})[event_name] = letter.key.upper() |
| 360 | |||
| 361 | if letter.level2: | ||
| 362 | event_name = f"{letter_name} (Double Collected)" | ||
| 363 | self.event_loc_item_by_room.setdefault(letter.room_id, {})[event_name] = letter.key.upper() | ||
| 193 | elif behavior == LetterBehavior.ITEM: | 364 | elif behavior == LetterBehavior.ITEM: |
| 194 | self.real_items.append(letter.key.upper()) | 365 | self.real_items.append(letter.key.upper()) |
| 195 | 366 | ||
| @@ -197,30 +368,42 @@ class Lingo2PlayerLogic: | |||
| 197 | self.double_letter_amount[letter.key.upper()] = self.double_letter_amount.get(letter.key.upper(), 0) + 1 | 368 | self.double_letter_amount[letter.key.upper()] = self.double_letter_amount.get(letter.key.upper(), 0) + 1 |
| 198 | 369 | ||
| 199 | for mastery in world.static_logic.objects.masteries: | 370 | for mastery in world.static_logic.objects.masteries: |
| 371 | if world.static_logic.get_room_object_map_id(mastery) not in self.shuffled_maps: | ||
| 372 | continue | ||
| 373 | |||
| 200 | self.locations_by_room.setdefault(mastery.room_id, []).append(PlayerLocation(mastery.ap_id, | 374 | self.locations_by_room.setdefault(mastery.room_id, []).append(PlayerLocation(mastery.ap_id, |
| 201 | AccessRequirements())) | 375 | AccessRequirements())) |
| 202 | 376 | ||
| 377 | if world.options.masteries_requirement > 0: | ||
| 378 | event_name = f"{world.static_logic.get_room_object_map_name(mastery)} - Mastery (Collected)" | ||
| 379 | self.event_loc_item_by_room.setdefault(mastery.room_id, {})[event_name] = "Mastery" | ||
| 380 | |||
| 203 | for ending in world.static_logic.objects.endings: | 381 | for ending in world.static_logic.objects.endings: |
| 204 | # Don't ever create a location for White Ending. Don't even make an event for it if it's not the victory | 382 | if world.static_logic.get_room_object_map_id(ending) not in self.shuffled_maps: |
| 205 | # condition, since it is necessarily going to be in the postgame. | 383 | continue |
| 206 | if ending.name == "WHITE": | 384 | |
| 207 | if self.world.options.victory_condition != VictoryCondition.option_white_ending: | 385 | # Don't create a location for your selected ending. Also don't create a location for White Ending if it's |
| 208 | continue | 386 | # necessarily in the postgame, i.e. it requires all 12 other endings. |
| 209 | else: | 387 | if world.options.victory_condition.current_key.removesuffix("_ending").upper() != ending.name\ |
| 388 | and (ending.name != "WHITE" or world.options.endings_requirement < 12): | ||
| 210 | self.locations_by_room.setdefault(ending.room_id, []).append(PlayerLocation(ending.ap_id, | 389 | self.locations_by_room.setdefault(ending.room_id, []).append(PlayerLocation(ending.ap_id, |
| 211 | AccessRequirements())) | 390 | AccessRequirements())) |
| 212 | 391 | ||
| 213 | event_name = f"{ending.name.capitalize()} Ending (Achieved)" | ||
| 214 | item_name = event_name | ||
| 215 | |||
| 216 | if world.options.victory_condition.current_key.removesuffix("_ending").upper() == ending.name: | 392 | if world.options.victory_condition.current_key.removesuffix("_ending").upper() == ending.name: |
| 217 | item_name = "Victory" | 393 | event_name = f"{ending.name.capitalize()} Ending (Goal)" |
| 394 | self.event_loc_item_by_room.setdefault(ending.room_id, {})[event_name] = "Victory" | ||
| 395 | self.goal_room_id = ending.room_id | ||
| 218 | 396 | ||
| 219 | self.event_loc_item_by_room.setdefault(ending.room_id, {})[event_name] = item_name | 397 | if ending.name != "WHITE": |
| 398 | event_name = f"{ending.name.capitalize()} Ending (Achieved)" | ||
| 399 | self.event_loc_item_by_room.setdefault(ending.room_id, {})[event_name] = "Ending" | ||
| 220 | 400 | ||
| 221 | if self.world.options.keyholder_sanity: | 401 | if self.world.options.keyholder_sanity: |
| 222 | for keyholder in world.static_logic.objects.keyholders: | 402 | for keyholder in world.static_logic.objects.keyholders: |
| 223 | if keyholder.HasField("key"): | 403 | if keyholder.HasField("key"): |
| 404 | if world.static_logic.get_room_object_map_id(keyholder) not in self.shuffled_maps: | ||
| 405 | continue | ||
| 406 | |||
| 224 | reqs = AccessRequirements() | 407 | reqs = AccessRequirements() |
| 225 | 408 | ||
| 226 | if self.get_letter_behavior(keyholder.key, False) != LetterBehavior.UNLOCKED: | 409 | if self.get_letter_behavior(keyholder.key, False) != LetterBehavior.UNLOCKED: |
| @@ -306,7 +489,6 @@ class Lingo2PlayerLogic: | |||
| 306 | door = self.world.static_logic.objects.doors[door_id] | 489 | door = self.world.static_logic.objects.doors[door_id] |
| 307 | reqs = AccessRequirements() | 490 | reqs = AccessRequirements() |
| 308 | 491 | ||
| 309 | # TODO: lavender_cubes, endings | ||
| 310 | if not door.HasField("complete_at") or door.complete_at == 0: | 492 | if not door.HasField("complete_at") or door.complete_at == 0: |
| 311 | for proxy in door.panels: | 493 | for proxy in door.panels: |
| 312 | panel_reqs = self.get_panel_reqs(proxy.panel, proxy.answer if proxy.HasField("answer") else None) | 494 | panel_reqs = self.get_panel_reqs(proxy.panel, proxy.answer if proxy.HasField("answer") else None) |
| @@ -323,11 +505,12 @@ class Lingo2PlayerLogic: | |||
| 323 | if len(disjunction) > 0: | 505 | if len(disjunction) > 0: |
| 324 | reqs.or_logic.append(disjunction) | 506 | reqs.or_logic.append(disjunction) |
| 325 | else: | 507 | else: |
| 326 | # TODO: Handle complete_at > 1 | 508 | reqs.complete_at = door.complete_at |
| 327 | pass | 509 | for proxy in door.panels: |
| 510 | panel_reqs = self.get_panel_reqs(proxy.panel, proxy.answer if proxy.HasField("answer") else None) | ||
| 511 | reqs.possibilities.append(panel_reqs) | ||
| 328 | 512 | ||
| 329 | if door.HasField("control_center_color"): | 513 | if door.HasField("control_center_color"): |
| 330 | # TODO: Logic for ensuring two CC states aren't needed at once. | ||
| 331 | reqs.rooms.add("Control Center - Main Area") | 514 | reqs.rooms.add("Control Center - Main Area") |
| 332 | self.add_solution_reqs(reqs, door.control_center_color) | 515 | self.add_solution_reqs(reqs, door.control_center_color) |
| 333 | 516 | ||
| @@ -353,18 +536,19 @@ class Lingo2PlayerLogic: | |||
| 353 | for room in door.rooms: | 536 | for room in door.rooms: |
| 354 | reqs.rooms.add(self.world.static_logic.get_room_region_name(room)) | 537 | reqs.rooms.add(self.world.static_logic.get_room_region_name(room)) |
| 355 | 538 | ||
| 356 | for ending_id in door.endings: | 539 | if door.white_ending: |
| 357 | ending = self.world.static_logic.objects.endings[ending_id] | 540 | if self.world.options.endings_requirement > 0: |
| 541 | reqs.progressives["Ending"] = self.world.options.endings_requirement.value | ||
| 358 | 542 | ||
| 359 | if self.world.options.victory_condition.current_key.removesuffix("_ending").upper() == ending.name: | 543 | if self.world.options.masteries_requirement > 0: |
| 360 | reqs.items.add("Victory") | 544 | reqs.progressives["Mastery"] = self.world.options.masteries_requirement.value |
| 361 | else: | ||
| 362 | reqs.items.add(f"{ending.name.capitalize()} Ending (Achieved)") | ||
| 363 | 545 | ||
| 364 | for sub_door_id in door.doors: | 546 | for sub_door_id in door.doors: |
| 365 | sub_reqs = self.get_door_open_reqs(sub_door_id) | 547 | sub_reqs = self.get_door_open_reqs(sub_door_id) |
| 366 | reqs.merge(sub_reqs) | 548 | reqs.merge(sub_reqs) |
| 367 | 549 | ||
| 550 | reqs.simplify() | ||
| 551 | |||
| 368 | return reqs | 552 | return reqs |
| 369 | 553 | ||
| 370 | # This gets the requirements to open a door within the world. When a door is shuffled, this means having the item | 554 | # This gets the requirements to open a door within the world. When a door is shuffled, this means having the item |
| @@ -419,3 +603,6 @@ class Lingo2PlayerLogic: | |||
| 419 | 603 | ||
| 420 | if needed > 0: | 604 | if needed > 0: |
| 421 | reqs.letters[l] = max(reqs.letters.get(l, 0), needed) | 605 | reqs.letters[l] = max(reqs.letters.get(l, 0), needed) |
| 606 | |||
| 607 | if any(l.isnumeric() for l in solution): | ||
| 608 | reqs.items.add("Numbers") | ||
