Skip to content

Instantly share code, notes, and snippets.

@AKovtunov
Created August 6, 2013 07:27
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save AKovtunov/6162779 to your computer and use it in GitHub Desktop.
class Player
def initialize
@health = 20
@wall = false
end
def play_turn(warrior)
if !warrior.feel.captive? and !warrior.look[1].captive? and !warrior.feel.enemy? and warrior.look[2].enemy?
warrior.shoot! #bad condition settings
else
if warrior.feel.wall?
warrior.pivot!
@wall = true
else
if warrior.feel.empty?
if warrior.health < @health.to_f
warrior.health < 10 ? warrior.walk!(:backward) : warrior.walk!
else
warrior.health < 20 ? warrior.rest! : warrior.walk!
end
else
warrior.feel.captive? ? warrior.rescue! : warrior.attack!
end
@health = warrior.health
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment