-
Notifications
You must be signed in to change notification settings - Fork 837
platypusBeginner
djuretic edited this page Feb 18, 2012
·
3 revisions
class Player
def play_turn(warrior)
if @shots == nil and @unsafe == nil
@shots = 0
@unsafe = 0
end
if warrior.look(:backward).to_s.include?("Archer")
@unfinished = 1
@unsafe = 1
end
if warrior.feel.empty?
shots = @shots
unsafe = @unsafe
if warrior.feel(:backward).captive?
warrior.rescue!(:backward)
elsif warrior.look(:backward).to_s.include?("Captive")
warrior.walk!(:backward)
elsif shoot_arrow(warrior, shots, unsafe)
warrior.shoot!
@shots += 1
elsif get_rest(warrior)
warrior.rest!
elsif warrior.look.to_s.match(/Ca|Ar|Th|Wi|wa/).to_s == "wa" and @unfinished == 1
warrior.pivot!
@unfinished = 0
else
warrior.walk!
@shots = 0
end
elsif warrior.feel.captive? == true
warrior.rescue!
elsif warrior.feel.wall? == true
warrior.pivot!
else
warrior.attack!
end
end
def get_rest(warrior)
if warrior.look.to_s.match(/Ar|Sl|Wi/) == nil
return false
elsif warrior.look.to_s.match(/Ar|Sl|Wi|Th/).to_s == "Sl" and warrior.health > 6
return false
elsif warrior.look.to_s.match(/Ar|Sl|Wi|Th/).to_s == "Th" and warrior.health > 7
return false
elsif warrior.look.to_s.match(/Ar|Sl|Wi|Th/).to_s == "Ar" and warrior.health > 6
return false
elsif warrior.health < 20
return true
else
return false
end
end
def shoot_arrow(warrior, shots, unsafe)
if warrior.look.to_s.match(/Ca|Wi/).to_s == "Wi"
return true
elsif warrior.look[1].to_s == "nothing" and warrior.look[2].to_s == "Archer"
return true
elsif warrior.look[1].to_s == "Thick Sludge" and shots < 3 and unsafe != 1
return true
elsif warrior.look[1].to_s == "Sludge" and shots <1
return true
else
return false
end
end
end