Skip to main content
The SpellRanks class provides access to a character’s spell circle ranks and training data. It automatically loads and saves rank information from persistent storage.

Overview

SpellRanks stores training ranks for all spell circles and related skills:
  • Minor Spiritual, Major Spiritual, Cleric
  • Minor Elemental, Major Elemental
  • Minor Mental, Ranger, Sorcerer, Wizard
  • Bard, Empath, Paladin, Monk
  • Arcane Symbols, Magic Item Use

Class Methods

SpellRanks.load

Loads spell rank data from persistent storage.
SpellRanks.load
This method is automatically called when accessing spell rank data, so manual invocation is typically unnecessary.
return
void
Loads rank data from spell-ranks.dat in the game data directory.

SpellRanks.save

Saves current spell rank data to persistent storage.
SpellRanks.save
return
void
Writes rank data to spell-ranks.dat in the game data directory.

SpellRanks.timestamp

Retrieve the last update timestamp for spell rank data.
timestamp = SpellRanks.timestamp
return
Integer
Unix timestamp of when the spell rank data was last updated.

SpellRanks.timestamp=

Set the timestamp for spell rank data.
SpellRanks.timestamp = Time.now.to_i
value
Integer
required
Unix timestamp value to set.

SpellRanks.[]

Retrieve spell rank data for a specific character by name.
character_ranks = SpellRanks["CharacterName"]
name
String
required
Character name to look up.
return
SpellRanks
SpellRanks instance for the specified character, or nil if not found.

SpellRanks.list

Retrieve all stored spell rank data.
all_ranks = SpellRanks.list
return
Array<SpellRanks>
Array of all SpellRanks instances.

Instance Methods

new

Create a new SpellRanks instance for a character.
ranks = SpellRanks.new("CharacterName")
name
String
required
Character name for the spell rank data.
All spell circle ranks are initialized to 0.

name

Get the character name for this spell rank data.
character_name = ranks.name
return
String
Character name.

Instance Attributes

Each SpellRanks instance has accessor attributes for all spell circles and related skills:
minorspiritual
Integer
Minor Spiritual circle ranks.
majorspiritual
Integer
Major Spiritual circle ranks.
cleric
Integer
Cleric Base circle ranks.
minorelemental
Integer
Minor Elemental circle ranks.
majorelemental
Integer
Major Elemental circle ranks.
minormental
Integer
Minor Mental circle ranks.
ranger
Integer
Ranger Base circle ranks.
sorcerer
Integer
Sorcerer Base circle ranks.
wizard
Integer
Wizard Base circle ranks.
bard
Integer
Bard Base circle ranks.
empath
Integer
Empath Base circle ranks.
paladin
Integer
Paladin Base circle ranks.
monk
Integer
Monk Base circle ranks.
arcanesymbols
Integer
Arcane Symbols skill ranks.
magicitemuse
Integer
Magic Item Use skill ranks.

Usage Examples

Access character spell ranks

# Get spell ranks for current character
my_ranks = SpellRanks[XMLData.name]

if my_ranks
  echo "Minor Spiritual: #{my_ranks.minorspiritual}"
  echo "Major Elemental: #{my_ranks.majorelemental}"
  echo "Arcane Symbols: #{my_ranks.arcanesymbols}"
else
  echo "No spell rank data found"
end

Update and save spell ranks

# Create or update spell ranks
ranks = SpellRanks[XMLData.name] || SpellRanks.new(XMLData.name)

ranks.minorspiritual = 25
ranks.majorspiritual = 18
ranks.magicitemuse = 40

# Save to disk
SpellRanks.save

List all characters with spell ranks

SpellRanks.list.each do |ranks|
  echo "#{ranks.name}: MS #{ranks.minorspiritual}, ME #{ranks.minorelemental}"
end

Check timestamp

last_update = SpellRanks.timestamp

if last_update > 0
  time_ago = ((Time.now.to_i - last_update) / 3600.0).round(1)
  echo "Spell ranks updated #{time_ago} hours ago"
else
  echo "No spell rank data available"
end

File Storage

Spell rank data is stored in spell-ranks.dat within the game-specific data directory using Ruby’s Marshal serialization.

Notes

  • Data is automatically loaded when first accessed
  • The minormental and monk circles were added in later updates; old data files will have these initialized to 0
  • All rank values are integers representing training ranks

Build docs developers (and LLMs) love