summary refs log tree commit diff stats
path: root/apworld/player_logic.py
blob: f54573fadccaa34c9eaac0ad0d5f1468cac37cfe (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
from typing import TYPE_CHECKING, NamedTuple

if TYPE_CHECKING:
    from . import Lingo2World


class PlayerLocation(NamedTuple):
    name: str
    code: int | None


class Lingo2PlayerLogic:
    locations_by_room: dict[int, list[PlayerLocation]]

    def __init__(self, world: "Lingo2World"):
        self.locations_by_room = {}

        code = 1
        for door in world.static_logic.objects.doors:
            if not door.HasField("room_id"):
                continue

            self.locations_by_room.setdefault(door.room_id, []).append(PlayerLocation(door.name, code))
            code += 1