diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-02-15 18:19:54 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-16 00:19:54 +0100 |
commit | 3a8ba8f4f16ac0d62b9ca4f9ff531eefd58004e4 (patch) | |
tree | 257584d018a5c3481ab085ba46537bc49db84631 /player_logic.py | |
parent | e21b6acc910fb4993395204c8c0fe4ec2cbea16c (diff) | |
download | lingo-apworld-3a8ba8f4f16ac0d62b9ca4f9ff531eefd58004e4.tar.gz lingo-apworld-3a8ba8f4f16ac0d62b9ca4f9ff531eefd58004e4.tar.bz2 lingo-apworld-3a8ba8f4f16ac0d62b9ca4f9ff531eefd58004e4.zip |
Lingo: Fix non-progressive The Colorful (#2782)
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).
Diffstat (limited to 'player_logic.py')
-rw-r--r-- | player_logic.py | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/player_logic.py b/player_logic.py index b2e5f77..0ae3035 100644 --- a/player_logic.py +++ b/player_logic.py | |||
@@ -1,3 +1,4 @@ | |||
1 | from enum import Enum | ||
1 | from typing import Dict, List, NamedTuple, Optional, Set, Tuple, TYPE_CHECKING | 2 | from typing import Dict, List, NamedTuple, Optional, Set, Tuple, TYPE_CHECKING |
2 | 3 | ||
3 | from .items import ALL_ITEM_TABLE | 4 | from .items import ALL_ITEM_TABLE |
@@ -36,6 +37,27 @@ class PlayerLocation(NamedTuple): | |||
36 | access: AccessRequirements | 37 | access: AccessRequirements |
37 | 38 | ||
38 | 39 | ||
40 | class ProgressiveItemBehavior(Enum): | ||
41 | DISABLE = 1 | ||
42 | SPLIT = 2 | ||
43 | PROGRESSIVE = 3 | ||
44 | |||
45 | |||
46 | def should_split_progression(progression_name: str, world: "LingoWorld") -> ProgressiveItemBehavior: | ||
47 | if progression_name == "Progressive Orange Tower": | ||
48 | if world.options.progressive_orange_tower: | ||
49 | return ProgressiveItemBehavior.PROGRESSIVE | ||
50 | else: | ||
51 | return ProgressiveItemBehavior.SPLIT | ||
52 | elif progression_name == "Progressive Colorful": | ||
53 | if world.options.progressive_colorful: | ||
54 | return ProgressiveItemBehavior.PROGRESSIVE | ||
55 | else: | ||
56 | return ProgressiveItemBehavior.SPLIT | ||
57 | |||
58 | return ProgressiveItemBehavior.PROGRESSIVE | ||
59 | |||
60 | |||
39 | class LingoPlayerLogic: | 61 | class LingoPlayerLogic: |
40 | """ | 62 | """ |
41 | Defines logic after a player's options have been applied | 63 | Defines logic after a player's options have been applied |
@@ -83,10 +105,13 @@ class LingoPlayerLogic: | |||
83 | 105 | ||
84 | def handle_non_grouped_door(self, room_name: str, door_data: Door, world: "LingoWorld"): | 106 | def handle_non_grouped_door(self, room_name: str, door_data: Door, world: "LingoWorld"): |
85 | if room_name in PROGRESSION_BY_ROOM and door_data.name in PROGRESSION_BY_ROOM[room_name]: | 107 | if room_name in PROGRESSION_BY_ROOM and door_data.name in PROGRESSION_BY_ROOM[room_name]: |
86 | if (room_name == "Orange Tower" and not world.options.progressive_orange_tower)\ | 108 | progression_name = PROGRESSION_BY_ROOM[room_name][door_data.name].item_name |
87 | or (room_name == "The Colorful" and not world.options.progressive_colorful): | 109 | progression_handling = should_split_progression(progression_name, world) |
110 | |||
111 | if progression_handling == ProgressiveItemBehavior.SPLIT: | ||
88 | self.set_door_item(room_name, door_data.name, door_data.item_name) | 112 | self.set_door_item(room_name, door_data.name, door_data.item_name) |
89 | else: | 113 | self.real_items.append(door_data.item_name) |
114 | elif progression_handling == ProgressiveItemBehavior.PROGRESSIVE: | ||
90 | progressive_item_name = PROGRESSION_BY_ROOM[room_name][door_data.name].item_name | 115 | progressive_item_name = PROGRESSION_BY_ROOM[room_name][door_data.name].item_name |
91 | self.set_door_item(room_name, door_data.name, progressive_item_name) | 116 | self.set_door_item(room_name, door_data.name, progressive_item_name) |
92 | self.real_items.append(progressive_item_name) | 117 | self.real_items.append(progressive_item_name) |