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

Defined Under Namespace

Modules: ArmorStats, ShieldStats, WeaponStats

Constant Summary collapse

AG_INDEX_TO_NAME =

A mapping of armor group indices to their names.

Examples:

Accessing armor group name

name = Armaments::AG_INDEX_TO_NAME[1]
{
  1 => "Cloth",
  2 => "Soft Leather",
  3 => "Rigid Leather",
  4 => "Chain",
  5 => "Plate"
}.freeze
ASG_INDEX_TO_NAME =

A mapping of armor subtype indices to their names.

Examples:

Accessing armor subtype name

name = Armaments::ASG_INDEX_TO_NAME[1]
{
  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 =

A mapping of spell circle indices to their names and abbreviations.

Examples:

Accessing spell circle name

spell_circle = Armaments::SPELL_CIRCLE_INDEX_TO_NAME[1]
{
  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 categories for armaments of a specified type.

Examples:

Getting all armament categories

all_categories = Armaments.categories

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.



133
134
135
136
137
138
139
140
141
# File 'documented/gemstone/armaments.rb', line 133

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:

Getting the category of an armament

armament_category = Armaments.category_for("sword")

Parameters:

  • name (String)

    The name of the armament.

Returns:

  • (String, nil)

    The category of the armament or nil if not found.



165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'documented/gemstone/armaments.rb', line 165

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 name and returns its type and data.

Examples:

Finding an armament

result = Armaments.find("sword")

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 names for armaments of a specified type.

Examples:

Getting all armament names

all_names = Armaments.names

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.



117
118
119
120
121
122
123
124
125
# File 'documented/gemstone/armaments.rb', line 117

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:

Getting the type of an armament

armament_type = 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.



149
150
151
152
153
154
155
156
157
# File 'documented/gemstone/armaments.rb', line 149

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 is valid by attempting to find it.

Examples:

Validating an armament name

is_valid = Armaments.valid_name?("shield")

Parameters:

  • name (String)

    The name to validate.

Returns:

  • (Boolean)

    True if the name is valid, false otherwise.



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

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