diff options
Diffstat (limited to 'apworld/player_logic.py')
| -rw-r--r-- | apworld/player_logic.py | 24 |
1 files changed, 24 insertions, 0 deletions
| diff --git a/apworld/player_logic.py b/apworld/player_logic.py new file mode 100644 index 0000000..f54573f --- /dev/null +++ b/apworld/player_logic.py | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | from typing import TYPE_CHECKING, NamedTuple | ||
| 2 | |||
| 3 | if TYPE_CHECKING: | ||
| 4 | from . import Lingo2World | ||
| 5 | |||
| 6 | |||
| 7 | class PlayerLocation(NamedTuple): | ||
| 8 | name: str | ||
| 9 | code: int | None | ||
| 10 | |||
| 11 | |||
| 12 | class Lingo2PlayerLogic: | ||
| 13 | locations_by_room: dict[int, list[PlayerLocation]] | ||
| 14 | |||
| 15 | def __init__(self, world: "Lingo2World"): | ||
| 16 | self.locations_by_room = {} | ||
| 17 | |||
| 18 | code = 1 | ||
| 19 | for door in world.static_logic.objects.doors: | ||
| 20 | if not door.HasField("room_id"): | ||
| 21 | continue | ||
| 22 | |||
| 23 | self.locations_by_room.setdefault(door.room_id, []).append(PlayerLocation(door.name, code)) | ||
| 24 | code += 1 | ||
