Created
January 12, 2011 21:31
-
-
Save korutsuru/776930 to your computer and use it in GitHub Desktop.
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
=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