-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcard.py
35 lines (28 loc) · 780 Bytes
/
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
from dataclasses import dataclass
from enum import Enum
class Suit(Enum):
DIAMOND = "\u2666"
CLUB = "\u2663"
HEART = "\u2665"
SPADE = "\u2660"
# JOKER = 4 # I guess no jokers in solo
class Royals(Enum):
JACK = 10
QUEEN = 15
KING = 20
@dataclass
class Card():
suit: Suit
rank: int
health: int = None
attack: int = None
is_royal: bool = False
def __post_init__(self):
self.health = self.rank
self.attack = self.rank
def __eq__(self, other):
return self.suit == other.suit and self.rank == other.rank and self.is_royal == other.is_royal
def __hash__(self):
return hash((self.suit, self.rank))
def __repr__(self):
return f"{self.rank}{self.suit.value.upper()}"