-
Notifications
You must be signed in to change notification settings - Fork 1
/
Deck.py
44 lines (36 loc) · 773 Bytes
/
Deck.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
import random
class deck:
suits = [
"Diamonds",
"Clubs",
"Hearts",
"Spades"
]
cardnames = [
"Ace",
"Two",
"Three",
"Four",
"Five",
"Six",
"Seven",
"Eight",
"Nine",
"Ten",
"Jack",
"Queen",
"King"
]
def __init__(self):
self.cards = []
def shuffle(self):
self.cards = list(range(52))
random.shuffle(self.cards)
def draw(self):
return self.cards.pop()
@staticmethod
def pointValue(cardid: int):
return min(cardid % 13 + 1, 10)
@staticmethod
def cardString(cardid: int):
return deck.cardnames[cardid % 13] + " of " + deck.suits[cardid // 13]