about summary refs log tree commit diff stats
path: root/apworld/static_logic.py
diff options
context:
space:
mode:
Diffstat (limited to 'apworld/static_logic.py')
-rw-r--r--apworld/static_logic.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/apworld/static_logic.py b/apworld/static_logic.py index 07800f8..e4d7d49 100644 --- a/apworld/static_logic.py +++ b/apworld/static_logic.py
@@ -1,5 +1,5 @@
1from .generated import data_pb2 as data_pb2 1from .generated import data_pb2 as data_pb2
2from .items import SYMBOL_ITEMS 2from .items import SYMBOL_ITEMS, ANTI_COLLECTABLE_TRAPS
3import pkgutil 3import pkgutil
4 4
5class Lingo2StaticLogic: 5class Lingo2StaticLogic:
@@ -12,11 +12,14 @@ class Lingo2StaticLogic:
12 item_name_groups: dict[str, list[str]] 12 item_name_groups: dict[str, list[str]]
13 location_name_groups: dict[str, list[str]] 13 location_name_groups: dict[str, list[str]]
14 14
15 letter_weights: dict[str, int]
16
15 def __init__(self): 17 def __init__(self):
16 self.item_id_to_name = {} 18 self.item_id_to_name = {}
17 self.location_id_to_name = {} 19 self.location_id_to_name = {}
18 self.item_name_groups = {} 20 self.item_name_groups = {}
19 self.location_name_groups = {} 21 self.location_name_groups = {}
22 self.letter_weights = {}
20 23
21 file = pkgutil.get_data(__name__, "generated/data.binpb") 24 file = pkgutil.get_data(__name__, "generated/data.binpb")
22 self.objects = data_pb2.AllObjects() 25 self.objects = data_pb2.AllObjects()
@@ -68,9 +71,16 @@ class Lingo2StaticLogic:
68 for symbol_name in SYMBOL_ITEMS.values(): 71 for symbol_name in SYMBOL_ITEMS.values():
69 self.item_id_to_name[self.objects.special_ids[symbol_name]] = symbol_name 72 self.item_id_to_name[self.objects.special_ids[symbol_name]] = symbol_name
70 73
74 for trap_name in ANTI_COLLECTABLE_TRAPS:
75 self.item_id_to_name[self.objects.special_ids[trap_name]] = trap_name
76
71 self.item_name_to_id = {name: ap_id for ap_id, name in self.item_id_to_name.items()} 77 self.item_name_to_id = {name: ap_id for ap_id, name in self.item_id_to_name.items()}
72 self.location_name_to_id = {name: ap_id for ap_id, name in self.location_id_to_name.items()} 78 self.location_name_to_id = {name: ap_id for ap_id, name in self.location_id_to_name.items()}
73 79
80 for panel in self.objects.panels:
81 for letter in panel.answer.upper():
82 self.letter_weights[letter] = self.letter_weights.get(letter, 0) + 1
83
74 def get_door_item_name(self, door: data_pb2.Door) -> str: 84 def get_door_item_name(self, door: data_pb2.Door) -> str:
75 return f"{self.get_map_object_map_name(door)} - {door.name}" 85 return f"{self.get_map_object_map_name(door)} - {door.name}"
76 86
@@ -94,7 +104,7 @@ class Lingo2StaticLogic:
94 if door.type != data_pb2.DoorType.STANDARD: 104 if door.type != data_pb2.DoorType.STANDARD:
95 return None 105 return None
96 106
97 if len(door.keyholders) > 0 or len(door.endings) > 0: 107 if len(door.keyholders) > 0 or len(door.endings) > 0 or door.HasField("complete_at"):
98 return None 108 return None
99 109
100 if len(door.panels) > 4: 110 if len(door.panels) > 4:
@@ -130,7 +140,7 @@ class Lingo2StaticLogic:
130 for panel_id in door.panels] 140 for panel_id in door.panels]
131 panel_names.sort() 141 panel_names.sort()
132 142
133 return f"{map_part} - {", ".join(panel_names)}" 143 return map_part + " - " + ", ".join(panel_names)
134 144
135 def get_door_location_name_by_id(self, door_id: int) -> str: 145 def get_door_location_name_by_id(self, door_id: int) -> str:
136 door = self.objects.doors[door_id] 146 door = self.objects.doors[door_id]