Module: Lich::Gemstone::Skills

Defined in:
documented/attributes/skills.rb

Overview

Module for handling skills in the Lich project. Provides methods to calculate bonuses and manage skills.

Examples:

Accessing skills

Lich::Gemstone::Skills.to_bonus(5)

Constant Summary collapse

@@skills =

List of skills available in the Lich project.

%i(two_weapon_combat armor_use shield_use combat_maneuvers edged_weapons blunt_weapons two_handed_weapons ranged_weapons thrown_weapons polearm_weapons brawling ambush multi_opponent_combat physical_fitness dodging arcane_symbols magic_item_use spell_aiming harness_power elemental_mana_control mental_mana_control spirit_mana_control elemental_lore_air elemental_lore_earth elemental_lore_fire elemental_lore_water spiritual_lore_blessings spiritual_lore_religion spiritual_lore_summoning sorcerous_lore_demonology sorcerous_lore_necromancy mental_lore_divination mental_lore_manipulation mental_lore_telepathy mental_lore_transference mental_lore_transformation survival disarming_traps picking_locks stalking_and_hiding perception climbing swimming first_aid trading pickpocketing)

Class Method Summary collapse

Class Method Details

.serializeArray<Integer>

Serializes the current skills into an array.

Examples:

Serializing skills

skills_array = Lich::Gemstone::Skills.serialize

Returns:

  • (Array<Integer>)

    An array of skill ranks.



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'documented/attributes/skills.rb', line 85

def self.serialize
  [self.two_weapon_combat, self.armor_use, self.shield_use, self.combat_maneuvers,
   self.edged_weapons, self.blunt_weapons, self.two_handed_weapons, self.ranged_weapons,
   self.thrown_weapons, self.polearm_weapons, self.brawling, self.ambush,
   self.multi_opponent_combat, self.physical_fitness, self.dodging, self.arcane_symbols,
   self.magic_item_use, self.spell_aiming, self.harness_power, self.elemental_mana_control,
   self.mental_mana_control, self.spirit_mana_control, self.elemental_lore_air,
   self.elemental_lore_earth, self.elemental_lore_fire, self.elemental_lore_water,
   self.spiritual_lore_blessings, self.spiritual_lore_religion, self.spiritual_lore_summoning,
   self.sorcerous_lore_demonology, self.sorcerous_lore_necromancy, self.mental_lore_divination,
   self.mental_lore_manipulation, self.mental_lore_telepathy, self.mental_lore_transference,
   self.mental_lore_transformation, self.survival, self.disarming_traps, self.picking_locks,
   self.stalking_and_hiding, self.perception, self.climbing, self.swimming,
   self.first_aid, self.trading, self.pickpocketing]
end

.to_bonus(ranks) ⇒ Integer

extended function, now takes INT, Symbol, String but not shorthand Symbol, String Skills.to_bonus(Skills.combatmaneuvers), Skills.to_bonus(5), Skills.to_bonus(:combat_maneuvers), Skills.to_bonus(‘combat_maneuvers’) as examples Calculates the bonus based on the number of ranks.

Examples:

Calculating bonus

bonus = Lich::Gemstone::Skills.to_bonus(30)
bonus = Lich::Gemstone::Skills.to_bonus(:combat_maneuvers)

Parameters:

  • ranks (Integer, String, Symbol)

    The ranks to calculate bonus for.

Returns:

  • (Integer)

    The calculated bonus.

Raises:

  • (StandardError)

    If the input is not valid.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'documented/attributes/skills.rb', line 24

def self.to_bonus(ranks)
  case ranks
  when Integer
    bonus = 0
    while ranks > 0
      if ranks > 40
        bonus += (ranks - 40)
        ranks = 40
      elsif ranks > 30
        bonus += (ranks - 30) * 2
        ranks = 30
      elsif ranks > 20
        bonus += (ranks - 20) * 3
        ranks = 20
      elsif ranks > 10
        bonus += (ranks - 10) * 4
        ranks = 10
      else
        bonus += (ranks * 5)
        ranks = 0
      end
    end
    bonus
  when String, Symbol
    Infomon.get("skill.%s_bonus" % ranks)
  else
    echo "You're trying to move the cheese!"
  end
end