-
Notifications
You must be signed in to change notification settings - Fork 1
/
enums.py
112 lines (90 loc) · 2.66 KB
/
enums.py
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import re
from enum import Enum
class GameStatus(Enum):
CREATED = "created"
STARTED = "started"
ABORTED = "aborted"
MATE = "mate"
RESIGN = "resign"
STALEMATE = "stalemate"
TIMEOUT = "timeout"
DRAW = "draw"
OUT_OF_TIME = "outoftime"
CHEAT = "cheat"
NO_START = "noStart"
UNKNOWN_FINISH = "unknownFinish"
VARIANT_END = "variantEnd"
class Event(Enum):
PING = "ping"
CHALLENGE = "challenge"
CHALLENGE_CANCELED = "challengeCanceled"
CHALLENGE_DECLINED = "challengeDeclined"
GAME_START = "gameStart"
GAME_FINISH = "gameFinish"
class GameEvent(Enum):
PING = "ping"
GAME_FULL = "gameFull"
GAME_STATE = "gameState"
CHAT_LINE = "chatLine"
OPPONENT_GONE = "opponentGone"
class Variant(Enum):
STANDARD = "standard"
FROM_POSITION = "fromPosition"
ANTICHESS = "antichess"
ATOMIC = "atomic"
CHESS960 = "chess960"
CRAZYHOUSE = "crazyhouse"
HORDE = "horde"
KING_OF_THE_HILL = "kingOfTheHill"
RACING_KINGS = "racingKings"
THREE_CHECK = "threeCheck"
def __str__(self):
return re.sub("([A-Z])", r" \1", self.value).title()
class PerfType(Enum):
BULLET = "bullet"
BLITZ = "blitz"
RAPID = "rapid"
CLASSICAL = "classical"
ANTICHESS = "antichess"
ATOMIC = "atomic"
CHESS960 = "chess960"
CRAZYHOUSE = "crazyhouse"
HORDE = "horde"
KING_OF_THE_HILL = "kingOfTheHill"
RACING_KINGS = "racingKings"
THREE_CHECK = "threeCheck"
def __str__(self):
return re.sub("([A-Z])", r" \1", self.value).title()
@classmethod
def from_standard_tc(cls, tc_seconds: int, tc_increment: int = 0) -> "PerfType":
duration = tc_seconds + 40 * tc_increment
if duration < 179:
return cls.BULLET
if duration < 479:
return cls.BLITZ
if duration < 1499:
return cls.RAPID
return cls.CLASSICAL
@classmethod
def from_nonstandard_variant(cls, variant: Variant) -> "PerfType":
if variant in (Variant.STANDARD, Variant.FROM_POSITION):
raise ValueError(f"{variant} not supported as a performance type.")
return cls(variant.value)
class BookSelection(Enum):
WEIGHTED_RANDOM = "weighted_random"
UNIFORM_RANDOM = "uniform_random"
BEST_MOVE = "best_move"
class DeclineReason(Enum):
GENERIC = "generic"
LATER = "later"
TOO_FAST = "tooFast"
TOO_SLOW = "tooSlow"
TIME_CONTROL = "timeControl"
RATED = "rated"
CASUAL = "casual"
STANDARD = "standard"
VARIANT = "variant"
NO_BOT = "noBot"
ONLY_BOT = "onlyBot"
def __str__(self):
return re.sub("([A-Z])", r" \1", self.value).lower()