-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruby_warrior.rb
66 lines (57 loc) · 1.21 KB
/
ruby_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
class Player
def play_turn(warrior)
@health = 20 if @health == nil
###captive
if warrior.feel.captive?
warrior.rescue!
elsif (warrior.feel:backward).captive?
warrior.rescue!:backward
###meet enemy
##back
elsif (warrior.feel:backward).enemy?
#turn
warrior.pivot!
##center
elsif warrior.feel.enemy?
#attack
if warrior.health > 4
warrior.attack!
#escape
else
warrior.walk!:backward
end
##archer aim you
elsif warrior.health < @health
#go
if warrior.health >= 18
warrior.walk!
#back
else
warrior.walk!:backward
end
#heal
elsif warrior.health < 20
warrior.rest!
#wall
elsif warrior.feel.wall?
warrior.pivot!
@wall = true
#stairs
elsif warrior.feel.stairs?
warrior.pivot! if @wall == nil
warrior.walk! if @wall
##wizard
else
begin
warrior.look.each{|i|
break if i.captive?
raise if i.enemy?
}
warrior.walk!
rescue
warrior.shoot!
end
end
@health = warrior.health
end # End of playturn
end # End of Class