-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathPlayer.py
47 lines (35 loc) · 927 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
39
40
41
42
43
44
45
46
47
from Hand import Hand
class Player:
def __init__(self, name, auto=False):
self.name = name
self.hand = Hand()
self.score = 0
self.roundScore = 0
self.tricksWon = []
def addCard(self, card):
self.hand.addCard(card)
def getInput(self, option):
card = None
while card is None:
card = raw_input(self.name + ", select a card to " + option + ": ")
return card
def play(self, option='play', c=None, auto=False):
if auto:
card = self.hand.getRandomCard()
elif c is None:
card = self.getInput(option)
else:
card = c
if not auto:
card = self.hand.playCard(card)
return card
def trickWon(self, trick):
self.roundScore += trick.points
def hasSuit(self, suit):
return len(self.hand.hand[suit.iden]) > 0
def removeCard(self, card):
self.hand.removeCard(card)
def discardTricks(self):
self.tricksWon = []
def hasOnlyHearts(self):
return self.hand.hasOnlyHearts()