Skip to content

Instantly share code, notes, and snippets.

@TheRealNOIG
Created April 22, 2016 05:05
Show Gist options
  • Save TheRealNOIG/3dda4ddb63d0595aba2567cd456ef58b to your computer and use it in GitHub Desktop.
Save TheRealNOIG/3dda4ddb63d0595aba2567cd456ef58b to your computer and use it in GitHub Desktop.
class Player
def play_turn(warrior)
if @shotNextTime == true
warrior.shoot!
if !warrior.look.any? { |space| space.enemy? }
@shotNextTime = false
end
elsif warrior.look(:backward).any? { |space| space.enemy? }
warrior.pivot!
@shotNextTime = true;
elsif warrior.look.any? { |space| space.enemy? }
warrior.shoot!
elsif warrior.feel.wall?
warrior.pivot!
elsif warrior.feel.empty? && warrior.health <= 18 && warrior.health >= @health
warrior.rest!
elsif warrior.feel.empty?
warrior.walk!
elsif warrior.feel.captive?
warrior.rescue!
elsif warrior.feel.wall?
warrior.pivot!
else
warrior.attack!
end
@health = warrior.health
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment