Module: Lich::DragonRealms::DRStats
- Defined in:
- documented/dragonrealms/drinfomon/drstats.rb
Overview
Access and manage character stats and attributes in DragonRealms.
This module provides thread-safe read/write access to character statistics gathered from the game's XML data feed, including abilities (strength, agility, etc.), dynamic states (health, mana, balance), and character metadata (guild, gender, age). Stats are cached in module-level variables and persist across script reloads when serialized and restored.
Constant Summary collapse
- GUILD_MANA_TYPES =
Guilds and their native mana types, frozen for immutability.
{ 'Necromancer' => 'arcane', 'Barbarian' => nil, 'Thief' => nil, 'Moon Mage' => 'lunar', 'Trader' => 'lunar', 'Warrior Mage' => 'elemental', 'Bard' => 'elemental', 'Cleric' => 'holy', 'Paladin' => 'holy', 'Empath' => 'life', 'Ranger' => 'life' }.freeze
- @@race =
nil- @@guild =
nil- @@gender =
nil- @@encumbrance =
nil
Class Method Summary collapse
-
.age ⇒ Integer
Returns the character's age in years.
-
.age=(val) ⇒ Integer
Sets the character's age.
-
.agility ⇒ Integer
Returns the character's trained Agility ability.
-
.agility=(val) ⇒ Integer
Sets the character's trained Agility ability.
-
.balance ⇒ Integer
Returns the character's current balance, a measure of how soon the character can perform an action.
-
.balance=(val) ⇒ Integer
Sets the character's current balance.
-
.barbarian? ⇒ Boolean
Returns whether the character is a Barbarian.
-
.bard? ⇒ Boolean
Returns whether the character is a Bard.
-
.charisma ⇒ Integer
Returns the character's trained Charisma ability.
-
.charisma=(val) ⇒ Integer
Sets the character's trained Charisma ability.
-
.circle ⇒ Integer
Returns the character's guild circle (experience tier).
-
.circle=(val) ⇒ Integer
Sets the character's guild circle.
-
.cleric? ⇒ Boolean
Returns whether the character is a Cleric.
-
.commoner? ⇒ Boolean
Returns whether the character is a Commoner.
-
.concentration ⇒ Integer
Returns the character's current concentration from the XML data feed.
-
.discipline ⇒ Integer
Returns the character's trained Discipline ability.
-
.discipline=(val) ⇒ Integer
Sets the character's trained Discipline ability.
-
.empath? ⇒ Boolean
Returns whether the character is an Empath.
-
.encumbrance ⇒ String?
Returns the character's encumbrance level.
-
.encumbrance=(val) ⇒ String?
Sets the character's encumbrance level.
-
.fatigue ⇒ Integer
Returns the character's current fatigue (stamina pool) from the XML data feed.
-
.favors ⇒ Integer
Returns the character's favor count.
-
.favors=(val) ⇒ Integer
Sets the character's favor count.
-
.gender ⇒ String?
Returns the character's gender.
-
.gender=(val) ⇒ String?
Sets the character's gender.
-
.guild ⇒ String?
Returns the character's guild.
-
.guild=(val) ⇒ String?
Sets the character's guild.
-
.health ⇒ Integer
Returns the character's current health from the XML data feed.
-
.intelligence ⇒ Integer
Returns the character's trained Intelligence ability.
-
.intelligence=(val) ⇒ Integer
Sets the character's trained Intelligence ability.
-
.load_serialized=(array) ⇒ Object
BUG FIX: Original code used array which only provides 8 elements but tried to assign to 13 variables (circle + 12 stats), causing data loss.
-
.luck ⇒ Integer
Returns the character's luck rating.
-
.luck=(val) ⇒ Integer
Sets the character's luck rating.
-
.mana ⇒ Integer
Returns the character's current mana from the XML data feed.
-
.moon_mage? ⇒ Boolean
Returns whether the character is a Moon Mage.
-
.name ⇒ String
Returns the character's name from the XML data feed.
-
.native_mana ⇒ String?
Returns the mana type native to the character's guild.
-
.necromancer? ⇒ Boolean
Returns whether the character is a Necromancer.
-
.paladin? ⇒ Boolean
Returns whether the character is a Paladin.
-
.position ⇒ Object
Combat positioning relative to your opponent.
-
.position=(val) ⇒ Integer
Sets the character's combat positioning relative to the opponent.
-
.race ⇒ String?
Returns the character's race.
-
.race=(val) ⇒ String?
Sets the character's race.
-
.ranger? ⇒ Boolean
Returns whether the character is a Ranger.
-
.reflex ⇒ Integer
Returns the character's trained Reflex ability.
-
.reflex=(val) ⇒ Integer
Sets the character's trained Reflex ability.
-
.serialize ⇒ Object
Serialization order (17 elements, indices 0-16): 0: race, 1: guild, 2: gender, 3: age, 4: circle, 5: strength, 6: stamina, 7: reflex, 8: agility, 9: intelligence, 10: wisdom, 11: discipline, 12: charisma, 13: favors, 14: tdps, 15: luck, 16: encumbrance.
-
.spirit ⇒ Integer
Returns the character's current spirit from the XML data feed.
-
.stamina ⇒ Integer
Returns the character's trained Stamina ability.
-
.stamina=(val) ⇒ Integer
Sets the character's trained Stamina ability.
-
.strength ⇒ Integer
Returns the character's trained Strength ability.
-
.strength=(val) ⇒ Integer
Sets the character's trained Strength ability.
-
.tdps ⇒ Integer
Returns the character's total drained points (from experience loss).
-
.tdps=(val) ⇒ Integer
Sets the character's total drained points.
-
.thief? ⇒ Boolean
Returns whether the character is a Thief.
-
.trader? ⇒ Boolean
Returns whether the character is a Trader.
-
.warrior_mage? ⇒ Boolean
Returns whether the character is a Warrior Mage.
-
.wisdom ⇒ Integer
Returns the character's trained Wisdom ability.
-
.wisdom=(val) ⇒ Integer
Sets the character's trained Wisdom ability.
Class Method Details
.age ⇒ Integer
Returns the character's age in years.
92 93 94 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 92 def self.age @@age end |
.age=(val) ⇒ Integer
Sets the character's age.
100 101 102 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 100 def self.age=(val) @@age = val end |
.agility ⇒ Integer
Returns the character's trained Agility ability.
167 168 169 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 167 def self.agility @@agility end |
.agility=(val) ⇒ Integer
Sets the character's trained Agility ability.
175 176 177 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 175 def self.agility=(val) @@agility = val end |
.balance ⇒ Integer
Returns the character's current balance, a measure of how soon the character can perform an action.
287 288 289 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 287 def self.balance @@balance end |
.balance=(val) ⇒ Integer
Sets the character's current balance.
295 296 297 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 295 def self.balance=(val) @@balance = val end |
.barbarian? ⇒ Boolean
Returns whether the character is a Barbarian.
421 422 423 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 421 def self. @@guild == 'Barbarian' end |
.bard? ⇒ Boolean
Returns whether the character is a Bard.
428 429 430 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 428 def self. @@guild == 'Bard' end |
.charisma ⇒ Integer
Returns the character's trained Charisma ability.
227 228 229 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 227 def self.charisma @@charisma end |
.charisma=(val) ⇒ Integer
Sets the character's trained Charisma ability.
235 236 237 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 235 def self.charisma=(val) @@charisma = val end |
.circle ⇒ Integer
Returns the character's guild circle (experience tier).
107 108 109 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 107 def self.circle @@circle end |
.circle=(val) ⇒ Integer
Sets the character's guild circle.
115 116 117 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 115 def self.circle=(val) @@circle = val end |
.cleric? ⇒ Boolean
Returns whether the character is a Cleric.
435 436 437 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 435 def self.cleric? @@guild == 'Cleric' end |
.commoner? ⇒ Boolean
Returns whether the character is a Commoner.
442 443 444 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 442 def self.commoner? @@guild == 'Commoner' end |
.concentration ⇒ Integer
Returns the character's current concentration from the XML data feed.
370 371 372 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 370 def self.concentration XMLData.concentration end |
.discipline ⇒ Integer
Returns the character's trained Discipline ability.
212 213 214 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 212 def self.discipline @@discipline end |
.discipline=(val) ⇒ Integer
Sets the character's trained Discipline ability.
220 221 222 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 220 def self.discipline=(val) @@discipline = val end |
.empath? ⇒ Boolean
Returns whether the character is an Empath.
449 450 451 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 449 def self.empath? @@guild == 'Empath' end |
.encumbrance ⇒ String?
Returns the character's encumbrance level.
320 321 322 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 320 def self.encumbrance @@encumbrance end |
.encumbrance=(val) ⇒ String?
Sets the character's encumbrance level.
328 329 330 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 328 def self.encumbrance=(val) @@encumbrance = val end |
.fatigue ⇒ Integer
Returns the character's current fatigue (stamina pool) from the XML data feed.
356 357 358 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 356 def self.fatigue XMLData.stamina end |
.favors ⇒ Integer
Returns the character's favor count.
242 243 244 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 242 def self.favors @@favors end |
.favors=(val) ⇒ Integer
Sets the character's favor count.
250 251 252 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 250 def self.favors=(val) @@favors = val end |
.gender ⇒ String?
Returns the character's gender.
77 78 79 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 77 def self.gender @@gender end |
.gender=(val) ⇒ String?
Sets the character's gender.
85 86 87 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 85 def self.gender=(val) @@gender = val end |
.guild ⇒ String?
Returns the character's guild.
62 63 64 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 62 def self.guild @@guild end |
.guild=(val) ⇒ String?
Sets the character's guild.
70 71 72 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 70 def self.guild=(val) @@guild = val end |
.health ⇒ Integer
Returns the character's current health from the XML data feed.
342 343 344 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 342 def self.health XMLData.health end |
.intelligence ⇒ Integer
Returns the character's trained Intelligence ability.
182 183 184 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 182 def self.intelligence @@intelligence end |
.intelligence=(val) ⇒ Integer
Sets the character's trained Intelligence ability.
190 191 192 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 190 def self.intelligence=(val) @@intelligence = val end |
.load_serialized=(array) ⇒ Object
411 412 413 414 415 416 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 411 def self.load_serialized=(array) return if array.nil? || array.empty? @@race, @@guild, @@gender, @@age = array[0..3] @@circle, @@strength, @@stamina, @@reflex, @@agility, @@intelligence, @@wisdom, @@discipline, @@charisma, @@favors, @@tdps, @@luck, @@encumbrance = array[4..16] end |
.luck ⇒ Integer
Returns the character's luck rating.
272 273 274 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 272 def self.luck @@luck end |
.luck=(val) ⇒ Integer
Sets the character's luck rating.
280 281 282 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 280 def self.luck=(val) @@luck = val end |
.mana ⇒ Integer
Returns the character's current mana from the XML data feed.
349 350 351 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 349 def self.mana XMLData.mana end |
.moon_mage? ⇒ Boolean
Returns whether the character is a Moon Mage.
456 457 458 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 456 def self.moon_mage? @@guild == 'Moon Mage' end |
.name ⇒ String
Returns the character's name from the XML data feed.
335 336 337 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 335 def self.name XMLData.name end |
.native_mana ⇒ String?
Returns the mana type native to the character's guild.
395 396 397 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 395 def self.native_mana GUILD_MANA_TYPES[@@guild] end |
.necromancer? ⇒ Boolean
Returns whether the character is a Necromancer.
463 464 465 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 463 def self.necromancer? @@guild == 'Necromancer' end |
.paladin? ⇒ Boolean
Returns whether the character is a Paladin.
470 471 472 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 470 def self.paladin? @@guild == 'Paladin' end |
.position ⇒ Object
Combat positioning relative to your opponent. Signed magnitude where positive means you hold the advantage, negative means your opponent does, and 0 is an even contest. See DR_POSITION_VALUES.
302 303 304 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 302 def self.position @@position end |
.position=(val) ⇒ Integer
Sets the character's combat positioning relative to the opponent.
Positive values indicate an advantage, negative values indicate a disadvantage, and 0 is an even contest.
313 314 315 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 313 def self.position=(val) @@position = val end |
.race ⇒ String?
Returns the character's race.
47 48 49 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 47 def self.race @@race end |
.race=(val) ⇒ String?
Sets the character's race.
55 56 57 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 55 def self.race=(val) @@race = val end |
.ranger? ⇒ Boolean
Returns whether the character is a Ranger.
477 478 479 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 477 def self.ranger? @@guild == 'Ranger' end |
.reflex ⇒ Integer
Returns the character's trained Reflex ability.
152 153 154 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 152 def self.reflex @@reflex end |
.reflex=(val) ⇒ Integer
Sets the character's trained Reflex ability.
160 161 162 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 160 def self.reflex=(val) @@reflex = val end |
.serialize ⇒ Object
Serialization order (17 elements, indices 0-16): 0: race, 1: guild, 2: gender, 3: age, 4: circle, 5: strength, 6: stamina, 7: reflex, 8: agility, 9: intelligence, 10: wisdom, 11: discipline, 12: charisma, 13: favors, 14: tdps, 15: luck, 16: encumbrance
404 405 406 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 404 def self.serialize [@@race, @@guild, @@gender, @@age, @@circle, @@strength, @@stamina, @@reflex, @@agility, @@intelligence, @@wisdom, @@discipline, @@charisma, @@favors, @@tdps, @@luck, @@encumbrance] end |
.spirit ⇒ Integer
Returns the character's current spirit from the XML data feed.
363 364 365 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 363 def self.spirit XMLData.spirit end |
.stamina ⇒ Integer
Returns the character's trained Stamina ability.
137 138 139 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 137 def self.stamina @@stamina end |
.stamina=(val) ⇒ Integer
Sets the character's trained Stamina ability.
145 146 147 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 145 def self.stamina=(val) @@stamina = val end |
.strength ⇒ Integer
Returns the character's trained Strength ability.
122 123 124 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 122 def self.strength @@strength end |
.strength=(val) ⇒ Integer
Sets the character's trained Strength ability.
130 131 132 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 130 def self.strength=(val) @@strength = val end |
.tdps ⇒ Integer
Returns the character's total drained points (from experience loss).
257 258 259 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 257 def self.tdps @@tdps end |
.tdps=(val) ⇒ Integer
Sets the character's total drained points.
265 266 267 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 265 def self.tdps=(val) @@tdps = val end |
.thief? ⇒ Boolean
Returns whether the character is a Thief.
484 485 486 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 484 def self.thief? @@guild == 'Thief' end |
.trader? ⇒ Boolean
Returns whether the character is a Trader.
491 492 493 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 491 def self.trader? @@guild == 'Trader' end |
.warrior_mage? ⇒ Boolean
Returns whether the character is a Warrior Mage.
498 499 500 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 498 def self.warrior_mage? @@guild == 'Warrior Mage' end |
.wisdom ⇒ Integer
Returns the character's trained Wisdom ability.
197 198 199 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 197 def self.wisdom @@wisdom end |
.wisdom=(val) ⇒ Integer
Sets the character's trained Wisdom ability.
205 206 207 |
# File 'documented/dragonrealms/drinfomon/drstats.rb', line 205 def self.wisdom=(val) @@wisdom = val end |