-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer.py
38 lines (30 loc) · 913 Bytes
/
player.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
from deck import Deck
from card import Card
class Player:
def __init__(self, player):
self.hand = []
self.player = player
self.finish = False
def __repr__(self):
print('Player {}\'s hand:'.format(self.player))
card_index = 0
for card in self.hand:
print("{}: {}".format(card_index, card))
card_index += 1
return ''
def draw(self, deck, qty):
for quantity in range(qty):
self.hand.append(deck.draw())
def draw_all(self, deck):
for card in deck:
self.hand.append(card)
def draw_from_index(self, index):
card = self.hand.pop(index)
return card
def finish(self):
self.finish = True
def show_hand(self):
card_index = 0
for card in self.hand:
print("{}: {}".format(card_index, card))
card_index += 1