Class: GamesAndRpgParadise::DnD::SkillPointsCalculator
- Defined in:
- lib/games_and_rpg_paradise/rpg/dnd/skill_points_calculator.rb
Overview
GamesAndRpgParadise::DnD::SkillPointsCalculator
Constant Summary collapse
- HASH_SKILL_POINTS =
#
HASH_SKILL_POINTS
Keep this hash sorted alphabetically.
#
{ 'barbarian' => 4, 'bard' => 6, 'cleric' => 2, 'druid' => 4, 'fighter' => 2, 'monk' => 4, 'paladin' => 2, 'ranger' => 6, 'rogue' => 8, 'sorcerer' => 2, 'wizard' => 2 }
Constants included from Base::Extensions::Colours
Base::Extensions::Colours::ARRAY_AVAILABLE_KONSOLE_COLOURS
Constants included from CommonExtensions
CommonExtensions::CONTROL_C_CODE, CommonExtensions::N
Instance Attribute Summary collapse
-
#final_string ⇒ Object
readonly
Returns the value of attribute final_string.
Class Method Summary collapse
-
.[](i = '') ⇒ Object
# === GamesAndRpgParadise::DnD::SkillPointsCalculator[] ========================================================================= #.
Instance Method Summary collapse
-
#determine_the_intelligence_bonus(value = @intelligence) ⇒ Object
# === determine_the_intelligence_bonus.
-
#feedback ⇒ Object
# === feedback ========================================================================= #.
-
#initialize(the_class = 'bard', the_level = 1, the_intelligence = 18, race = :human, run_already = true) ⇒ SkillPointsCalculator
constructor
# === initialize.
-
#n_skill_points_available? ⇒ Boolean
(also: #the_result)
# === n_skill_points_available?.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
-
#run ⇒ Object
# === run (run tag) ========================================================================= #.
-
#sanitize ⇒ Object
# === sanitize ========================================================================= #.
-
#verbose_result ⇒ Object
# === verbose_result ========================================================================= #.
Methods included from Base::Extensions::Colours
ecomment, #efancy, #eparse, #forestgreen, #gold, #grey, #lightblue, #mediumseagreen, #mediumslateblue, #peru, #rev, sdir, sfancy, #sfile, simp, #teal, #yellow
Methods included from Base::Extensions::CommandlineArguments
#commandline_arguments?, #filter_away_commandline_arguments, #first_argument?, #first_non_hyphened_argument?, #set_commandline_arguments
Methods included from CommonExtensions
#cat, #cd, #cliner, #copy_file, #delete, #dirname_but_retains_the_trailing_slash, #disable_colours, #ensure_that_the_log_directory_exists, #esystem, #get_user_input, #infer_the_namespace, #is_on_roebe?, #log_dir?, #mkdir, #mkdir_then_cd_into_it, #mv, #namespace?, #opne, #opnn, #project_base_directory?, #project_image_directory?, #project_yaml_directory?, #rds, #register_sigint, #remove_this_directory, #rename_file, #reset_the_internal_hash, #return_pwd, #return_today, #touch_file, #wrap, #write_what_into
Constructor Details
#initialize(the_class = 'bard', the_level = 1, the_intelligence = 18, race = :human, run_already = true) ⇒ SkillPointsCalculator
#
initialize
Input:
1) class name
2) class level
3) the intelligence score
4) the race
#
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/games_and_rpg_paradise/rpg/dnd/skill_points_calculator.rb', line 54 def initialize( the_class = 'bard', the_level = 1, the_intelligence = 18, race = :human, run_already = true ) reset @class = the_class @race = race @level = the_level @intelligence = the_intelligence run if run_already end |
Instance Attribute Details
#final_string ⇒ Object (readonly)
Returns the value of attribute final_string.
22 23 24 |
# File 'lib/games_and_rpg_paradise/rpg/dnd/skill_points_calculator.rb', line 22 def final_string @final_string end |
Class Method Details
.[](i = '') ⇒ Object
#
GamesAndRpgParadise::DnD::SkillPointsCalculator[]
#
163 164 165 |
# File 'lib/games_and_rpg_paradise/rpg/dnd/skill_points_calculator.rb', line 163 def self.[](i = '') new(i) end |
Instance Method Details
#determine_the_intelligence_bonus(value = @intelligence) ⇒ Object
#
determine_the_intelligence_bonus
This method will set the @intelligence_bonus to a proper value.
#
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/games_and_rpg_paradise/rpg/dnd/skill_points_calculator.rb', line 87 def determine_the_intelligence_bonus( value = @intelligence ) case value.to_i when 8,9 i = -1 when 10,11 i = 0 when 12,13 i = 1 when 14,15 i = 2 when 16,17 i = 3 when 18,19 i = 4 when 20 i = 5 end @intelligence_bonus = i end |
#feedback ⇒ Object
#
feedback
#
147 148 149 150 |
# File 'lib/games_and_rpg_paradise/rpg/dnd/skill_points_calculator.rb', line 147 def feedback e "\n#{rev}We have a #{@class} of level #{@level}, "\ "with an intelligence-score of #{@intelligence}.\n\n" end |
#n_skill_points_available? ⇒ Boolean Also known as: the_result
#
n_skill_points_available?
This method will return n_skill_points_available.
#
114 115 116 |
# File 'lib/games_and_rpg_paradise/rpg/dnd/skill_points_calculator.rb', line 114 def n_skill_points_available? return @n_skill_points_available end |
#reset ⇒ Object
#
reset (reset tag)
#
72 73 74 75 76 77 78 79 80 |
# File 'lib/games_and_rpg_paradise/rpg/dnd/skill_points_calculator.rb', line 72 def reset # ======================================================================= # # === @final_string # ======================================================================= # @final_string = ''.dup @intelligence_bonus = 0 @skills_per_level = 0 @n_skill_points_available = 0 end |
#run ⇒ Object
#
run (run tag)
#
155 156 157 158 |
# File 'lib/games_and_rpg_paradise/rpg/dnd/skill_points_calculator.rb', line 155 def run determine_the_intelligence_bonus sanitize end |
#sanitize ⇒ Object
#
sanitize
#
121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/games_and_rpg_paradise/rpg/dnd/skill_points_calculator.rb', line 121 def sanitize @skills_per_level = HASH_SKILL_POINTS[@class] sanitized_level = (@level.to_i+3) case @race when 'human' sanitized_level += 1 end @n_skill_points_available = sanitized_level * ( @skills_per_level.to_i + @intelligence_bonus.to_i ) @final_string = @n_skill_points_available.to_s end |