diff options
Diffstat (limited to 'rubywarrior/alimo-beginner/player.rb')
| -rw-r--r-- | rubywarrior/alimo-beginner/player.rb | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/rubywarrior/alimo-beginner/player.rb b/rubywarrior/alimo-beginner/player.rb index 34262a9..7044745 100644 --- a/rubywarrior/alimo-beginner/player.rb +++ b/rubywarrior/alimo-beginner/player.rb @@ -43,23 +43,18 @@ class Attack end class Rest - FIFTY_PERCENT = 0.5 + def initialize(good_health = GoodHealth.new) + @good_health = good_health + end def matches(warrior) @initial_health ||= warrior.health - warrior.feel.empty? == false && health_is_low(warrior) + warrior.feel.empty? == false && @good_health.matches(warrior) == false end def play(warrior) warrior.rest! end - - private - - def health_is_low(warrior) - threshold = FIFTY_PERCENT * @initial_health - warrior.health <= threshold - end end class Walk |
