Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module RubyWarrior::Units
- class Warrior < Base
- def max_health
- 1000
- end
- end
- end
- class Player
- def play_turn(warrior)
- direction = attack? warrior
- if direction
- warrior.attack!(direction)
- else
- warrior.walk!(warrior.direction_of_stairs)
- end
- end
- def attack?(warrior)
- [:forward, :backward, :left, :right].select do |dir|
- warrior.feel(dir).enemy?
- end.first
- end
- end
Add Comment
Please, Sign In to add comment