-
Notifications
You must be signed in to change notification settings - Fork 0
/
hand.py
42 lines (32 loc) · 1.04 KB
/
hand.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
#!/usr/bin/python3
from card import Card
from logger import Logger
class Hand:
hand = None
def __init__(self, num_cards = 2):
Logger.log("Hand: Creating a new hand with cards: " + str(num_cards))
self.hand = []
for i in range(0, num_cards):
Logger.log("Hand: Calling add_card(Card()).")
self.add_card(Card())
def __del__(self):
pass
def hand_to_string(self):
Logger.log("Hand: Converting hand to string.")
results = "[ "
for i in range(0, 2):
results += Card.translate(self.hand[i]) + " ], ["
return results[:-3]
def add_card(self, g_card):
Logger.log("Hand: add_card(Card) called.")
if (len(self.hand) < 2):
self.hand.append(g_card)
else:
raise Exception('Hand already has two cards.')
def end_hand(self, g_card):
self.hand.clear()
if (__name__ == '__main__'):
one_hand = Hand()
one_hand.add_card("1:9")
one_hand.add_card("1:12")
one_hand.display_hand()