diff options
Diffstat (limited to 'apworld/static_logic.py')
| -rw-r--r-- | apworld/static_logic.py | 23 |
1 files changed, 22 insertions, 1 deletions
| diff --git a/apworld/static_logic.py b/apworld/static_logic.py index 6c38f1f..d3ed85c 100644 --- a/apworld/static_logic.py +++ b/apworld/static_logic.py | |||
| @@ -1,9 +1,30 @@ | |||
| 1 | from .generated import common_pb2 as common_pb2 | ||
| 1 | from .generated import data_pb2 as data_pb2 | 2 | from .generated import data_pb2 as data_pb2 |
| 2 | import pkgutil | 3 | import pkgutil |
| 3 | 4 | ||
| 4 | class Lingo2StaticLogic: | 5 | class Lingo2StaticLogic: |
| 6 | item_id_to_name: dict[int, str] | ||
| 7 | location_id_to_name: dict[int, str] | ||
| 8 | |||
| 9 | item_name_to_id: dict[str, int] | ||
| 10 | location_name_to_id: dict[str, int] | ||
| 11 | |||
| 5 | def __init__(self): | 12 | def __init__(self): |
| 6 | file = pkgutil.get_data(__name__, "generated/data.binpb") | 13 | self.item_id_to_name = {} |
| 14 | self.location_id_to_name = {} | ||
| 7 | 15 | ||
| 16 | file = pkgutil.get_data(__name__, "generated/data.binpb") | ||
| 8 | self.objects = data_pb2.AllObjects() | 17 | self.objects = data_pb2.AllObjects() |
| 9 | self.objects.ParseFromString(bytearray(file)) | 18 | self.objects.ParseFromString(bytearray(file)) |
| 19 | |||
| 20 | for door in self.objects.doors: | ||
| 21 | if door.type == common_pb2.DoorType.STANDARD: | ||
| 22 | location_name = f"{self.objects.rooms[door.room_id].display_name} - {door.name}" | ||
| 23 | self.location_id_to_name[door.ap_id] = location_name | ||
| 24 | |||
| 25 | if door.type != common_pb2.DoorType.EVENT: | ||
| 26 | item_name = f"{self.objects.rooms[door.room_id].display_name} - {door.name}" | ||
| 27 | self.item_id_to_name[door.ap_id] = item_name | ||
| 28 | |||
| 29 | self.item_name_to_id = {name: ap_id for ap_id, name in self.item_id_to_name.items()} | ||
| 30 | self.location_name_to_id = {name: ap_id for ap_id, name in self.location_id_to_name.items()} | ||
