-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathwarrior.py
More file actions
76 lines (59 loc) · 1.78 KB
/
warrior.py
File metadata and controls
76 lines (59 loc) · 1.78 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import glob
import sys
from pythonwarrior.units.base import UnitBase
from pythonwarrior.units.golem import Golem
class Warrior(UnitBase):
def __init__(self, level=None):
super(Warrior, self).__init__()
self.level = level
self.player_attr = None
self.name_attr = None
self.score = 0
self.golem_abilities = []
self.max_health = 20
def play_turn(self, turn):
return self.player().play_turn(turn)
def player(self):
if self.level.player_path() not in sys.path:
sys.path.insert(0, self.level.player_path())
if glob.glob(self.level.player_path() + '/player.py'):
import player
if self.player_attr:
return self.player_attr
else:
self.player_attr = player.Player()
return self.player_attr
def earn_points(self, points):
self.score = self.score + points
print("earns %d points" % points)
@property
def attack_power(self):
return 5
@property
def shoot_power(self):
return 3
def name(self):
if self.name_attr:
return self.name_attr
else:
return 'Warrior'
def __repr__(self):
return self.name()
@property
def character(self):
return "@"
def perform_turn(self):
if self.current_turn.action is None:
self.say('does nothing')
super(Warrior, self).perform_turn()
def add_golem_abilities(self, *abilities):
self.golem_abilities += abilities
def has_golem(self):
if self.golem_abilities:
return True
else:
return False
def base_golem(self):
golem = Golem()
golem.add_abilities(*self.golem_abilities)
return golem