Skip to content

Instantly share code, notes, and snippets.

@korutsuru
Created January 12, 2011 21:31
Show Gist options
  • Save korutsuru/776930 to your computer and use it in GitHub Desktop.
Save korutsuru/776930 to your computer and use it in GitHub Desktop.
=begin
level 1
---------
|@ >|
---------
=end
class Player
def play_turn(warrior)
warrior.walk!
end
end
=begin
level 2
---------
|@ s >|
---------
=end
class Player
def play_turn(warrior)
warrior.feel.empty?? warrior.walk! : warrior.attack!
end
end
=begin
level 3
---------
|@ s ss s>|
---------
=end
class Player
def play_turn(warrior)
warrior.feel.empty? && warrior.health<10? warrior.rest! : warrior.feel.empty?? warrior.walk! : warrior.attack!
end
end
=begin
level 4
-------
|@ Sa S>|
-------
=end
class Player
def play_turn(warrior)
@health = warrior.health unless @health
under_attack=false
if warrior.health<@health then under_attack=true end
if (warrior.feel.empty?) && (warrior.health<18) && (not under_attack)
warrior.rest!
else
if warrior.feel.empty?
warrior.walk!
else warrior.attack! end end
@health=warrior.health
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment