-
Notifications
You must be signed in to change notification settings - Fork 837
Apoema's code
Figuera edited this page May 19, 2012
·
1 revision
class Player
def play_turn(warrior)
@flechas ||= 0
o_que = O_que(warrior, :forward)[:o_que]
aonde = O_que(warrior, :forward)[:aonde]
tras = O_que(warrior, :backward)[:o_que]
case
when tras == "Captive" && o_que == "Thick Sludge"
@level ||= 6
when tras == "Thick Sludge" && o_que == "wall"
@level ||= 7
when tras == "Archer" && o_que == "Thick Sludge"
@level ||= 9
end
case
when tras == "Captive"
@acao = :correr
when o_que == "Archer"
@acao = AcaoArqueiro(warrior, aonde)
when o_que == "Wizard"
@acao = :atirar
when o_que == "Sludge"
@acao = AcaoGosma(warrior, :pequena, aonde)
when o_que == "Thick Sludge"
@acao = AcaoGosma(warrior, :grande, aonde)
else
@acao = :seguir
end
Agir(warrior)
end
end
def Agir(warrior)
if warrior.feel.enemy?
warrior.attack!
@flechas = 0
elsif warrior.feel.captive?
if @level == 9
warrior.pivot!
@level = nil
else
warrior.rescue!
end
elsif warrior.feel(:backward).captive?
warrior.rescue!(:backward)
else
case @acao
when :correr
warrior.walk!(:backward)
when :seguir
warrior.feel.wall? ? warrior.pivot! : warrior.walk!
when :atirar
warrior.shoot!
@flechas += 1
when :curar
warrior.rest!
when :virar
warrior.pivot!(:backward)
end
end
end
def AcaoArqueiro(warrior, aonde)
case aonde
when 1
:seguir
when 2
case
when warrior.health > 15
:seguir
when warrior.health > 6 && @level != 6 || @flechas > 0
:atirar
end
end
end
def AcaoGosma(warrior, tamanho, aonde)
case
when @level == 7 || @level == 9
atirar = false
when @level == 6
atirar = @flechas < 5
when tamanho == :pequena
atirar = @flechas < 1
when tamanho == :grande
atirar = @flechas < 3
end
case
when warrior.health < 6
:curar
when atirar
:atirar
else
:seguir
end
end
def O_que(warrior, direcao)
if warrior.look(direcao)[0].to_s == "nothing"
if warrior.look(direcao)[1].to_s == "nothing"
{ :o_que => warrior.look(direcao)[2].to_s, :aonde => 2 }
else
{ :o_que => warrior.look(direcao)[1].to_s, :aonde => 1 }
end
else
{ :o_que => warrior.look(direcao)[0].to_s, :aonde => 0 }
end
end