Guest User

Untitled

a guest
Nov 18th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. module RubyWarrior::Units
  2. class Warrior < Base
  3. def max_health
  4. 1000
  5. end
  6. end
  7. end
  8.  
  9. class Player
  10. def play_turn(warrior)
  11. direction = attack? warrior
  12. if direction
  13. warrior.attack!(direction)
  14. else
  15. warrior.walk!(warrior.direction_of_stairs)
  16. end
  17. end
  18.  
  19. def attack?(warrior)
  20. [:forward, :backward, :left, :right].select do |dir|
  21. warrior.feel(dir).enemy?
  22. end.first
  23. end
  24. end
Add Comment
Please, Sign In to add comment