Created
August 6, 2013 07:27
-
-
Save AKovtunov/6162779 to your computer and use it in GitHub Desktop.
https://www.bloc.io/ruby-warrior/
9 levels :]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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