From 123b6b6a3ca9b63a8cfb746cab3e9e69987492d4 Mon Sep 17 00:00:00 2001
From: Jeffrey Phillips Freeman <the@jeffreyfreeman.me>
Date: Tue, 5 May 2020 19:32:51 -0400
Subject: [PATCH] Fixed look and skills command.

---
 lib/aethyr/core/actions/commands/look.rb   | 12 +++++++
 lib/aethyr/core/actions/commands/skills.rb | 38 +++++++++++++++++++-
 lib/aethyr/core/input_handlers/look.rb     | 14 --------
 lib/aethyr/core/input_handlers/skills.rb   | 42 ++--------------------
 4 files changed, 52 insertions(+), 54 deletions(-)

diff --git a/lib/aethyr/core/actions/commands/look.rb b/lib/aethyr/core/actions/commands/look.rb
index f2f4769..2a47a7a 100644
--- a/lib/aethyr/core/actions/commands/look.rb
+++ b/lib/aethyr/core/actions/commands/look.rb
@@ -67,6 +67,18 @@ module Aethyr
             end
           end
 
+          private
+          def describe_area(object)
+            if object.is_a? Room
+              result = object.terrain_type.room_text unless object.terrain_type.nil?
+              result = "uncertain" if result.nil?
+            elsif object.is_a? Area
+              result = object.terrain_type.area_text unless object.terrain_type.nil?
+              result = "uncertain" if result.nil?
+            end
+            result
+          end
+
         end
       end
     end
diff --git a/lib/aethyr/core/actions/commands/skills.rb b/lib/aethyr/core/actions/commands/skills.rb
index b4324ea..516fe10 100644
--- a/lib/aethyr/core/actions/commands/skills.rb
+++ b/lib/aethyr/core/actions/commands/skills.rb
@@ -1,3 +1,4 @@
+# coding: utf-8
 require "aethyr/core/actions/command_action"
 
 module Aethyr
@@ -40,7 +41,7 @@ module Aethyr
 
               output += "│#{text_format_right % ''}│\n"
 
-              output += "│#{SkillsHandler::generate_progress(box_work_width, skill.level_percentage)}│\n"
+              output += "│#{SkillsCommand::generate_progress(box_work_width, skill.level_percentage)}│\n"
 
               xp_left = "#{skill.xp_to_go} xp to next"
               output += "│#{text_format_right % xp_left}│\n"
@@ -55,6 +56,41 @@ module Aethyr
             end
             @player.output(output)
           end
+
+          private
+          def self.generate_progress(width, percentage, style = :vertical_smooth)
+            if (style.eql? :horizontal_smooth) or (style.eql? :vertical_smooth)
+              working_space = width - 7
+              block_per = 1.0 / working_space.to_f
+              filled = (working_space * percentage).to_i
+              filled_coverage = filled.to_f * block_per
+              bar = ("â–ˆ" * filled).to_s
+
+              remaining_coverage = percentage - filled_coverage
+              percent_of_block = remaining_coverage / block_per
+              if percent_of_block >= (7.0 / 8.0)
+                bar += (style.eql?(:horizontal_smooth) ? "â–‰" : "â–‡" )
+              elsif percent_of_block >= (6.0 / 8.0)
+                bar += (style.eql?(:horizontal_smooth) ? "â–Š" : "â–†" )
+              elsif percent_of_block >= (5.0 / 8.0)
+                bar += (style.eql?(:horizontal_smooth) ? "â–‹" : "â–…" )
+              elsif percent_of_block >= (4.0 / 8.0)
+                bar += (style.eql?(:horizontal_smooth) ? "▌" : "▄" )
+              elsif percent_of_block >= (3.0 / 8.0)
+                bar += (style.eql?(:horizontal_smooth) ? "▍" : "▃" )
+              elsif percent_of_block >= (2.0 / 8.0)
+                bar += (style.eql?(:horizontal_smooth) ? "â–Ž" : "â–‚" )
+              elsif percent_of_block >= (1.0 / 8.0)
+                bar += (style.eql?(:horizontal_smooth) ? "▏" : "▁" )
+              end
+
+              bar_format = "%-#{working_space}.#{working_space}s"
+              percent_format = "%-4.4s"
+              percent_text = (percentage * 100.0).to_i.to_s + "%"
+
+              return "[<raw fg:white>#{bar_format % bar}</raw fg:white>] #{percent_format % percent_text}"
+            end
+          end
         end
       end
     end
diff --git a/lib/aethyr/core/input_handlers/look.rb b/lib/aethyr/core/input_handlers/look.rb
index 085d2fe..d6bc9db 100644
--- a/lib/aethyr/core/input_handlers/look.rb
+++ b/lib/aethyr/core/input_handlers/look.rb
@@ -49,21 +49,7 @@ EOF
               $manager.submit_action(Aethyr::Core::Actions::Look::LookCommand.new(@player, { :at => $2 }))
             end
           end
-
-          private
-
-          def describe_area(object)
-            if object.is_a? Room
-              result = object.terrain_type.room_text unless object.terrain_type.nil?
-              result = "uncertain" if result.nil?
-            elsif object.is_a? Area
-              result = object.terrain_type.area_text unless object.terrain_type.nil?
-              result = "uncertain" if result.nil?
-            end
-            result
-          end
         end
-
         Aethyr::Extend::HandlerRegistry.register_handler(LookHandler)
       end
     end
diff --git a/lib/aethyr/core/input_handlers/skills.rb b/lib/aethyr/core/input_handlers/skills.rb
index 7c7d945..a6a23e8 100644
--- a/lib/aethyr/core/input_handlers/skills.rb
+++ b/lib/aethyr/core/input_handlers/skills.rb
@@ -41,46 +41,10 @@ EOF
               $manager.submit_action(Aethyr::Core::Actions::Skills::SkillsCommand.new(@player, {}))
             end
           end
-          
-          private
-
-          def self.generate_progress(width, percentage, style = :vertical_smooth)
-            if (style.eql? :horizontal_smooth) or (style.eql? :vertical_smooth)
-              working_space = width - 7
-              block_per = 1.0 / working_space.to_f
-              filled = (working_space * percentage).to_i
-              filled_coverage = filled.to_f * block_per
-              bar = ("â–ˆ" * filled).to_s
-
-              remaining_coverage = percentage - filled_coverage
-              percent_of_block = remaining_coverage / block_per
-              if percent_of_block >= (7.0 / 8.0)
-                bar += (style.eql?(:horizontal_smooth) ? "â–‰" : "â–‡" )
-              elsif percent_of_block >= (6.0 / 8.0)
-                bar += (style.eql?(:horizontal_smooth) ? "â–Š" : "â–†" )
-              elsif percent_of_block >= (5.0 / 8.0)
-                bar += (style.eql?(:horizontal_smooth) ? "â–‹" : "â–…" )
-              elsif percent_of_block >= (4.0 / 8.0)
-                bar += (style.eql?(:horizontal_smooth) ? "▌" : "▄" )
-              elsif percent_of_block >= (3.0 / 8.0)
-                bar += (style.eql?(:horizontal_smooth) ? "▍" : "▃" )
-              elsif percent_of_block >= (2.0 / 8.0)
-                bar += (style.eql?(:horizontal_smooth) ? "â–Ž" : "â–‚" )
-              elsif percent_of_block >= (1.0 / 8.0)
-                bar += (style.eql?(:horizontal_smooth) ? "▏" : "▁" )
-              end
-
-              bar_format = "%-#{working_space}.#{working_space}s"
-              percent_format = "%-4.4s"
-              percent_text = (percentage * 100.0).to_i.to_s + "%"
-
-              return "[<raw fg:white>#{bar_format % bar}</raw fg:white>] #{percent_format % percent_text}"
-            end
-          end
-
-          Aethyr::Extend::HandlerRegistry.register_handler(SkillsHandler)
         end
+
+        Aethyr::Extend::HandlerRegistry.register_handler(SkillsHandler)
       end
     end
   end
-end
\ No newline at end of file
+end
-- 
GitLab