Class: Lich::Gemstone::SpellRanks
- Inherits:
-
Object
- Object
- Lich::Gemstone::SpellRanks
- Defined in:
- documented/gemstone/spellranks.rb
Overview
Represents the spell ranks in the Lich5 project. This class handles loading, saving, and managing spell rank data.
Instance Attribute Summary collapse
-
#arcanesymbols ⇒ Object
Accessors for various spell rank attributes.
-
#bard ⇒ Object
Accessors for various spell rank attributes.
-
#cleric ⇒ Object
Accessors for various spell rank attributes.
-
#empath ⇒ Object
Accessors for various spell rank attributes.
-
#magicitemuse ⇒ Object
Accessors for various spell rank attributes.
-
#majorelemental ⇒ Object
Accessors for various spell rank attributes.
-
#majorspiritual ⇒ Object
Accessors for various spell rank attributes.
-
#minorelemental ⇒ Object
Accessors for various spell rank attributes.
-
#minormental ⇒ Object
Accessors for various spell rank attributes.
-
#minorspiritual ⇒ Object
Accessors for various spell rank attributes.
-
#monk ⇒ Object
Accessors for various spell rank attributes.
-
#name ⇒ Object
readonly
The name of the spell rank.
-
#paladin ⇒ Object
Accessors for various spell rank attributes.
-
#ranger ⇒ Object
Accessors for various spell rank attributes.
-
#sorcerer ⇒ Object
Accessors for various spell rank attributes.
-
#wizard ⇒ Object
Accessors for various spell rank attributes.
Class Method Summary collapse
-
.[](name) ⇒ SpellRanks?
Finds a spell rank by name.
-
.list ⇒ Array<SpellRanks>
Retrieves the list of all spell ranks.
-
.load ⇒ void
Loads the spell ranks from a data file.
-
.method_missing(arg = nil) ⇒ void
Handles calls to undefined methods for the SpellRanks class.
-
.save ⇒ void
Saves the current spell ranks to a data file.
-
.timestamp ⇒ Integer
Retrieves the current timestamp for the spell ranks.
-
.timestamp=(val) ⇒ void
Sets the timestamp for the spell ranks.
Instance Method Summary collapse
-
#initialize(name) ⇒ void
constructor
Initializes a new SpellRanks object with a name.
Constructor Details
#initialize(name) ⇒ void
Initializes a new SpellRanks object with a name.
109 110 111 112 113 114 |
# File 'documented/gemstone/spellranks.rb', line 109 def initialize(name) SpellRanks.load unless @@loaded @name = name @minorspiritual, @majorspiritual, @cleric, @minorelemental, @majorelemental, @ranger, @sorcerer, @wizard, @bard, @empath, @paladin, @minormental, @arcanesymbols, @magicitemuse = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 @@list.push(self) end |
Instance Attribute Details
#arcanesymbols ⇒ Object
Accessors for various spell rank attributes.
20 21 22 |
# File 'documented/gemstone/spellranks.rb', line 20 def arcanesymbols @arcanesymbols end |
#bard ⇒ Object
Accessors for various spell rank attributes.
20 21 22 |
# File 'documented/gemstone/spellranks.rb', line 20 def @bard end |
#cleric ⇒ Object
Accessors for various spell rank attributes.
20 21 22 |
# File 'documented/gemstone/spellranks.rb', line 20 def cleric @cleric end |
#empath ⇒ Object
Accessors for various spell rank attributes.
20 21 22 |
# File 'documented/gemstone/spellranks.rb', line 20 def empath @empath end |
#magicitemuse ⇒ Object
Accessors for various spell rank attributes.
20 21 22 |
# File 'documented/gemstone/spellranks.rb', line 20 def magicitemuse @magicitemuse end |
#majorelemental ⇒ Object
Accessors for various spell rank attributes.
20 21 22 |
# File 'documented/gemstone/spellranks.rb', line 20 def majorelemental @majorelemental end |
#majorspiritual ⇒ Object
Accessors for various spell rank attributes.
20 21 22 |
# File 'documented/gemstone/spellranks.rb', line 20 def majorspiritual @majorspiritual end |
#minorelemental ⇒ Object
Accessors for various spell rank attributes.
20 21 22 |
# File 'documented/gemstone/spellranks.rb', line 20 def minorelemental @minorelemental end |
#minormental ⇒ Object
Accessors for various spell rank attributes.
20 21 22 |
# File 'documented/gemstone/spellranks.rb', line 20 def minormental @minormental end |
#minorspiritual ⇒ Object
Accessors for various spell rank attributes.
20 21 22 |
# File 'documented/gemstone/spellranks.rb', line 20 def minorspiritual @minorspiritual end |
#monk ⇒ Object
Accessors for various spell rank attributes.
20 21 22 |
# File 'documented/gemstone/spellranks.rb', line 20 def monk @monk end |
#name ⇒ Object (readonly)
The name of the spell rank.
18 19 20 |
# File 'documented/gemstone/spellranks.rb', line 18 def name @name end |
#paladin ⇒ Object
Accessors for various spell rank attributes.
20 21 22 |
# File 'documented/gemstone/spellranks.rb', line 20 def paladin @paladin end |
#ranger ⇒ Object
Accessors for various spell rank attributes.
20 21 22 |
# File 'documented/gemstone/spellranks.rb', line 20 def ranger @ranger end |
#sorcerer ⇒ Object
Accessors for various spell rank attributes.
20 21 22 |
# File 'documented/gemstone/spellranks.rb', line 20 def sorcerer @sorcerer end |
#wizard ⇒ Object
Accessors for various spell rank attributes.
20 21 22 |
# File 'documented/gemstone/spellranks.rb', line 20 def wizard @wizard end |
Class Method Details
.[](name) ⇒ SpellRanks?
Finds a spell rank by name.
86 87 88 89 |
# File 'documented/gemstone/spellranks.rb', line 86 def SpellRanks.[](name) SpellRanks.load unless @@loaded @@list.find { |n| n.name == name } end |
.list ⇒ Array<SpellRanks>
Retrieves the list of all spell ranks.
93 94 95 96 |
# File 'documented/gemstone/spellranks.rb', line 93 def SpellRanks.list SpellRanks.load unless @@loaded @@list end |
.load ⇒ void
This method returns an undefined value.
Loads the spell ranks from a data file.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'documented/gemstone/spellranks.rb', line 27 def SpellRanks.load if File.exist?(File.join(DATA_DIR, "#{XMLData.game}", "spell-ranks.dat")) begin File.open(File.join(DATA_DIR, "#{XMLData.game}", "spell-ranks.dat"), 'rb') { |f| @@timestamp, @@list = Marshal.load(f.read) } # minor mental circle added 2012-07-18; old data files will have @minormental as nil @@list.each { |rank_info| rank_info.minormental ||= 0 } # monk circle added 2013-01-15; old data files will have @minormental as nil @@list.each { |rank_info| rank_info.monk ||= 0 } @@loaded = true rescue respond "--- Lich: error: SpellRanks.load: #{$!}" Lich.log "error: SpellRanks.load: #{$!}\n\t#{$!.backtrace.join("\n\t")}" @@list = Array.new @@timestamp = 0 @@loaded = true end else @@loaded = true end end |
.method_missing(arg = nil) ⇒ void
This method returns an undefined value.
Handles calls to undefined methods for the SpellRanks class.
101 102 103 104 |
# File 'documented/gemstone/spellranks.rb', line 101 def SpellRanks.method_missing(arg = nil) echo "error: unknown method #{arg} for class SpellRanks" respond caller[0..1] end |
.save ⇒ void
This method returns an undefined value.
Saves the current spell ranks to a data file.
55 56 57 58 59 60 61 62 63 64 |
# File 'documented/gemstone/spellranks.rb', line 55 def SpellRanks.save begin File.open(File.join(DATA_DIR, "#{XMLData.game}", "spell-ranks.dat"), 'wb') { |f| f.write(Marshal.dump([@@timestamp, @@list])) } rescue respond "--- Lich: error: SpellRanks.save: #{$!}" Lich.log "error: SpellRanks.save: #{$!}\n\t#{$!.backtrace.join("\n\t")}" end end |
.timestamp ⇒ Integer
Retrieves the current timestamp for the spell ranks.
68 69 70 71 |
# File 'documented/gemstone/spellranks.rb', line 68 def SpellRanks. SpellRanks.load unless @@loaded @@timestamp end |
.timestamp=(val) ⇒ void
This method returns an undefined value.
Sets the timestamp for the spell ranks.
76 77 78 79 |
# File 'documented/gemstone/spellranks.rb', line 76 def SpellRanks.(val) SpellRanks.load unless @@loaded @@timestamp = val end |