-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer.py
109 lines (79 loc) · 2.14 KB
/
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
from hand import Hand
class Player(object):
HUMAN = 1
COMPUTER = 0
def __init__(self,name,tyyppi):
self.__name=name
self.__cottages=0
self.__points=0
self.__hand = Hand()
self.__type = tyyppi
self.__stack = Hand()
'''
name methods
'''
def getName(self):
return self.__name
'''
point methods
'''
def updatePoints(self,amount):
self.__points += amount
def setPoints(self,amount):
self.__points = amount
def getPoints(self):
return self.__points
'''
cottage methods
'''
def getCottages(self):
return self.__cottages
def raiseCottages(self,amount):
self.__cottages+=amount
def setCottages(self,amount):
self.__cottages=amount
def clearCottages(self):
self.__cottages=0
'''
hand methods
'''
def getHand(self):
return self.__hand
def addCardsToHand(self,cards):
self.__hand.addCards(cards)
def addCardToHand(self,card):
self.__hand.append(cards)
def setHand(self,cards):
self.__hand.clear()
self.__hand.addCards(cards)
def hasCards(self):
return len(self.__hand.getCards())>0
'''
stack methods
'''
def getStack(self):
return self.__stack
def clearStack(self):
self.__stack=Hand()
def addCardsToStack(self,cards):
for card in cards:
self.addCardToStack(card)
def addCardToStack(self,card):
self.__stack.addCard(card)
def setStack(self,cards):
self.__stack.clear()
self.__stack.addCards(cards)
'''
type methods
'''
def getType(self):
return self.__type
'''
other methods
'''
def getScoreFromStack(self):
points = self.__cottages
points += self.__stack.getSureValue()
return points
def __str__(self):
return self.__name+"-"+str(self.__points)