-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.py
98 lines (81 loc) · 2.52 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
import constants
import exception
class Player(object):
def __init__(self, name, wonder=None, left=None, right=None, starting_coins=constants.PLAYER_STARTING_COINS):
"""
Args:
name: String for the name of the player.
left: Reference to the player to the left of current player.
right: Reference to the player to the right of current player.
wonder: Reference to this player's wonder.
starting_coins: Starting number of coins.
"""
self.name = name
self.left = left
self.right = right
self.wonder = wonder
self.coins = starting_coins
self.wins = 0
self.losses = 0
self.wonder_stage = 0
self.cards = []
self.hand = []
def setHand(self, hand=None):
"""Set the player's cards in hand for selection."""
self.hand = hand or []
def canBuildCard(self, card):
"""Check whether the card can be built by the player.
Args:
card: The card to build.
Returns:
True if the card can be built.
"""
# TODO
return True
def buildCard(self, card):
"""Build the card."""
if self.canBuildCard(card):
self.payForCard(card)
self.hand.remove(card)
self.cards.append(card)
self.applyBonus(card)
else:
raise exception.IllegalMoveException(self, card, 'Cannot build card.')
def payForCard(self, card):
"""Pay the cost of the card."""
pass
def applyBonus(self, card):
"""Apply the bonus on the card."""
pass
def exchangeCard(self, card):
"""Exchange card for coins."""
self.hand.remove(card)
self.coins += constants.CARD_EXCHANGE_RATE
def canBuildWonderStage(self):
"""Check whether the player can build the next wonder stage."""
if len(self.wonder.stages) == self.wonder_stage:
return False
# TODO
return True
def buildWonderStage(self, card):
"""Build the next stage of the wonder."""
if self.canBuildWonderStage():
self.hand.remove(card)
self.wonder_stage += 1
else:
raise exception.IllegalMoveException(self, card, 'Cannot build wonder stage.')
def getActiveWonderStages(self):
return self.wonder.stages[:self.wonder_stage]
def getMilitaryStrength(self):
"""Get the player's current military strength, used for combat resolution."""
# TODO
return 0
def calcPoints(self):
"""Calculate total points the player has."""
# TODO
return 0
class TurnSummary(object):
def __init__(self, action, card, coin_delta=0):
self.action = action
self.card = card
self.coin_delta = coin_delta