diff options
Diffstat (limited to 'items.py')
| -rw-r--r-- | items.py | 106 |
1 files changed, 106 insertions, 0 deletions
| diff --git a/items.py b/items.py new file mode 100644 index 0000000..af24570 --- /dev/null +++ b/items.py | |||
| @@ -0,0 +1,106 @@ | |||
| 1 | from typing import Dict, List, NamedTuple, Optional, TYPE_CHECKING | ||
| 2 | |||
| 3 | from BaseClasses import Item, ItemClassification | ||
| 4 | from .options import ShuffleDoors | ||
| 5 | from .static_logic import DOORS_BY_ROOM, PROGRESSION_BY_ROOM, PROGRESSIVE_ITEMS, get_door_group_item_id, \ | ||
| 6 | get_door_item_id, get_progressive_item_id, get_special_item_id | ||
| 7 | |||
| 8 | if TYPE_CHECKING: | ||
| 9 | from . import LingoWorld | ||
| 10 | |||
| 11 | |||
| 12 | class ItemData(NamedTuple): | ||
| 13 | """ | ||
| 14 | ItemData for an item in Lingo | ||
| 15 | """ | ||
| 16 | code: int | ||
| 17 | classification: ItemClassification | ||
| 18 | mode: Optional[str] | ||
| 19 | door_ids: List[str] | ||
| 20 | painting_ids: List[str] | ||
| 21 | |||
| 22 | def should_include(self, world: "LingoWorld") -> bool: | ||
| 23 | if self.mode == "colors": | ||
| 24 | return world.options.shuffle_colors > 0 | ||
| 25 | elif self.mode == "doors": | ||
| 26 | return world.options.shuffle_doors != ShuffleDoors.option_none | ||
| 27 | elif self.mode == "orange tower": | ||
| 28 | # door shuffle is on and tower isn't progressive | ||
| 29 | return world.options.shuffle_doors != ShuffleDoors.option_none \ | ||
| 30 | and not world.options.progressive_orange_tower | ||
| 31 | elif self.mode == "complex door": | ||
| 32 | return world.options.shuffle_doors == ShuffleDoors.option_complex | ||
| 33 | elif self.mode == "door group": | ||
| 34 | return world.options.shuffle_doors == ShuffleDoors.option_simple | ||
| 35 | elif self.mode == "special": | ||
| 36 | return False | ||
| 37 | else: | ||
| 38 | return True | ||
| 39 | |||
| 40 | |||
| 41 | class LingoItem(Item): | ||
| 42 | """ | ||
| 43 | Item from the game Lingo | ||
| 44 | """ | ||
| 45 | game: str = "Lingo" | ||
| 46 | |||
| 47 | |||
| 48 | ALL_ITEM_TABLE: Dict[str, ItemData] = {} | ||
| 49 | |||
| 50 | |||
| 51 | def load_item_data(): | ||
| 52 | global ALL_ITEM_TABLE | ||
| 53 | |||
| 54 | for color in ["Black", "Red", "Blue", "Yellow", "Green", "Orange", "Gray", "Brown", "Purple"]: | ||
| 55 | ALL_ITEM_TABLE[color] = ItemData(get_special_item_id(color), ItemClassification.progression, | ||
| 56 | "colors", [], []) | ||
| 57 | |||
| 58 | door_groups: Dict[str, List[str]] = {} | ||
| 59 | for room_name, doors in DOORS_BY_ROOM.items(): | ||
| 60 | for door_name, door in doors.items(): | ||
| 61 | if door.skip_item is True or door.event is True: | ||
| 62 | continue | ||
| 63 | |||
| 64 | if door.group is None: | ||
| 65 | door_mode = "doors" | ||
| 66 | else: | ||
| 67 | door_mode = "complex door" | ||
| 68 | door_groups.setdefault(door.group, []).extend(door.door_ids) | ||
| 69 | |||
| 70 | if room_name in PROGRESSION_BY_ROOM and door_name in PROGRESSION_BY_ROOM[room_name]: | ||
| 71 | if room_name == "Orange Tower": | ||
| 72 | door_mode = "orange tower" | ||
| 73 | else: | ||
| 74 | door_mode = "special" | ||
| 75 | |||
| 76 | ALL_ITEM_TABLE[door.item_name] = \ | ||
| 77 | ItemData(get_door_item_id(room_name, door_name), | ||
| 78 | ItemClassification.filler if door.junk_item else ItemClassification.progression, door_mode, | ||
| 79 | door.door_ids, door.painting_ids) | ||
| 80 | |||
| 81 | for group, group_door_ids in door_groups.items(): | ||
| 82 | ALL_ITEM_TABLE[group] = ItemData(get_door_group_item_id(group), | ||
| 83 | ItemClassification.progression, "door group", group_door_ids, []) | ||
| 84 | |||
| 85 | special_items: Dict[str, ItemClassification] = { | ||
| 86 | ":)": ItemClassification.filler, | ||
| 87 | "The Feeling of Being Lost": ItemClassification.filler, | ||
| 88 | "Wanderlust": ItemClassification.filler, | ||
| 89 | "Empty White Hallways": ItemClassification.filler, | ||
| 90 | "Slowness Trap": ItemClassification.trap, | ||
| 91 | "Iceland Trap": ItemClassification.trap, | ||
| 92 | "Atbash Trap": ItemClassification.trap, | ||
| 93 | "Puzzle Skip": ItemClassification.useful, | ||
| 94 | } | ||
| 95 | |||
| 96 | for item_name, classification in special_items.items(): | ||
| 97 | ALL_ITEM_TABLE[item_name] = ItemData(get_special_item_id(item_name), classification, | ||
| 98 | "special", [], []) | ||
| 99 | |||
| 100 | for item_name in PROGRESSIVE_ITEMS: | ||
| 101 | ALL_ITEM_TABLE[item_name] = ItemData(get_progressive_item_id(item_name), | ||
| 102 | ItemClassification.progression, "special", [], []) | ||
| 103 | |||
| 104 | |||
| 105 | # Initialize the item data at module scope. | ||
| 106 | load_item_data() | ||
