Module: GamesAndRpgParadise::DnD

Defined in:
lib/games_and_rpg_paradise/rpg/dnd/dnd.rb,
lib/games_and_rpg_paradise/rpg/dnd/combat/combat.rb,
lib/games_and_rpg_paradise/rpg/dnd/weapons/weapons.rb,
lib/games_and_rpg_paradise/rpg/dnd/character/character.rb,
lib/games_and_rpg_paradise/rpg/dnd/skill_points_calculator.rb,
lib/games_and_rpg_paradise/rpg/dnd/items/deck_of_many_things.rb

Overview

GamesAndRpgParadise::DnD

Defined Under Namespace

Modules: Weapons Classes: Character, Combat, DeckOfManyThings, SkillPointsCalculator

Constant Summary collapse

COMMON_CSS_BODY =
#

GamesAndRpgParadise::DnD::COMMON_CSS_BODY

#
'BG_IMG_DD1 BG_Black BG_FIX BG_noR BG_Pos00 mar0px'
DEFAULT_CSS_RULES_FOR_THE_DOC_ELEMENT =
#

GamesAndRpgParadise::DnD::DEFAULT_CSS_RULES_FOR_THE_DOC_ELEMENT

The next CSS rules are for the main doc (aka main <div> tag) on any DnD-related page.

#
'mar0px pad0px s0_8em'
RACIAL_MODIFIERS =
#

GamesAndRpgParadise::DnD::RACIAL_MODIFIERS

This constant (a Hash) refers to the fifth edition rules. We can not use hyphens, so just access the values without a hyphen.

A String such as ‘con+2’ means “CONSTITUTION increases by a value of 2”. All means 1 for all abilities.

#
{
  dwarf:      'con+2',
  elf:        'dex+2',
  halfling:   'dex+2',
  human:      'all+1',       # See: https://www.dndbeyond.com/races/human
  dragonborn: 'str+2,cha+1',
  gnome:      'int+2',
  halfelf:    'cha+2,another_attribute+1,another_attribute+1',
  halforc:    'str+2,con+1',
  tiefling:   'int+1,cha+2'
}
AVAILABLE_RACES =
#

GamesAndRpgParadise::DnD::AVAILABLE_RACES

This constant describes the available races in DnD (5th edition).

Note that draconians are a race specifically from the dragonlance setting; the dragonborn-race is related to this, but somewhat distinct from these “oldschool” draconians.

#
%w(
  dwarf
  elf
  halfling
  human
  dragonborn
  gnome
  half-elf
  half-orc
  tiefling
).sort
DND_MARGIN =
#

DND_MARGIN

This is the default margin for the DnD-cgi or sinatra applications pertaining to DnD-related content.

marl28 means “margin-left: 28%”. It used to be marl40, but I think this was too large.

#
'marl28'
BACKGROUND_COLOUR =
#

BACKGROUND_COLOUR

Specify the background colour to use for the DnD-related web-components.

#
'#f3e6a3'
BORDER_TOP =
#

BORDER_TOP

#
'border-top: 10px solid teal;'
BACKGROUND_IMAGE =
#

BACKGROUND_IMAGE

#
'RPG/DnD/BG_DnD.png'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.hp(i) ⇒ Object

#

GamesAndRpgParadise::DnD.hp

Return the hitpoints, as a String for www-related use.

#


132
133
134
# File 'lib/games_and_rpg_paradise/rpg/dnd/dnd.rb', line 132

def self.hp(i)
  '<span class="darkblue"> Hp: '+i.to_s+'</span>'
end

.load_XP_table_from_the_yaml_datasetObject

#

GamesAndRpgParadise::DnD.load_XP_table_from_the_yaml_dataset

#


186
187
188
189
190
# File 'lib/games_and_rpg_paradise/rpg/dnd/dnd.rb', line 186

def self.load_XP_table_from_the_yaml_dataset
  YAML.load_file(
    GamesAndRpgParadise.project_yaml_directory?+'role_playing_games/dungeons_and_dragons/fifth_edition/xp_table.yml'
  )
end

.random_raceObject

#

GamesAndRpgParadise::DnD.random_race

Return a random race, from the Array defined above.

#


81
82
83
# File 'lib/games_and_rpg_paradise/rpg/dnd/dnd.rb', line 81

def self.random_race
  AVAILABLE_RACES.sample
end

.show_dnd_xp_table(max_level = :default) ⇒ Object

#

GamesAndRpgParadise::DnD.show_dnd_xp_table

This will show the DnD-XP Table.

#


141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/games_and_rpg_paradise/rpg/dnd/dnd.rb', line 141

def self.show_dnd_xp_table(
    max_level = :default
  )
  if max_level.is_a? Hash
    if max_level.has_key? :max_level
      max_level = max_level.delete(:max_level)
    end
  end
  case max_level
  when :default
    max_level = 18
  end
  div('mars2em pad1em','xp_table') {
    e '<script type="text/javascript">
    write_dnc_xp_table('+max_level.to_s+'); 
    </script>'
  }
end

Instance Method Details

#add_background_imageObject

#

add_background_image

This background-image can be used consistently across the .cgi pages related to DnD, as part of the GamesAndRpgParadise project.

#


119
120
121
122
123
124
125
# File 'lib/games_and_rpg_paradise/rpg/dnd/dnd.rb', line 119

def add_background_image
  img(
    BACKGROUND_IMAGE,
    'FLR mar0_5em bblack3',
    'drag_background_image'
  )
end

#show_dnd_xp_table(max_level = 35) ⇒ Object

#

show_dnd_xp_table

#


163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/games_and_rpg_paradise/rpg/dnd/dnd.rb', line 163

def show_dnd_xp_table(max_level = 35)
  if max_level.is_a? Hash
    # ===================================================================== #
    # === :max_level
    # ===================================================================== #
    if max_level.has_key? :max_level
      max_level = max_level.delete(:max_level)
    end
  end
 
  div('mars2em martb2px pad0_5em') {
    fancy3 "Showing the <b>XP table</b> next, for (up to) level #{max_level}:"
    div('mars2em pad0_5em') {
      ee '<script type="text/javascript">
      write_dnc_xp_table('+max_level.to_s+') 
      </script>'
    }
  }
end