Class: Lich::Gemstone::Spellsong

Inherits:
Object
  • Object
show all
Defined in:
lib/attributes/spellsong.rb

Overview

Represents a spellsong for a bard character.

Class Method Summary collapse

Class Method Details

.armorcostArray<Integer>

Calculates the cost for the armor spell.

Examples:

Spellsong.armorcost

Returns:

  • (Array<Integer>)

    the cost of the armor spell.



354
355
356
# File 'lib/attributes/spellsong.rb', line 354

def self.armorcost
  [14, 5]
end

.costInteger

Calculates the cost of the spellsong.

Examples:

Spellsong.cost

Returns:

  • (Integer)

    the cost of the spellsong.



207
208
209
# File 'lib/attributes/spellsong.rb', line 207

def self.cost
  self.renew_cost
end

.depressionpushdownInteger

Calculates the push down bonus for the depression spell.

Examples:

Spellsong.depressionpushdown

Returns:

  • (Integer)

    the depression push down bonus.



177
178
179
# File 'lib/attributes/spellsong.rb', line 177

def self.depressionpushdown
  20 + Skills.mltelepathy
end

.depressionslowInteger

Calculates the slow bonus for the depression spell.

Examples:

Spellsong.depressionslow

Returns:

  • (Integer)

    the depression slow bonus.



186
187
188
189
190
191
# File 'lib/attributes/spellsong.rb', line 186

def self.depressionslow
  thresholds = [10, 25, 45, 70, 100]
  bonus = -2
  thresholds.each { |val| if Skills.mltelepathy >= val then bonus -= 1 end }
  bonus
end

.durationFloat

Calculates the duration of the spellsong based on various stats.

Examples:

Spellsong.duration

Returns:

  • (Float)

    the duration of the spellsong.



72
73
74
75
76
77
78
# File 'lib/attributes/spellsong.rb', line 72

def self.duration
  return @@song_duration if @@duration_calcs == [Stats.level, Stats.log[1], Stats.inf[1], Skills.mltelepathy]
  return @@song_duration if [Stats.level, Stats.log[1], Stats.inf[1], Skills.mltelepathy].include?(nil)
  @@duration_calcs = [Stats.level, Stats.log[1], Stats.inf[1], Skills.mltelepathy]
  total = self.duration_base_level(Stats.level)
  return (@@song_duration = total + Stats.log[1] + (Stats.inf[1] * 3) + (Skills.mltelepathy * 2))
end

.duration_base_level(level = Stats.level) ⇒ Integer

Calculates the base duration of the spellsong based on the bard’s level.

Examples:

Spellsong.duration_base_level(30)

Parameters:

  • level (Integer) (defaults to: Stats.level)

    the level of the bard (default is the current level).

Returns:

  • (Integer)

    the base duration of the spellsong.



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/attributes/spellsong.rb', line 86

def self.duration_base_level(level = Stats.level)
  total = 120
  case level
  when (0..25)
    total += level * 4
  when (26..50)
    total += 100 + (level - 25) * 3
  when (51..75)
    total += 175 + (level - 50) * 2
  when (76..100)
    total += 225 + (level - 75)
  else
    Lich.log("unhandled case in Spellsong.duration level=#{level}")
  end
  return total
end

.fortcostArray<Integer>

Calculates the cost for the fort spell.

Examples:

Spellsong.fortcost

Returns:

  • (Array<Integer>)

    the cost of the fort spell.



327
328
329
# File 'lib/attributes/spellsong.rb', line 327

def self.fortcost
  [3, 1]
end

.holdingtargetsInteger

Calculates the number of targets that can be held by the bard.

Examples:

Spellsong.holdingtargets

Returns:

  • (Integer)

    the number of holding targets.



198
199
200
# File 'lib/attributes/spellsong.rb', line 198

def self.holdingtargets
  1 + ((Spells.bard - 1) / 7).truncate
end

.luckcostArray<Integer>

Calculates the cost for the luck spell.

Examples:

Spellsong.luckcost

Returns:

  • (Array<Integer>)

    the cost of the luck spell.



309
310
311
# File 'lib/attributes/spellsong.rb', line 309

def self.luckcost
  [6 + ((Spells.bard - 6) / 4), (6 + ((Spells.bard - 6) / 4) / 2).round]
end

.manacostArray<Integer>

Calculates the mana cost for spells.

Examples:

Spellsong.manacost

Returns:

  • (Array<Integer>)

    the mana cost for spells.



318
319
320
# File 'lib/attributes/spellsong.rb', line 318

def self.manacost
  [18, 15]
end

.mirrorscostArray<Integer>

Calculates the cost for the mirrors spell.

Examples:

Spellsong.mirrorscost

Returns:

  • (Array<Integer>)

    the cost of the mirrors spell.



237
238
239
# File 'lib/attributes/spellsong.rb', line 237

def self.mirrorscost
  [19 + ((Spells.bard - 19) / 5).truncate, 8 + ((Spells.bard - 19) / 10).truncate]
end

.mirrorsdodgebonusInteger

Calculates the dodge bonus for the mirrors spell.

Examples:

Spellsong.mirrorsdodgebonus

Returns:

  • (Integer)

    the mirrors dodge bonus.



228
229
230
# File 'lib/attributes/spellsong.rb', line 228

def self.mirrorsdodgebonus
  20 + ((Spells.bard - 19) / 2).round
end

.renew_costInteger

Calculates the total cost to renew active spells.

Examples:

Spellsong.renew_cost

Returns:

  • (Integer)

    the total renewal cost for active spells.



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/attributes/spellsong.rb', line 108

def self.renew_cost
  # fixme: multi-spell penalty?
  total = num_active = 0
  [1003, 1006, 1009, 1010, 1012, 1014, 1018, 1019, 1025].each { |song_num|
    if (song = Spell[song_num])
      if song.active?
        total += song.renew_cost
        num_active += 1
      end
    else
      echo "self.renew_cost: warning: can't find song number #{song_num}"
    end
  }
  return total
end

.renewedTime

Updates the time when the spellsong was last renewed.

Examples:

Spellsong.renewed

Returns:

  • (Time)

    the current time when the spellsong was renewed.



25
26
27
# File 'lib/attributes/spellsong.rb', line 25

def self.renewed
  @@renewed = Time.now
end

.renewed=(val) ⇒ Object

Sets the renewed time for the spellsong.

Examples:

Spellsong.renewed = Time.now

Parameters:

  • val (Time)

    the time to set as the renewed time.



34
35
36
# File 'lib/attributes/spellsong.rb', line 34

def self.renewed=(val)
  @@renewed = val
end

.renewed_atTime

Retrieves the last renewed time of the spellsong.

Examples:

Spellsong.renewed_at

Returns:

  • (Time)

    the last renewed time.



43
44
45
# File 'lib/attributes/spellsong.rb', line 43

def self.renewed_at
  @@renewed
end

.serializeFloat

Serializes the current time left for the spellsong.

Examples:

Spellsong.serialize

Returns:

  • (Float)

    the time left in minutes.



63
64
65
# File 'lib/attributes/spellsong.rb', line 63

def self.serialize
  self.timeleft
end

.shieldcostArray<Integer>

Calculates the cost for the shield spell.

Examples:

Spellsong.shieldcost

Returns:

  • (Array<Integer>)

    the cost of the shield spell.



336
337
338
# File 'lib/attributes/spellsong.rb', line 336

def self.shieldcost
  [9, 4]
end

.sonicarmorbonusInteger

Calculates the sonic armor bonus.

Examples:

Spellsong.sonicarmorbonus

Returns:

  • (Integer)

    the sonic armor bonus.



255
256
257
# File 'lib/attributes/spellsong.rb', line 255

def self.sonicarmorbonus
  self.sonicbonus + 15
end

.sonicarmordurabilityInteger

Calculates the durability of the sonic armor.

Examples:

Spellsong.sonicarmordurability

Returns:

  • (Integer)

    the durability of the sonic armor.



129
130
131
# File 'lib/attributes/spellsong.rb', line 129

def self.sonicarmordurability
  210 + (Stats.level / 2).round + Skills.to_bonus(Skills.elair)
end

.sonicbladebonusInteger

Calculates the sonic blade bonus.

Examples:

Spellsong.sonicbladebonus

Returns:

  • (Integer)

    the sonic blade bonus.



264
265
266
# File 'lib/attributes/spellsong.rb', line 264

def self.sonicbladebonus
  self.sonicbonus + 10
end

.sonicbladedurabilityInteger

Calculates the durability of the sonic blade.

Examples:

Spellsong.sonicbladedurability

Returns:

  • (Integer)

    the durability of the sonic blade.



138
139
140
# File 'lib/attributes/spellsong.rb', line 138

def self.sonicbladedurability
  160 + (Stats.level / 2).round + Skills.to_bonus(Skills.elair)
end

.sonicbonusInteger

Calculates the sonic bonus based on the bard’s spells.

Examples:

Spellsong.sonicbonus

Returns:

  • (Integer)

    the sonic bonus.



246
247
248
# File 'lib/attributes/spellsong.rb', line 246

def self.sonicbonus
  (Spells.bard / 2).round
end

.sonicshieldbonusInteger

Calculates the sonic shield bonus.

Examples:

Spellsong.sonicshieldbonus

Returns:

  • (Integer)

    the sonic shield bonus.



282
283
284
# File 'lib/attributes/spellsong.rb', line 282

def self.sonicshieldbonus
  self.sonicbonus + 10
end

.sonicshielddurabilityInteger

Calculates the durability of the sonic shield.

Examples:

Spellsong.sonicshielddurability

Returns:

  • (Integer)

    the durability of the sonic shield.



156
157
158
# File 'lib/attributes/spellsong.rb', line 156

def self.sonicshielddurability
  125 + (Stats.level / 2).round + Skills.to_bonus(Skills.elair)
end

.sonicweaponbonusInteger

Calculates the sonic weapon bonus.

Examples:

Spellsong.sonicweaponbonus

Returns:

  • (Integer)

    the sonic weapon bonus.



273
274
275
# File 'lib/attributes/spellsong.rb', line 273

def self.sonicweaponbonus
  self.sonicbladebonus
end

.sonicweapondurabilityInteger

Calculates the durability of the sonic weapon.

Examples:

Spellsong.sonicweapondurability

Returns:

  • (Integer)

    the durability of the sonic weapon.



147
148
149
# File 'lib/attributes/spellsong.rb', line 147

def self.sonicweapondurability
  self.sonicbladedurability
end

.swordcostArray<Integer>

Calculates the cost for the sword spell.

Examples:

Spellsong.swordcost

Returns:

  • (Array<Integer>)

    the cost of the sword spell.



363
364
365
# File 'lib/attributes/spellsong.rb', line 363

def self.swordcost
  [25, 15]
end

.syncString

Synchronizes the spellsong duration based on active bard spells.

Examples:

Spellsong.sync

Returns:

  • (String)

    message indicating the status of active bard spells.



14
15
16
17
18
# File 'lib/attributes/spellsong.rb', line 14

def self.sync
  timed_spell = Effects::Spells.to_h.keys.find { |k| k.to_s.match(/10[0-9][0-9]/) }
  return 'No active bard spells' if timed_spell.nil?
  @@renewed = Time.at(Time.now.to_f - self.timeleft.to_f + (Effects::Spells.time_left(timed_spell) * 60.to_f)) # duration
end

.timeleftFloat

Note:

Returns 0.0 if the character is not a Bard.

Calculates the remaining time left for the spellsong.

Examples:

Spellsong.timeleft

Returns:

  • (Float)

    the time left in minutes.



53
54
55
56
# File 'lib/attributes/spellsong.rb', line 53

def self.timeleft
  return 0.0 if Stats.prof != 'Bard'
  (self.duration - ((Time.now.to_f - @@renewed.to_f) % self.duration)) / 60.to_f
end

.tonisdodgebonusInteger

Calculates the dodge bonus for the tonis spell.

Examples:

Spellsong.tonisdodgebonus

Returns:

  • (Integer)

    the tonis dodge bonus.



216
217
218
219
220
221
# File 'lib/attributes/spellsong.rb', line 216

def self.tonisdodgebonus
  thresholds = [1, 2, 3, 5, 8, 10, 14, 17, 21, 26, 31, 36, 42, 49, 55, 63, 70, 78, 87, 96]
  bonus = 20
  thresholds.each { |val| if Skills.elair >= val then bonus += 1 end }
  bonus
end

.tonishastebonusInteger

Calculates the bonus for the tonis spell.

Examples:

Spellsong.tonishastebonus

Returns:

  • (Integer)

    the tonis haste bonus.



165
166
167
168
169
170
# File 'lib/attributes/spellsong.rb', line 165

def self.tonishastebonus
  bonus = -1
  thresholds = [30, 75]
  thresholds.each { |val| if Skills.elair >= val then bonus -= 1 end }
  bonus
end

.valorbonusInteger

Calculates the valor bonus based on the bard’s level and spells.

Examples:

Spellsong.valorbonus

Returns:

  • (Integer)

    the valor bonus.



291
292
293
# File 'lib/attributes/spellsong.rb', line 291

def self.valorbonus
  10 + (([Spells.bard, Stats.level].min - 10) / 2).round
end

.valorcostArray<Integer>

Calculates the cost for the valor spell.

Examples:

Spellsong.valorcost

Returns:

  • (Array<Integer>)

    the cost of the valor spell.



300
301
302
# File 'lib/attributes/spellsong.rb', line 300

def self.valorcost
  [10 + (self.valorbonus / 2), 3 + (self.valorbonus / 5)]
end

.weaponcostArray<Integer>

Calculates the cost for the weapon spell.

Examples:

Spellsong.weaponcost

Returns:

  • (Array<Integer>)

    the cost of the weapon spell.



345
346
347
# File 'lib/attributes/spellsong.rb', line 345

def self.weaponcost
  [12, 4]
end