-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer.py
38 lines (34 loc) · 1.19 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
import city
import unit
import player_territory
import random
class Player:
"""
An object representing a player of the game
Includes both computer and human players
"""
def __init__(self, game_obj, p_id):
"""
Initialise a new Player object
Requires a p_id, or unique Player id, by which this player can be referenced
The Player starts with no cities, units, or territory.
"""
self.game = game_obj
self.id = p_id
self.cities = []
self.territory = player_territory.PlayerTerritory(game_obj, self)
self.units = []
self.color = (random.randint(50, 255), random.randint(50, 255), random.randint(50, 255))
def add_city(self, c):
"""
Add an existing City object to the Player object
TODO: ensure that the PlayerTerritory object is appropriately modified
"""
self.cities.append(c)
def remove_city(self, c):
"""
Remove an existing City object from the Player object
under the precondition that this Player object has that city
TODO: ensure that the PlayerTerritory object is appropriately modified
"""
self.cities.remove(c)