Skip to content

Instantly share code, notes, and snippets.

@jnf
Created July 27, 2014 05:54
Show Gist options
  • Save jnf/9b67b91b7414deacd286 to your computer and use it in GitHub Desktop.
Save jnf/9b67b91b7414deacd286 to your computer and use it in GitHub Desktop.
Ruby Warrior, Intermediate
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