Module: Lich::Gemstone::Armaments

Defined in:
documented/gemstone/armaments.rb,
documented/gemstone/armaments/armor_stats.rb,
documented/gemstone/armaments/shield_stats.rb,
documented/gemstone/armaments/weapon_stats.rb,
documented/gemstone/armaments/weapon_stats_blunt.rb,
documented/gemstone/armaments/weapon_stats_edged.rb,
documented/gemstone/armaments/weapon_stats_hybrid.rb,
documented/gemstone/armaments/weapon_stats_ranged.rb,
documented/gemstone/armaments/weapon_stats_thrown.rb,
documented/gemstone/armaments/weapon_stats_natural.rb,
documented/gemstone/armaments/weapon_stats_polearm.rb,
documented/gemstone/armaments/weapon_stats_unarmed.rb,
documented/gemstone/armaments/weapon_stats_brawling.rb,
documented/gemstone/armaments/weapon_stats_runestave.rb,
documented/gemstone/armaments/weapon_stats_two_handed.rb

Overview

Contains constants and methods related to armaments in the game.

See Also:

Defined Under Namespace

Modules: ArmorStats, ShieldStats, WeaponStats

Constant Summary collapse

AG_INDEX_TO_NAME =
{
  1 => "Cloth",
  2 => "Soft Leather",
  3 => "Rigid Leather",
  4 => "Chain",
  5 => "Plate"
}.freeze
ASG_INDEX_TO_NAME =
{
  1  => "Robes",
  2  => "Light Leather",
  3  => "Full Leather",
  4  => "Double Leather",
  5  => "Leather Breastplate",
  6  => "Cuirbouilli",
  7  => "Studded Leather",
  8  => "Reinforced Leather",
  9  => "Hardened Leather",
  10 => "Brigandine",
  11 => "Chain Mail",
  12 => "Double Chain",
  13 => "Augmented Chain",
  14 => "Chain Hauberk",
  15 => "Metal Breastplate",
  16 => "Augmented Breastplate",
  17 => "Half Plate",
  18 => "Full Plate",
  19 => "Field Plate",
  20 => "Augmented Plate"
}.freeze
SPELL_CIRCLE_INDEX_TO_NAME =
{
  0  => { name: "Action",                  abbr: "Act"    },
  1  => { name: "Minor Spiritual",         abbr: "MinSp"  },
  2  => { name: "Major Spiritual",         abbr: "MajSp"  },
  3  => { name: "Cleric",                  abbr: "Clerc"  },
  4  => { name: "Minor Elemental",         abbr: "MinEl"  },
  5  => { name: "Major Elemental",         abbr: "MajEl"  },
  6  => { name: "Ranger",                  abbr: "Rngr"   },
  7  => { name: "Sorcerer",                abbr: "Sorc"   },
  8  => { name: "Old Empath (Deprecated)", abbr: "OldEm"  },
  9  => { name: "Wizard",                  abbr: "Wiz"    },
  10 => { name: "Bard",                    abbr: "Bard"   },
  11 => { name: "Empath",                  abbr: "Emp"    },
  12 => { name: "Minor Mental",            abbr: "MinMn"  },
  13 => { name: "Major Mental",            abbr: "MajMn"  },
  14 => { name: "Savant",                  abbr: "Sav"    },
  15 => { name: "Unused",                  abbr: " - "    },
  16 => { name: "Paladin",                 abbr: "Pal"    },
  17 => { name: "Arcane Spells",           abbr: "Arcne"  },
  18 => { name: "Unused",                  abbr: " - "    },
  19 => { name: "Lost Arts",               abbr: "Lost"   },
}.freeze

Class Method Summary collapse

Class Method Details

.categories(type = nil) ⇒ Array<String>

Retrieves a list of armament categories, optionally filtered by type.

Examples:

Get all armament categories

Armaments.categories

Get only armor categories

Armaments.categories(:armor)

Parameters:

  • type (Symbol, nil) (defaults to: nil)

    the type of armament (:weapon, :armor, :shield) or nil for all

Returns:

  • (Array<String>)

    an array of unique armament categories



140
141
142
143
144
145
146
147
148
# File 'documented/gemstone/armaments.rb', line 140

def self.categories(type = nil)
  case type
  when :weapon then WeaponStats.categories
  when :armor  then ArmorStats.categories
  when :shield then ShieldStats.categories
  else
    WeaponStats.categories + ArmorStats.categories + ShieldStats.categories
  end.uniq
end

.category_for(name) ⇒ String?

Retrieves the category of an armament based on its name.

Examples:

Get the category for a known armor

Armaments.category_for("plate")

Parameters:

  • name (String)

    the name of the armament

Returns:

  • (String, nil)

    the category of the armament or nil if not found



174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'documented/gemstone/armaments.rb', line 174

def self.category_for(name)
  name = name.downcase.strip

  category = WeaponStats.category_for(name)
  return category unless category.nil?

  category = ArmorStats.category_for(name)
  return category unless category.nil?

  category = ShieldStats.category_for(name)
  return category unless category.nil?

  nil
end

.find(name) ⇒ Hash?

Finds an armament by its name.

Examples:

Find a weapon

Armaments.find("sword")

Find an armor

Armaments.find("plate")

Parameters:

  • name (String)

    the name of the armament to find

Returns:

  • (Hash, nil)

    a hash containing the type and data of the armament, or nil if not found



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'documented/gemstone/armaments.rb', line 80

def self.find(name)
  name = name.downcase.strip

  if (data = WeaponStats.find(name))
    return { type: :weapon, data: data }
  end

  if (data = ArmorStats.find(name))
    return { type: :armor, data: data }
  end

  if (data = ShieldStats.find(name))
    return { type: :shield, data: data }
  end

  nil
end

.names(type = nil) ⇒ Array<String>

Retrieves a list of armament names, optionally filtered by type.

Examples:

Get all armament names

Armaments.names

Get only weapon names

Armaments.names(:weapon)

Parameters:

  • type (Symbol, nil) (defaults to: nil)

    the type of armament (:weapon, :armor, :shield) or nil for all

Returns:

  • (Array<String>)

    an array of unique armament names



121
122
123
124
125
126
127
128
129
# File 'documented/gemstone/armaments.rb', line 121

def self.names(type = nil)
  case type
  when :weapon then WeaponStats.names
  when :armor  then ArmorStats.names
  when :shield then ShieldStats.names
  else
    WeaponStats.names + ArmorStats.names + ShieldStats.names
  end.uniq
end

.type_for(name) ⇒ Symbol?

Determines the type of armament based on its name.

Examples:

Get the type for a known weapon

Armaments.type_for("sword")

Parameters:

  • name (String)

    the name of the armament

Returns:

  • (Symbol, nil)

    the type of the armament (:weapon, :armor, :shield) or nil if not found



157
158
159
160
161
162
163
164
165
# File 'documented/gemstone/armaments.rb', line 157

def self.type_for(name)
  name = name.downcase.strip

  return :weapon if WeaponStats.find(name)
  return :armor if ArmorStats.find(name)
  return :shield if ShieldStats.find(name)

  nil
end

.valid_name?(name) ⇒ Boolean

Checks if the given name corresponds to a valid armament.

Examples:

Validate a weapon name

Armaments.valid_name?("sword")

Parameters:

  • name (String)

    the name to validate

Returns:

  • (Boolean)

    true if the name is valid, false otherwise



105
106
107
108
109
110
# File 'documented/gemstone/armaments.rb', line 105

def self.valid_name?(name)
  name = name.downcase.strip

  return true unless Armaments.find(name).nil? # if we found it, then it's valid
  return false # if nil, then the name was not found and it's not a valid name
end