-
Notifications
You must be signed in to change notification settings - Fork 0
/
rabbit.rb
43 lines (38 loc) · 924 Bytes
/
rabbit.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
require './dwemthy'
class Rabbit < Creature
def initialize
super(life: 10, strength: 2, charisma: 44, weapon: 4)
@bombs = 3
end
attr_reader :bombs
def name; self.class; end
# little boomerang
def ^( enemy )
fight( enemy, 3 )
end
# the hero's sword is unlimited!!
def /( enemy )
fight( enemy, rand( 4 + ( ( enemy.life % 10 ) ** 2 ) ) )
end
# lettuce will build your strength and extra ruffage
# will fly in the face of your opponent!!
def %( enemy )
lettuce = rand( charisma )
puts "[Healthy lettuce gives you #{ lettuce } life points!!]"
@life += lettuce
fight( enemy, 0 )
end
# bombs, but you only have three!!
def *( enemy )
if @bombs.zero?
puts "[UHN!! You're out of bombs!!]"
return
end
@bombs -= 1
fight( enemy, 86 )
end
#what happens when you define a method twice?
def ^( enemy )
fight( enemy, 13)
end
end