From d64bb991bdaa4240a3f7ec38b92f675048e2b27c Mon Sep 17 00:00:00 2001 From: mo khan Date: Wed, 24 Apr 2013 08:40:48 -0600 Subject: extract hard coded constant --- rubywarrior/alimo-beginner/player.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rubywarrior/alimo-beginner/player.rb b/rubywarrior/alimo-beginner/player.rb index a30e0f3..aba09b9 100644 --- a/rubywarrior/alimo-beginner/player.rb +++ b/rubywarrior/alimo-beginner/player.rb @@ -1,4 +1,5 @@ class Player + FIFTY_PERCENT = 0.5 def play_turn(warrior) @initial_health ||= warrior.health if warrior.feel.empty? @@ -10,8 +11,7 @@ class Player end def health_is_low(warrior) - threshold = 0.5 * @initial_health - p "threshold is #{threshold}, initial health: #{@initial_health}, current: #{warrior.health}" + threshold = FIFTY_PERCENT * @initial_health warrior.health <= threshold end end -- cgit v1.2.3