Module: Lich::Gemstone::Stats

Defined in:
documented/attributes/stats.rb

Overview

API for querying character statistics: abilities, attributes, experience, and level.

Constant Summary collapse

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

Class Method Summary collapse

Class Method Details

.ageInteger?

Returns the character's age in years.

Examples:

Lich::Gemstone::Stats.age #=> 25

Returns:

  • (Integer, nil)

    the age, or nil if not yet cached from the server



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

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

.expInteger?

Returns the character's current experience.

Examples:

Lich::Gemstone::Stats.exp #=> 1234567

Returns:

  • (Integer, nil)

    the experience value, or nil if not yet cached from the server



108
109
110
# File 'documented/attributes/stats.rb', line 108

def self.exp
  XMLData.exp
end

.genderString?

Returns the character's gender.

Examples:

Lich::Gemstone::Stats.gender #=> "Male"

Returns:

  • (String, nil)

    the gender, or nil if not yet cached from the server



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

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

.levelInteger?

Returns the character's level.

Examples:

Lich::Gemstone::Stats.level #=> 50

Returns:

  • (Integer, nil)

    the level, or nil if not yet cached from the server



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

def self.level
  XMLData.level
end

.profString?

Alias for .profession.

Returns:

  • (String, nil)

    the profession name, or nil if not yet cached from the server



30
31
32
# File 'documented/attributes/stats.rb', line 30

def self.prof
  self.profession
end

.professionString?

Returns the character's profession.

Examples:

Lich::Gemstone::Stats.profession #=> "Warrior"

Returns:

  • (String, nil)

    the profession name, or nil if not yet cached from the server



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

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

.raceString?

Returns the character's race.

Examples:

Lich::Gemstone::Stats.race #=> "Human"

Returns:

  • (String, nil)

    the race name, or nil if not yet cached from the server



14
15
16
# File 'documented/attributes/stats.rb', line 14

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

.serializeArray

Returns an array of all character statistics in a fixed order for serialization.

Includes race, profession, gender, age, experience, level, all base and shorthand attributes (str, con, dex, agi, dis, aur, log, int, wis, inf), their enhanced variants, and base variants.

Examples:

Lich::Gemstone::Stats.serialize #=> ["Human", "Warrior", "Male", 25, 1234567, 50, ...]

Returns:

  • (Array)

    an ordered array of character stats; elements may be nil if not yet cached



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'documented/attributes/stats.rb', line 121

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,
   self.base_str, self.base_con, self.base_dex,
   self.base_agi, self.base_dis, self.base_aur,
   self.base_log, self.base_int, self.base_wis,
   self.base_inf]
end