-
Notifications
You must be signed in to change notification settings - Fork 0
/
Deck.py
71 lines (53 loc) · 1.78 KB
/
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
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
from enum import Enum
import random
import itertools
POSSIBLE_NUMBERS = ["A", "K", "Q", "J", "10", "9", "8", "7", "6", "5", "4", "3", "2"] # Only for refrence, DO NOT CHNAGE LATER
class Shape(Enum):
HEART = 'H' # '♥'
DIAMOND = 'D' # '♦'
CLUB = 'C' # '♣'
SPADE = 'S' # '♠'
def getShapeFromValue(value):
for enum_member in Shape:
if enum_member.value == value:
return enum_member
return None
class Card():
def __init__(self, shape, number):
self.shape = shape
self.number = number
def __str__(self):
return f"{self.number}-{self.shape.value.encode('utf-8').decode('utf-8')}"
class Deck():
def __init__(self):
self.DECK = []
def createDeck(self, shuffle = True):
self.DECK.clear()
for s in Shape:
for num in POSSIBLE_NUMBERS:
self.DECK.append(Card(s, num))
if shuffle:
random.shuffle(self.DECK)
def printDeck(self):
print()
items_per_line = 13
for i in range(0, len(self.DECK), items_per_line):
print(*self.DECK[i:i+items_per_line])
print()
def getTopCard(self):
return self.DECK.pop(0)
def pop(self, i):
return self.DECK.pop(i)
def getCard(self, shape, number):
for card in self.DECK:
if card.shape == shape and card.number == number:
return card
return None
if __name__ == "__main__":
deck = Deck()
deck.createDeck(False)
COMBINATION = itertools.combinations(itertools.combinations(deck.DECK, 2), 4)
for i in COMBINATION:
for x in i:
print(" ".join(map(str, x)))
input()