Created
July 27, 2014 05:54
-
-
Save jnf/9b67b91b7414deacd286 to your computer and use it in GitHub Desktop.
Ruby Warrior, Intermediate
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 play_turn(warrior) | |
@warrior = warrior | |
@preferred_direction = @warrior.direction_of_stairs | |
wat_do? | |
end | |
protected | |
def wat_do? | |
space = @warrior.feel @preferred_direction | |
run_for_it! if space.empty? | |
one_eight_four! if space.enemy? | |
end | |
def run_for_it!(direction = @preferred_direction) | |
@warrior.walk! direction | |
end | |
def one_eight_four!(direction = @preferred_direction) | |
@warrior.attack! direction | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment