-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcard.py
54 lines (42 loc) · 1.4 KB
/
card.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
from __future__ import annotations
from enum import StrEnum, auto
class CardName(StrEnum):
SODA = "Soda"
MUSCAT_OTTONEL = "Muscat Ottonel"
GREY_FRIAR = "Grey Friar"
ZOLD_VELTELLINI = "Zold Veltellini"
BREAD_AND_DRIPPING = "Bread & Dripping"
WATER_SPILL = "Water Spill"
TIP = "Tip"
GLASS_BREAK = "Glass Break"
MIDDLE_FINDER = "Middle Finger"
@staticmethod
def all() -> list[str]:
return [item.value for item in CardName.__members__.values()]
class CardType(StrEnum):
SODA = auto()
VINE = auto()
PUNISHMENT = auto()
RESIST = auto()
card_type_mapping = {
CardName.SODA: CardType.SODA,
CardName.MUSCAT_OTTONEL: CardType.VINE,
CardName.GREY_FRIAR: CardType.VINE,
CardName.ZOLD_VELTELLINI: CardType.VINE,
CardName.BREAD_AND_DRIPPING: CardType.PUNISHMENT,
CardName.WATER_SPILL: CardType.PUNISHMENT,
CardName.TIP: CardType.PUNISHMENT,
CardName.GLASS_BREAK: CardType.PUNISHMENT,
CardName.MIDDLE_FINDER: CardType.RESIST
}
class Card:
def __init__(self, name: CardName) -> None:
self.name = name
self.type = card_type_mapping[name]
def __repr__(self) -> str:
return self.name
def __str__(self) -> str:
return self.name
@staticmethod
def get_type_of_name(name: CardName) -> CardType:
return card_type_mapping[name]