-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayer.py
More file actions
56 lines (43 loc) · 1.5 KB
/
Copy pathplayer.py
File metadata and controls
56 lines (43 loc) · 1.5 KB
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
class Player():
def __init__(self, name, start_planet, game):
self.start_planet = start_planet
self.name = name
self.game = game
self._lost = False
start_planet.to_start_planet(self)
def __repr__(self):
return '<Player: {}>'.format(self.name)
def turn_start(self):
'''can run some commands for especcially ki
returns weather the game should end the turn after it self'''
return True
def has_won(self):
for player in self.game.players:
if player != self:
if not player.has_lost():
#print(self.name, player.name)
return False
return True
def has_lost(self):
if self._lost:
return True
if self.get_own_planets() == []:
self._lost = True
self.game.turn_start()
return True
return False
def get_own_planets(self):
def players_planet(planet):
return planet.owner == self
planets = [i for i in filter(
players_planet, self.game.planetmap.to_list()
)]
return planets
def get_num_planets(self):
return len(self.get_own_planets())
def get_num_spaceships(self):
sum = 0
for ship in self.game.spaceshipmap.to_list():
if ship.owner == self:
sum += 1
return sum