diff --git a/lib/aethyr/core/actions/commands/look.rb b/lib/aethyr/core/actions/commands/look.rb index f2f476993e24cda58b3b3e17067b98b1f2349a6c..2a47a7a9760a519f8ad08abd28a0e0cc04a12a5f 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 b4324eac2f8d658ff33d381cce2e45b5882334b4..516fe10a863abccb5e5c2890929639a68c960cd9 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 085d2fe8b0c2a719e050642e34869f675ea12269..d6bc9db5a048440c7d582d6c934ffc39809f7c1d 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 7c7d945e1b716122259fde63c8413a088a1bb2ed..a6a23e8bd6963713aa67a7736ad6d63b0163fb1d 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