summary refs log tree commit diff stats
path: root/items.py
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2024-03-15 04:26:00 -0400
committerGitHub <noreply@github.com>2024-03-15 09:26:00 +0100
commite016228d2b76fa367889c9d98d6eb9e783f98cb4 (patch)
tree5c4fd5427ee1c89a832b3327eef6d39d4ce82d82 /items.py
parentfcb3b36f44a7d475aa49c5c44971a2b7cabc4ca8 (diff)
downloadlingo-apworld-e016228d2b76fa367889c9d98d6eb9e783f98cb4.tar.gz
lingo-apworld-e016228d2b76fa367889c9d98d6eb9e783f98cb4.tar.bz2
lingo-apworld-e016228d2b76fa367889c9d98d6eb9e783f98cb4.zip
Lingo: Pre-compile datafile to improve loading time (#2829)
Diffstat (limited to 'items.py')
-rw-r--r--items.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/items.py b/items.py index 9f8bf56..623cd79 100644 --- a/items.py +++ b/items.py
@@ -16,7 +16,7 @@ class ItemData(NamedTuple):
16 code: int 16 code: int
17 classification: ItemClassification 17 classification: ItemClassification
18 mode: Optional[str] 18 mode: Optional[str]
19 door_ids: List[str] 19 has_doors: bool
20 painting_ids: List[str] 20 painting_ids: List[str]
21 21
22 def should_include(self, world: "LingoWorld") -> bool: 22 def should_include(self, world: "LingoWorld") -> bool:
@@ -61,7 +61,7 @@ def load_item_data():
61 door_mode = "doors" 61 door_mode = "doors"
62 else: 62 else:
63 door_mode = "complex door" 63 door_mode = "complex door"
64 door_groups.setdefault(door.group, []).extend(door.door_ids) 64 door_groups.setdefault(door.group, [])
65 65
66 if room_name in PROGRESSION_BY_ROOM and door_name in PROGRESSION_BY_ROOM[room_name]: 66 if room_name in PROGRESSION_BY_ROOM and door_name in PROGRESSION_BY_ROOM[room_name]:
67 door_mode = "special" 67 door_mode = "special"
@@ -69,11 +69,11 @@ def load_item_data():
69 ALL_ITEM_TABLE[door.item_name] = \ 69 ALL_ITEM_TABLE[door.item_name] = \
70 ItemData(get_door_item_id(room_name, door_name), 70 ItemData(get_door_item_id(room_name, door_name),
71 ItemClassification.filler if door.junk_item else ItemClassification.progression, door_mode, 71 ItemClassification.filler if door.junk_item else ItemClassification.progression, door_mode,
72 door.door_ids, door.painting_ids) 72 door.has_doors, door.painting_ids)
73 73
74 for group, group_door_ids in door_groups.items(): 74 for group, group_door_ids in door_groups.items():
75 ALL_ITEM_TABLE[group] = ItemData(get_door_group_item_id(group), 75 ALL_ITEM_TABLE[group] = ItemData(get_door_group_item_id(group),
76 ItemClassification.progression, "door group", group_door_ids, []) 76 ItemClassification.progression, "door group", True, [])
77 77
78 special_items: Dict[str, ItemClassification] = { 78 special_items: Dict[str, ItemClassification] = {
79 ":)": ItemClassification.filler, 79 ":)": ItemClassification.filler,
@@ -88,11 +88,11 @@ def load_item_data():
88 88
89 for item_name, classification in special_items.items(): 89 for item_name, classification in special_items.items():
90 ALL_ITEM_TABLE[item_name] = ItemData(get_special_item_id(item_name), classification, 90 ALL_ITEM_TABLE[item_name] = ItemData(get_special_item_id(item_name), classification,
91 "special", [], []) 91 "special", False, [])
92 92
93 for item_name in PROGRESSIVE_ITEMS: 93 for item_name in PROGRESSIVE_ITEMS:
94 ALL_ITEM_TABLE[item_name] = ItemData(get_progressive_item_id(item_name), 94 ALL_ITEM_TABLE[item_name] = ItemData(get_progressive_item_id(item_name),
95 ItemClassification.progression, "special", [], []) 95 ItemClassification.progression, "special", False, [])
96 96
97 97
98# Initialize the item data at module scope. 98# Initialize the item data at module scope.