Class: Lich::Gemstone::SpellRanks
- Inherits:
-
Object
- Object
- Lich::Gemstone::SpellRanks
- Defined in:
- documented/gemstone/spellranks.rb
Overview
Represents the spell ranks for various classes in the Lich project.
This class manages loading and saving spell rank data.
Instance Attribute Summary collapse
-
#arcanesymbols ⇒ Object
Returns the value of attribute arcanesymbols.
-
#bard ⇒ Object
Returns the value of attribute bard.
-
#cleric ⇒ Object
Returns the value of attribute cleric.
-
#empath ⇒ Object
Returns the value of attribute empath.
-
#magicitemuse ⇒ Object
Returns the value of attribute magicitemuse.
-
#majorelemental ⇒ Object
Returns the value of attribute majorelemental.
-
#majorspiritual ⇒ Object
Returns the value of attribute majorspiritual.
-
#minorelemental ⇒ Object
Returns the value of attribute minorelemental.
-
#minormental ⇒ Object
Returns the value of attribute minormental.
-
#minorspiritual ⇒ Object
Returns the value of attribute minorspiritual.
-
#monk ⇒ Object
Returns the value of attribute monk.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#paladin ⇒ Object
Returns the value of attribute paladin.
-
#ranger ⇒ Object
Returns the value of attribute ranger.
-
#sorcerer ⇒ Object
Returns the value of attribute sorcerer.
-
#wizard ⇒ Object
Returns the value of attribute wizard.
Class Method Summary collapse
-
.[](name) ⇒ Object?
Finds a spell rank by name.
-
.list ⇒ Array<Object>
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 the given name.
Constructor Details
#initialize(name) ⇒ void
Initializes a new SpellRanks object with the given name.
97 98 99 100 101 102 |
# File 'documented/gemstone/spellranks.rb', line 97 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
Returns the value of attribute arcanesymbols.
14 15 16 |
# File 'documented/gemstone/spellranks.rb', line 14 def arcanesymbols @arcanesymbols end |
#bard ⇒ Object
Returns the value of attribute bard.
14 15 16 |
# File 'documented/gemstone/spellranks.rb', line 14 def @bard end |
#cleric ⇒ Object
Returns the value of attribute cleric.
14 15 16 |
# File 'documented/gemstone/spellranks.rb', line 14 def cleric @cleric end |
#empath ⇒ Object
Returns the value of attribute empath.
14 15 16 |
# File 'documented/gemstone/spellranks.rb', line 14 def empath @empath end |
#magicitemuse ⇒ Object
Returns the value of attribute magicitemuse.
14 15 16 |
# File 'documented/gemstone/spellranks.rb', line 14 def magicitemuse @magicitemuse end |
#majorelemental ⇒ Object
Returns the value of attribute majorelemental.
14 15 16 |
# File 'documented/gemstone/spellranks.rb', line 14 def majorelemental @majorelemental end |
#majorspiritual ⇒ Object
Returns the value of attribute majorspiritual.
14 15 16 |
# File 'documented/gemstone/spellranks.rb', line 14 def majorspiritual @majorspiritual end |
#minorelemental ⇒ Object
Returns the value of attribute minorelemental.
14 15 16 |
# File 'documented/gemstone/spellranks.rb', line 14 def minorelemental @minorelemental end |
#minormental ⇒ Object
Returns the value of attribute minormental.
14 15 16 |
# File 'documented/gemstone/spellranks.rb', line 14 def minormental @minormental end |
#minorspiritual ⇒ Object
Returns the value of attribute minorspiritual.
14 15 16 |
# File 'documented/gemstone/spellranks.rb', line 14 def minorspiritual @minorspiritual end |
#monk ⇒ Object
Returns the value of attribute monk.
14 15 16 |
# File 'documented/gemstone/spellranks.rb', line 14 def monk @monk end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'documented/gemstone/spellranks.rb', line 13 def name @name end |
#paladin ⇒ Object
Returns the value of attribute paladin.
14 15 16 |
# File 'documented/gemstone/spellranks.rb', line 14 def paladin @paladin end |
#ranger ⇒ Object
Returns the value of attribute ranger.
14 15 16 |
# File 'documented/gemstone/spellranks.rb', line 14 def ranger @ranger end |
#sorcerer ⇒ Object
Returns the value of attribute sorcerer.
14 15 16 |
# File 'documented/gemstone/spellranks.rb', line 14 def sorcerer @sorcerer end |
#wizard ⇒ Object
Returns the value of attribute wizard.
14 15 16 |
# File 'documented/gemstone/spellranks.rb', line 14 def wizard @wizard end |
Class Method Details
.[](name) ⇒ Object?
Finds a spell rank by name.
74 75 76 77 |
# File 'documented/gemstone/spellranks.rb', line 74 def self.[](name) SpellRanks.load unless @@loaded @@list.find { |n| n.name == name } end |
.list ⇒ Array<Object>
Retrieves the list of all spell ranks.
81 82 83 84 |
# File 'documented/gemstone/spellranks.rb', line 81 def self.list SpellRanks.load unless @@loaded @@list end |
.load ⇒ void
This method returns an undefined value.
Loads the spell ranks from a data file.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'documented/gemstone/spellranks.rb', line 19 def self.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.
89 90 91 92 |
# File 'documented/gemstone/spellranks.rb', line 89 def self.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.
45 46 47 48 49 50 51 52 53 54 |
# File 'documented/gemstone/spellranks.rb', line 45 def self.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.
58 59 60 61 |
# File 'documented/gemstone/spellranks.rb', line 58 def self. SpellRanks.load unless @@loaded @@timestamp end |
.timestamp=(val) ⇒ void
This method returns an undefined value.
Sets the timestamp for the spell ranks.
66 67 68 69 |
# File 'documented/gemstone/spellranks.rb', line 66 def self.(val) SpellRanks.load unless @@loaded @@timestamp = val end |