diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2026-01-30 10:50:01 -0500 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2026-01-30 10:50:01 -0500 |
| commit | 9b5c160f60a4e6c679b0c1afca82d9a58523eaab (patch) | |
| tree | 3def18df041138da0a7656efdc99008f8b13ffad /apworld/player_logic.py | |
| parent | e9e4a7a42ca17e7dc1947b012c5f6a50047c159e (diff) | |
| download | lingo2-archipelago-daed-only.tar.gz lingo2-archipelago-daed-only.tar.bz2 lingo2-archipelago-daed-only.zip | |
Worked on daed-only mode daed-only
Diffstat (limited to 'apworld/player_logic.py')
| -rw-r--r-- | apworld/player_logic.py | 60 |
1 files changed, 47 insertions, 13 deletions
| diff --git a/apworld/player_logic.py b/apworld/player_logic.py index 3ee8f38..aea7698 100644 --- a/apworld/player_logic.py +++ b/apworld/player_logic.py | |||
| @@ -203,6 +203,8 @@ class Lingo2PlayerLogic: | |||
| 203 | world: "Lingo2World" | 203 | world: "Lingo2World" |
| 204 | 204 | ||
| 205 | shuffled_maps: set[int] | 205 | shuffled_maps: set[int] |
| 206 | shuffled_rooms: set[int] | ||
| 207 | shuffled_doors: set[int] | ||
| 206 | 208 | ||
| 207 | locations_by_room: dict[int, list[PlayerLocation]] | 209 | locations_by_room: dict[int, list[PlayerLocation]] |
| 208 | event_loc_item_by_room: dict[int, dict[str, str]] | 210 | event_loc_item_by_room: dict[int, dict[str, str]] |
| @@ -220,6 +222,8 @@ class Lingo2PlayerLogic: | |||
| 220 | 222 | ||
| 221 | def __init__(self, world: "Lingo2World"): | 223 | def __init__(self, world: "Lingo2World"): |
| 222 | self.world = world | 224 | self.world = world |
| 225 | self.shuffled_rooms = set() | ||
| 226 | self.shuffled_doors = set() | ||
| 223 | self.locations_by_room = {} | 227 | self.locations_by_room = {} |
| 224 | self.event_loc_item_by_room = {} | 228 | self.event_loc_item_by_room = {} |
| 225 | self.item_by_door = {} | 229 | self.item_by_door = {} |
| @@ -229,7 +233,10 @@ class Lingo2PlayerLogic: | |||
| 229 | self.real_items = list() | 233 | self.real_items = list() |
| 230 | self.double_letter_amount = dict() | 234 | self.double_letter_amount = dict() |
| 231 | 235 | ||
| 232 | def should_shuffle_map(game_map) -> bool: | 236 | def should_shuffle_map(game_map) -> bool | set[int]: |
| 237 | if world.options.daedalus_only: | ||
| 238 | return game_map.daedalus_only_mode == data_pb2.DaedalusOnlyMode.DAED_ONLY_ALLOW | ||
| 239 | |||
| 233 | if game_map.type == data_pb2.MapType.NORMAL_MAP: | 240 | if game_map.type == data_pb2.MapType.NORMAL_MAP: |
| 234 | return True | 241 | return True |
| 235 | elif game_map.type == data_pb2.MapType.ICARUS: | 242 | elif game_map.type == data_pb2.MapType.ICARUS: |
| @@ -251,6 +258,14 @@ class Lingo2PlayerLogic: | |||
| 251 | self.shuffled_maps = set(game_map.id for game_map in world.static_logic.objects.maps | 258 | self.shuffled_maps = set(game_map.id for game_map in world.static_logic.objects.maps |
| 252 | if should_shuffle_map(game_map)) | 259 | if should_shuffle_map(game_map)) |
| 253 | 260 | ||
| 261 | if world.options.daedalus_only: | ||
| 262 | for game_map in world.static_logic.objects.maps: | ||
| 263 | if game_map.daedalus_only_mode == data_pb2.DaedalusOnlyMode.DAED_ONLY_PARTIAL: | ||
| 264 | self.shuffled_rooms.update(set(room.id for room in world.static_logic.objects.rooms | ||
| 265 | if room.map_id == game_map.id and room.daedalus_only_allow)) | ||
| 266 | self.shuffled_doors.update(set(door.id for door in world.static_logic.objects.doors | ||
| 267 | if door.map_id == game_map.id and door.daedalus_only_allow)) | ||
| 268 | |||
| 254 | maximum_masteries = 13 + len(world.options.enable_gift_maps.value) | 269 | maximum_masteries = 13 + len(world.options.enable_gift_maps.value) |
| 255 | if world.options.enable_icarus: | 270 | if world.options.enable_icarus: |
| 256 | maximum_masteries += 1 | 271 | maximum_masteries += 1 |
| @@ -265,7 +280,7 @@ class Lingo2PlayerLogic: | |||
| 265 | for progressive in world.static_logic.objects.progressives: | 280 | for progressive in world.static_logic.objects.progressives: |
| 266 | for i in range(0, len(progressive.doors)): | 281 | for i in range(0, len(progressive.doors)): |
| 267 | door = world.static_logic.objects.doors[progressive.doors[i]] | 282 | door = world.static_logic.objects.doors[progressive.doors[i]] |
| 268 | if door.map_id not in self.shuffled_maps: | 283 | if not self.should_shuffle_door(door.id): |
| 269 | continue | 284 | continue |
| 270 | 285 | ||
| 271 | self.item_by_door[progressive.doors[i]] = (progressive.name, i + 1) | 286 | self.item_by_door[progressive.doors[i]] = (progressive.name, i + 1) |
| @@ -279,13 +294,15 @@ class Lingo2PlayerLogic: | |||
| 279 | if not self.world.options.shuffle_control_center_colors or self.world.options.shuffle_worldports: | 294 | if not self.world.options.shuffle_control_center_colors or self.world.options.shuffle_worldports: |
| 280 | continue | 295 | continue |
| 281 | elif door_group.type == data_pb2.DoorGroupType.SHUFFLE_GROUP: | 296 | elif door_group.type == data_pb2.DoorGroupType.SHUFFLE_GROUP: |
| 282 | if not self.world.options.shuffle_doors: | 297 | if door_group.name == "Lavender Cubes" and self.world.options.daedalus_only: |
| 298 | # Always shuffle this if we're in Daed-only mode. | ||
| 299 | pass | ||
| 300 | elif not self.world.options.shuffle_doors: | ||
| 283 | continue | 301 | continue |
| 284 | else: | 302 | else: |
| 285 | continue | 303 | continue |
| 286 | 304 | ||
| 287 | shuffleable_doors = [door_id for door_id in door_group.doors | 305 | shuffleable_doors = [door_id for door_id in door_group.doors if self.should_shuffle_door(door_id)] |
| 288 | if world.static_logic.objects.doors[door_id].map_id in self.shuffled_maps] | ||
| 289 | 306 | ||
| 290 | if len(shuffleable_doors) > 0: | 307 | if len(shuffleable_doors) > 0: |
| 291 | for door in shuffleable_doors: | 308 | for door in shuffleable_doors: |
| @@ -296,7 +313,7 @@ class Lingo2PlayerLogic: | |||
| 296 | # We iterate through the doors in two parts because it is essential that we determine which doors are shuffled | 313 | # We iterate through the doors in two parts because it is essential that we determine which doors are shuffled |
| 297 | # before we calculate any access requirements. | 314 | # before we calculate any access requirements. |
| 298 | for door in world.static_logic.objects.doors: | 315 | for door in world.static_logic.objects.doors: |
| 299 | if door.map_id not in self.shuffled_maps: | 316 | if not self.should_shuffle_door(door.id): |
| 300 | continue | 317 | continue |
| 301 | 318 | ||
| 302 | if door.type in [data_pb2.DoorType.EVENT, data_pb2.DoorType.LOCATION_ONLY, data_pb2.DoorType.GRAVESTONE]: | 319 | if door.type in [data_pb2.DoorType.EVENT, data_pb2.DoorType.LOCATION_ONLY, data_pb2.DoorType.GRAVESTONE]: |
| @@ -328,8 +345,7 @@ class Lingo2PlayerLogic: | |||
| 328 | continue | 345 | continue |
| 329 | 346 | ||
| 330 | shuffleable_doors = [door_id for door_id in door_group.doors | 347 | shuffleable_doors = [door_id for door_id in door_group.doors |
| 331 | if world.static_logic.objects.doors[door_id].map_id in self.shuffled_maps | 348 | if self.should_shuffle_door(door_id) and door_id not in self.item_by_door] |
| 332 | and door_id not in self.item_by_door] | ||
| 333 | 349 | ||
| 334 | if len(shuffleable_doors) > 0: | 350 | if len(shuffleable_doors) > 0: |
| 335 | for door in shuffleable_doors: | 351 | for door in shuffleable_doors: |
| @@ -338,7 +354,7 @@ class Lingo2PlayerLogic: | |||
| 338 | self.real_items.append(door_group.name) | 354 | self.real_items.append(door_group.name) |
| 339 | 355 | ||
| 340 | for door in world.static_logic.objects.doors: | 356 | for door in world.static_logic.objects.doors: |
| 341 | if door.map_id not in self.shuffled_maps: | 357 | if not self.should_shuffle_door(door.id): |
| 342 | continue | 358 | continue |
| 343 | 359 | ||
| 344 | if door.type in [data_pb2.DoorType.STANDARD, data_pb2.DoorType.LOCATION_ONLY, data_pb2.DoorType.GRAVESTONE]: | 360 | if door.type in [data_pb2.DoorType.STANDARD, data_pb2.DoorType.LOCATION_ONLY, data_pb2.DoorType.GRAVESTONE]: |
| @@ -346,7 +362,7 @@ class Lingo2PlayerLogic: | |||
| 346 | self.get_door_reqs(door.id))) | 362 | self.get_door_reqs(door.id))) |
| 347 | 363 | ||
| 348 | for letter in world.static_logic.objects.letters: | 364 | for letter in world.static_logic.objects.letters: |
| 349 | if world.static_logic.get_room_object_map_id(letter) not in self.shuffled_maps: | 365 | if not self.should_shuffle_room(letter.room_id): |
| 350 | continue | 366 | continue |
| 351 | 367 | ||
| 352 | self.locations_by_room.setdefault(letter.room_id, []).append(PlayerLocation(letter.ap_id, | 368 | self.locations_by_room.setdefault(letter.room_id, []).append(PlayerLocation(letter.ap_id, |
| @@ -368,7 +384,7 @@ class Lingo2PlayerLogic: | |||
| 368 | self.double_letter_amount[letter.key.upper()] = self.double_letter_amount.get(letter.key.upper(), 0) + 1 | 384 | self.double_letter_amount[letter.key.upper()] = self.double_letter_amount.get(letter.key.upper(), 0) + 1 |
| 369 | 385 | ||
| 370 | for mastery in world.static_logic.objects.masteries: | 386 | for mastery in world.static_logic.objects.masteries: |
| 371 | if world.static_logic.get_room_object_map_id(mastery) not in self.shuffled_maps: | 387 | if not self.should_shuffle_room(mastery.room_id): |
| 372 | continue | 388 | continue |
| 373 | 389 | ||
| 374 | self.locations_by_room.setdefault(mastery.room_id, []).append(PlayerLocation(mastery.ap_id, | 390 | self.locations_by_room.setdefault(mastery.room_id, []).append(PlayerLocation(mastery.ap_id, |
| @@ -379,7 +395,7 @@ class Lingo2PlayerLogic: | |||
| 379 | self.event_loc_item_by_room.setdefault(mastery.room_id, {})[event_name] = "Mastery" | 395 | self.event_loc_item_by_room.setdefault(mastery.room_id, {})[event_name] = "Mastery" |
| 380 | 396 | ||
| 381 | for ending in world.static_logic.objects.endings: | 397 | for ending in world.static_logic.objects.endings: |
| 382 | if world.static_logic.get_room_object_map_id(ending) not in self.shuffled_maps: | 398 | if not self.should_shuffle_room(ending.room_id): |
| 383 | continue | 399 | continue |
| 384 | 400 | ||
| 385 | # Don't create a location for your selected ending. Also don't create a location for White Ending if it's | 401 | # Don't create a location for your selected ending. Also don't create a location for White Ending if it's |
| @@ -401,7 +417,7 @@ class Lingo2PlayerLogic: | |||
| 401 | if self.world.options.keyholder_sanity: | 417 | if self.world.options.keyholder_sanity: |
| 402 | for keyholder in world.static_logic.objects.keyholders: | 418 | for keyholder in world.static_logic.objects.keyholders: |
| 403 | if keyholder.HasField("key"): | 419 | if keyholder.HasField("key"): |
| 404 | if world.static_logic.get_room_object_map_id(keyholder) not in self.shuffled_maps: | 420 | if not self.should_shuffle_room(keyholder.room_id): |
| 405 | continue | 421 | continue |
| 406 | 422 | ||
| 407 | reqs = AccessRequirements() | 423 | reqs = AccessRequirements() |
| @@ -606,3 +622,21 @@ class Lingo2PlayerLogic: | |||
| 606 | 622 | ||
| 607 | if any(l.isnumeric() for l in solution): | 623 | if any(l.isnumeric() for l in solution): |
| 608 | reqs.items.add("Numbers") | 624 | reqs.items.add("Numbers") |
| 625 | |||
| 626 | def should_shuffle_room(self, room_id: int) -> bool: | ||
| 627 | if room_id in self.shuffled_rooms: | ||
| 628 | return True | ||
| 629 | |||
| 630 | room = self.world.static_logic.objects.rooms[room_id] | ||
| 631 | game_map = self.world.static_logic.objects.maps[room.map_id] | ||
| 632 | |||
| 633 | return game_map.id in self.shuffled_maps | ||
| 634 | |||
| 635 | def should_shuffle_door(self, door_id: int) -> bool: | ||
| 636 | if door_id in self.shuffled_doors: | ||
| 637 | return True | ||
| 638 | |||
| 639 | door = self.world.static_logic.objects.doors[door_id] | ||
| 640 | game_map = self.world.static_logic.objects.maps[door.map_id] | ||
| 641 | |||
| 642 | return game_map.id in self.shuffled_maps | ||
