aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ywalk/types.py
blob: 33048cd82beaa4190b0f10e8ebe28143b54151b0 (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
from dataclasses import dataclass
from enum import Enum

class Mode(Enum):
    ALMSIVI = 'Almsivi Intervention', 'invoke Almsivi Intervention', True, 0.25
    BOAT = 'Boat', 'take the Boat', False, 0
    CARAVAN = 'Caravan', 'use the Caravan', False, 0
    DIVINE = 'Divine Intervention', 'invoke Divine Intervention', True, 0.25
    FOOT = 'Foot', 'walk', False, 0.75
    GUIDE = 'Guild Guide', 'take the Guild Guide', True, 0.5
    PROPYLON = 'Propylon Index', 'travel by Propylon', True, 0.5
    RECALL = 'Recall', 'recall', True, 0
    RIVER_STRIDER = 'River Strider', 'take the River Strider', False, 0
    SILT_STRIDER = 'Silt Strider', 'take the Silt Strider', False, 0

    def __new__(cls, value, pretty, teleport, weight):
        obj = object.__new__(cls)
        obj._value_ = value
        obj.pretty = pretty
        obj.weight = weight
        obj.teleport = teleport
        return obj

    def __str__(self) -> str:
        return self.value

@dataclass(frozen=True)
class Place:
    name: str

    def __str__(self) -> str:
        return self.name

@dataclass(frozen=True)
class Connection:
    origin: Place
    destination: Place
    mode: Mode
    time: int

    def __str__(self) -> str:
        time = 'instantaneous'
        if self.time > 0:
            time = f'{self.time} {"hour" if self.time == 1 else "hours"}'

        return f'{self.origin} -> {self.destination} ({self.mode}, {time})'