-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayer.py
More file actions
34 lines (26 loc) · 774 Bytes
/
player.py
File metadata and controls
34 lines (26 loc) · 774 Bytes
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
from buildings import *
from soldiers import SoldierClass
class Player(object):
def __init__(self, name, money, army, buildings):
self.name = name
self.money = money
self.army = army
self.buildings = buildings
def buyArmy(self, economy, army):
iCost = economy.cost(army)
print "Buying army for %d coins"%(iCost)
if iCost <= self.money:
self.army += [army]
self.money -= iCost
return True;
else:
return False;
def buyBuilding(self, economy, building):
iCost = economy.buildingCost(building)
print "Buying building for %d coins"%(iCost)
if iCost <= self.money:
self.buildings += [building]
self.money -= iCost
return True;
else:
return False;