summary refs log tree commit diff stats
path: root/locations.py
blob: c527e522fb0689b0c288a7953cf280222cffbce4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
from enum import Flag, auto
from typing import Dict, List, NamedTuple

from BaseClasses import Location
from .datatypes import RoomAndPanel
from .static_logic import DOORS_BY_ROOM, PANELS_BY_ROOM, get_door_location_id, get_panel_location_id


class LocationClassification(Flag):
    normal = auto()
    reduced = auto()
    insanity = auto()
    small_sphere_one = auto()


class LocationData(NamedTuple):
    """
    LocationData for a location in Lingo
    """
    code: int
    room: str
    panels: List[RoomAndPanel]
    classification: LocationClassification


class LingoLocation(Location):
    """
    Location from the game Lingo
    """
    game: str = "Lingo"


ALL_LOCATION_TABLE: Dict[str, LocationData] = {}
LOCATIONS_BY_GROUP: Dict[str, List[str]] = {}


def load_location_data():
    global ALL_LOCATION_TABLE, LOCATIONS_BY_GROUP

    for room_name, panels in PANELS_BY_ROOM.items():
        for panel_name, panel in panels.items():
            location_name = f"{room_name} - {panel_name}" if panel.location_name is None else panel.location_name

            classification = LocationClassification.insanity
            if panel.check:
                classification |= LocationClassification.normal

                if not panel.exclude_reduce:
                    classification |= LocationClassification.reduced

            if room_name == "Starting Room":
                classification |= LocationClassification.small_sphere_one

            ALL_LOCATION_TABLE[location_name] = \
                LocationData(get_panel_location_id(room_name, panel_name), room_name,
                             [RoomAndPanel(None, panel_name)], classification)

            if panel.achievement:
                LOCATIONS_BY_GROUP.setdefault("Achievements", []).append(location_name)

    for room_name, doors in DOORS_BY_ROOM.items():
        for door_name, door in doors.items():
            if door.skip_location or door.event or not door.panels:
                continue

            location_name = door.location_name
            classification = LocationClassification.normal
            if door.include_reduce:
                classification |= LocationClassification.reduced

            if location_name in ALL_LOCATION_TABLE:
                new_id = ALL_LOCATION_TABLE[location_name].code
                classification |= ALL_LOCATION_TABLE[location_name].classification
            else:
                new_id = get_door_location_id(room_name, door_name)

            ALL_LOCATION_TABLE[location_name] = LocationData(new_id, room_name, door.panels, classification)


# Initialize location data on the module scope.
load_location_data()