Skip to content

Commit

Permalink
Lingo: Fix non-progressive The Colorful (ArchipelagoMW#2782)
Browse files Browse the repository at this point in the history
The Colorful did not actually properly split into individual doors when progressive colorful was off. This change refactors the code that handles special cases with progressive items to make things clearer (which is important because I will be introducing another one).
  • Loading branch information
hatkirby authored and TheLX5 committed Mar 2, 2024
1 parent d68a5ab commit 4bdcc0f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
15 changes: 1 addition & 14 deletions worlds/lingo/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ def should_include(self, world: "LingoWorld") -> bool:
return world.options.shuffle_colors > 0
elif self.mode == "doors":
return world.options.shuffle_doors != ShuffleDoors.option_none
elif self.mode == "orange tower":
# door shuffle is on and tower isn't progressive
return world.options.shuffle_doors != ShuffleDoors.option_none \
and not world.options.progressive_orange_tower
elif self.mode == "the colorful":
# complex door shuffle is on and colorful isn't progressive
return world.options.shuffle_doors == ShuffleDoors.option_complex \
and not world.options.progressive_colorful
elif self.mode == "complex door":
return world.options.shuffle_doors == ShuffleDoors.option_complex
elif self.mode == "door group":
Expand Down Expand Up @@ -72,12 +64,7 @@ def load_item_data():
door_groups.setdefault(door.group, []).extend(door.door_ids)

if room_name in PROGRESSION_BY_ROOM and door_name in PROGRESSION_BY_ROOM[room_name]:
if room_name == "Orange Tower":
door_mode = "orange tower"
elif room_name == "The Colorful":
door_mode = "the colorful"
else:
door_mode = "special"
door_mode = "special"

ALL_ITEM_TABLE[door.item_name] = \
ItemData(get_door_item_id(room_name, door_name),
Expand Down
31 changes: 28 additions & 3 deletions worlds/lingo/player_logic.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from enum import Enum
from typing import Dict, List, NamedTuple, Optional, Set, Tuple, TYPE_CHECKING

from .items import ALL_ITEM_TABLE
Expand Down Expand Up @@ -36,6 +37,27 @@ class PlayerLocation(NamedTuple):
access: AccessRequirements


class ProgressiveItemBehavior(Enum):
DISABLE = 1
SPLIT = 2
PROGRESSIVE = 3


def should_split_progression(progression_name: str, world: "LingoWorld") -> ProgressiveItemBehavior:
if progression_name == "Progressive Orange Tower":
if world.options.progressive_orange_tower:
return ProgressiveItemBehavior.PROGRESSIVE
else:
return ProgressiveItemBehavior.SPLIT
elif progression_name == "Progressive Colorful":
if world.options.progressive_colorful:
return ProgressiveItemBehavior.PROGRESSIVE
else:
return ProgressiveItemBehavior.SPLIT

return ProgressiveItemBehavior.PROGRESSIVE


class LingoPlayerLogic:
"""
Defines logic after a player's options have been applied
Expand Down Expand Up @@ -83,10 +105,13 @@ def set_door_item(self, room: str, door: str, item: str):

def handle_non_grouped_door(self, room_name: str, door_data: Door, world: "LingoWorld"):
if room_name in PROGRESSION_BY_ROOM and door_data.name in PROGRESSION_BY_ROOM[room_name]:
if (room_name == "Orange Tower" and not world.options.progressive_orange_tower)\
or (room_name == "The Colorful" and not world.options.progressive_colorful):
progression_name = PROGRESSION_BY_ROOM[room_name][door_data.name].item_name
progression_handling = should_split_progression(progression_name, world)

if progression_handling == ProgressiveItemBehavior.SPLIT:
self.set_door_item(room_name, door_data.name, door_data.item_name)
else:
self.real_items.append(door_data.item_name)
elif progression_handling == ProgressiveItemBehavior.PROGRESSIVE:
progressive_item_name = PROGRESSION_BY_ROOM[room_name][door_data.name].item_name
self.set_door_item(room_name, door_data.name, progressive_item_name)
self.real_items.append(progressive_item_name)
Expand Down

0 comments on commit 4bdcc0f

Please sign in to comment.