-
Notifications
You must be signed in to change notification settings - Fork 0
/
constants.py
59 lines (51 loc) · 1.24 KB
/
constants.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
from dataclasses import dataclass, field
@dataclass(frozen=True)
class SuitsRanks:
"""Container class to generate signs and ranks used in most popular card deck type"""
suits: tuple = field(
init=False, default_factory=lambda: ("Clubs", "Diamonds", "Hearts", "Spades")
)
ranks: tuple = field(
init=False,
default_factory=lambda: (
"Ace",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"Jack",
"Queen",
"King",
),
)
def generate_suits(self):
for suit in self.suits:
yield suit
def generate_ranks(self):
for rank in self.ranks:
yield rank
@dataclass(frozen=True)
class BlackjackCardScoring:
"""Container for card values used in BlackJack game."""
values: dict = field(
default_factory=lambda: {
"Ace": 1,
"2": 2,
"3": 3,
"4": 4,
"5": 5,
"6": 6,
"7": 7,
"8": 8,
"9": 9,
"10": 10,
"Jack": 10,
"Queen": 10,
"King": 10,
}
)