Skip to content

Instantly share code, notes, and snippets.

@ryan-scott-dev
Last active December 20, 2015 09:40
Show Gist options
  • Save ryan-scott-dev/6109905 to your computer and use it in GitHub Desktop.
Save ryan-scott-dev/6109905 to your computer and use it in GitHub Desktop.
class Player
def play_turn(warrior)
@direction = :forward if @direction.nil?
if warrior.look(@direction)[1].empty? and warrior.health == @health or @health.nil?
warrior.walk!
elsif warrior.look(@direction)[1].empty? and warrior.health < @health
if warrior.look(@direction)[1].enemy?
warrior.shoot!
end
elsif warrior.feel(@direction).enemy?
warrior.attack!
elsif warrior.look(@direction)[1].enemy?
warrior.shoot!
elsif warrior.feel(@direction).captive?
warrior.rescue!(@direction)
elsif warrior.feel(@direction).wall?
warrior.pivot!
end
@health = warrior.health
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment