Module: GamesAndRpgParadise::DnD::Weapons

Defined in:
lib/games_and_rpg_paradise/rpg/dnd/weapons/weapons.rb

Overview

GamesAndRpgParadise::DnD::Weapons

Class Method Summary collapse

Class Method Details

.display_damage_range_of_the_weapons_in_fifth_edition(use_this_yaml_file = ::GamesAndRpgParadise.project_yaml_directory?+ 'dnd/fifth_edition//weapons_damage_table.yml') ⇒ Object

#

GamesAndRpgParadise::DnD::Weapons.display_damage_range_of_the_weapons_in_fifth_edition

#


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/games_and_rpg_paradise/rpg/dnd/weapons/weapons.rb', line 27

def self.display_damage_range_of_the_weapons_in_fifth_edition(
    use_this_yaml_file = ::GamesAndRpgParadise.project_yaml_directory?+
                         'dnd/fifth_edition//weapons_damage_table.yml'
  )
  dataset = YAML.load_file(use_this_yaml_file)
  dataset.each_pair {|name_of_the_weapon, damage_roll|
    if damage_roll.include?(' ') # e. g. "2d6 slashing"
      damage_roll = damage_roll.split(' ').first.strip
    end
    dice = Dice.create(damage_roll)
    dice.min
    puts (name_of_the_weapon+':').ljust(30)+
         damage_roll.to_s.rjust(4)+' ('+
                              dice.min.to_s+'-'+
                              dice.max.to_s+
                           ')' 
  }
end