Module: Lich::Gemstone::Stats

Defined in:
documented/attributes/stats.rb

Overview

Provides methods to retrieve various character statistics

Examples:

Accessing character stats

Lich::Gemstone::Stats.level

Constant Summary collapse

@@stats =
Note:

This constant is used to define methods for each stat dynamically.

List of character stats

%i(strength constitution dexterity agility discipline aura logic intuition wisdom influence)

Class Method Summary collapse

Class Method Details

.ageInteger

Retrieves the character’s age

Examples:

Lich::Gemstone::Stats.age

Returns:

  • (Integer)

    The character’s age



48
49
50
# File 'documented/attributes/stats.rb', line 48

def self.age
  Infomon.get("stat.age")
end

.expInteger

Calculates the experience points needed for the next level

Examples:

Lich::Gemstone::Stats.exp

Returns:

  • (Integer)

    The experience points needed



96
97
98
99
100
101
102
103
# File 'documented/attributes/stats.rb', line 96

def self.exp
  if XMLData.next_level_text =~ /until next level/
    exp_threshold = [2500, 5000, 10000, 17500, 27500, 40000, 55000, 72500, 92500, 115000, 140000, 167000, 197500, 230000, 265000, 302000, 341000, 382000, 425000, 470000, 517000, 566000, 617000, 670000, 725000, 781500, 839500, 899000, 960000, 1022500, 1086500, 1152000, 1219000, 1287500, 1357500, 1429000, 1502000, 1576500, 1652500, 1730000, 1808500, 1888000, 1968500, 2050000, 2132500, 2216000, 2300500, 2386000, 2472500, 2560000, 2648000, 2736500, 2825500, 2915000, 3005000, 3095500, 3186500, 3278000, 3370000, 3462500, 3555500, 3649000, 3743000, 3837500, 3932500, 4028000, 4124000, 4220500, 4317500, 4415000, 4513000, 4611500, 4710500, 4810000, 4910000, 5010500, 5111500, 5213000, 5315000, 5417500, 5520500, 5624000, 5728000, 5832500, 5937500, 6043000, 6149000, 6255500, 6362500, 6470000, 6578000, 6686500, 6795500, 6905000, 7015000, 7125500, 7236500, 7348000, 7460000, 7572500]
    exp_threshold[XMLData.level] - XMLData.next_level_text.slice(/[0-9]+/).to_i
  else
    XMLData.next_level_text.slice(/[0-9]+/).to_i
  end
end

.genderString

Retrieves the character’s gender

Examples:

Lich::Gemstone::Stats.gender

Returns:

  • (String)

    The character’s gender



40
41
42
# File 'documented/attributes/stats.rb', line 40

def self.gender
  Infomon.get("stat.gender")
end

.levelInteger

Retrieves the character’s level

Examples:

Lich::Gemstone::Stats.level

Returns:

  • (Integer)

    The character’s level



56
57
58
# File 'documented/attributes/stats.rb', line 56

def self.level
  XMLData.level
end

.profString

Retrieves the character’s profession (alias for profession)

Examples:

Lich::Gemstone::Stats.prof

Returns:

  • (String)

    The character’s profession



32
33
34
# File 'documented/attributes/stats.rb', line 32

def self.prof
  self.profession
end

.professionString

Retrieves the character’s profession

Examples:

Lich::Gemstone::Stats.profession

Returns:

  • (String)

    The character’s profession



24
25
26
# File 'documented/attributes/stats.rb', line 24

def self.profession
  Infomon.get("stat.profession")
end

.raceString

Retrieves the character’s race

Examples:

Lich::Gemstone::Stats.race

Returns:

  • (String)

    The character’s race



16
17
18
# File 'documented/attributes/stats.rb', line 16

def self.race
  Infomon.get("stat.race")
end

.serializeArray

Serializes the character’s stats into an array

Examples:

Lich::Gemstone::Stats.serialize

Returns:

  • (Array)

    An array of character stats



109
110
111
112
113
114
115
116
117
118
119
# File 'documented/attributes/stats.rb', line 109

def self.serialize
  [self.race, self.prof, self.gender,
   self.age, self.exp, self.level,
   self.str, self.con, self.dex,
   self.agi, self.dis, self.aur,
   self.log, self.int, self.wis, self.inf,
   self.enhanced_str, self.enhanced_con, self.enhanced_dex,
   self.enhanced_agi, self.enhanced_dis, self.enhanced_aur,
   self.enhanced_log, self.enhanced_int, self.enhanced_wis,
   self.enhanced_inf]
end