-
Notifications
You must be signed in to change notification settings - Fork 838
/
warrior.rb
73 lines (59 loc) · 1.23 KB
/
warrior.rb
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
module RubyWarrior
module Units
class Warrior < Base
attr_writer :name
attr_reader :score
def initialize
@score = 0 # TODO make score dynamic
@golem_abilities = []
end
def play_turn(turn)
player.play_turn(turn)
end
def player
@player ||= Player.new
end
def earn_points(points)
@score += points
say "earns #{points} points"
end
def attack_power
5
end
def shoot_power
3
end
def max_health
20
end
def name
if @name && !@name.empty?
@name
else
"Warrior"
end
end
def to_s
name
end
def character
"@"
end
def perform_turn
say "does nothing" if @current_turn.action.nil?
super
end
def add_golem_abilities(*abilities)
@golem_abilities += abilities
end
def has_golem?
!@golem_abilities.empty?
end
def base_golem
golem = Golem.new
golem.add_abilities *@golem_abilities
golem
end
end
end
end