Class: Lich::Gemstone::Spellsong

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

Overview

Represents a spellsong in the Lich game.

This class manages the duration and effects of bard spells.

See Also:

Class Method Summary collapse

Class Method Details

.armorcostArray<Integer>

Returns the armor cost for spells.

Returns:

  • (Array<Integer>)

    an array containing the armor cost values



254
255
256
# File 'documented/attributes/spellsong.rb', line 254

def self.armorcost
  [14, 5]
end

.costInteger

Returns the cost associated with renewing spells.

Returns:

  • (Integer)

    the renewal cost



155
156
157
# File 'documented/attributes/spellsong.rb', line 155

def self.cost
  self.renew_cost
end

.depressionpushdownInteger

Calculates the push down effect of the depression spell.

Returns:

  • (Integer)

    the push down value



134
135
136
# File 'documented/attributes/spellsong.rb', line 134

def self.depressionpushdown
  20 + Skills.mltelepathy
end

.depressionslowInteger

Calculates the slow effect of the depression spell.

Returns:

  • (Integer)

    the slow value



140
141
142
143
144
145
# File 'documented/attributes/spellsong.rb', line 140

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 total duration of the spellsong based on various factors.

Returns:

  • (Float)

    the total duration in seconds



53
54
55
56
57
58
59
# File 'documented/attributes/spellsong.rb', line 53

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.

Parameters:

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

    the level of the bard

Returns:

  • (Integer)

    the base duration in seconds



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'documented/attributes/spellsong.rb', line 64

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>

Returns the fortitude cost for spells.

Returns:

  • (Array<Integer>)

    an array containing the fortitude cost values



236
237
238
# File 'documented/attributes/spellsong.rb', line 236

def self.fortcost
  [3, 1]
end

.holdingtargetsInteger

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

Returns:

  • (Integer)

    the number of holding targets



149
150
151
# File 'documented/attributes/spellsong.rb', line 149

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

.luckcostArray<Integer>

Calculates the cost associated with the luck spell.

Returns:

  • (Array<Integer>)

    an array containing the cost values



224
225
226
# File 'documented/attributes/spellsong.rb', line 224

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

.manacostArray<Integer>

Returns the mana cost for spells.

Returns:

  • (Array<Integer>)

    an array containing the mana cost values



230
231
232
# File 'documented/attributes/spellsong.rb', line 230

def self.manacost
  [18, 15]
end

.mirrorscostArray<Integer>

Calculates the cost associated with the mirrors spell.

Returns:

  • (Array<Integer>)

    an array containing the cost values



176
177
178
# File 'documented/attributes/spellsong.rb', line 176

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.

Returns:

  • (Integer)

    the dodge bonus value



170
171
172
# File 'documented/attributes/spellsong.rb', line 170

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

.renew_costInteger

Calculates the total cost to renew active bard spells.

Returns:

  • (Integer)

    total renewal cost



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'documented/attributes/spellsong.rb', line 83

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

.renewedvoid

This method returns an undefined value.

Updates the time when the spellsong was last renewed.



23
24
25
# File 'documented/attributes/spellsong.rb', line 23

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

.renewed=(val) ⇒ Object



27
28
29
# File 'documented/attributes/spellsong.rb', line 27

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

.renewed_atTime

Returns the last time the spellsong was renewed.

Returns:

  • (Time)

    the time of the last renewal



33
34
35
# File 'documented/attributes/spellsong.rb', line 33

def self.renewed_at
  @@renewed
end

.serializeFloat

Serializes the current state of the spellsong.

Returns:

  • (Float)

    the time left for the spellsong



47
48
49
# File 'documented/attributes/spellsong.rb', line 47

def self.serialize
  self.timeleft
end

.shieldcostArray<Integer>

Returns the shield cost for spells.

Returns:

  • (Array<Integer>)

    an array containing the shield cost values



242
243
244
# File 'documented/attributes/spellsong.rb', line 242

def self.shieldcost
  [9, 4]
end

.sonicarmorbonusInteger

Calculates the sonic armor bonus.

Returns:

  • (Integer)

    the sonic armor bonus value



188
189
190
# File 'documented/attributes/spellsong.rb', line 188

def self.sonicarmorbonus
  self.sonicbonus + 15
end

.sonicarmordurabilityInteger

Calculates the durability of the sonic armor.

Returns:

  • (Integer)

    the durability value



101
102
103
# File 'documented/attributes/spellsong.rb', line 101

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

.sonicbladebonusInteger

Calculates the sonic blade bonus.

Returns:

  • (Integer)

    the sonic blade bonus value



194
195
196
# File 'documented/attributes/spellsong.rb', line 194

def self.sonicbladebonus
  self.sonicbonus + 10
end

.sonicbladedurabilityInteger

Calculates the durability of the sonic blade.

Returns:

  • (Integer)

    the durability value



107
108
109
# File 'documented/attributes/spellsong.rb', line 107

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

.sonicbonusInteger

Calculates the sonic bonus based on bard level.

Returns:

  • (Integer)

    the sonic bonus value



182
183
184
# File 'documented/attributes/spellsong.rb', line 182

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

.sonicshieldbonusInteger

Calculates the sonic shield bonus.

Returns:

  • (Integer)

    the sonic shield bonus value



206
207
208
# File 'documented/attributes/spellsong.rb', line 206

def self.sonicshieldbonus
  self.sonicbonus + 10
end

.sonicshielddurabilityInteger

Calculates the durability of the sonic shield.

Returns:

  • (Integer)

    the durability value



119
120
121
# File 'documented/attributes/spellsong.rb', line 119

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

.sonicweaponbonusInteger

Returns the sonic weapon bonus.

Returns:

  • (Integer)

    the sonic weapon bonus value



200
201
202
# File 'documented/attributes/spellsong.rb', line 200

def self.sonicweaponbonus
  self.sonicbladebonus
end

.sonicweapondurabilityInteger

Returns the durability of the sonic weapon.

Returns:

  • (Integer)

    the durability value



113
114
115
# File 'documented/attributes/spellsong.rb', line 113

def self.sonicweapondurability
  self.sonicbladedurability
end

.swordcostArray<Integer>

Returns the sword cost for spells.

Returns:

  • (Array<Integer>)

    an array containing the sword cost values



260
261
262
# File 'documented/attributes/spellsong.rb', line 260

def self.swordcost
  [25, 15]
end

.syncString

Note:

Returns 'No active bard spells' if no timed spells are found.

Synchronizes the spellsong duration based on active bard spells.

Returns:

  • (String)

    message indicating the status of the synchronization



15
16
17
18
19
# File 'documented/attributes/spellsong.rb', line 15

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 current profession is not 'Bard'.

Calculates the remaining time left for the spellsong.

Returns:

  • (Float)

    remaining time in minutes



40
41
42
43
# File 'documented/attributes/spellsong.rb', line 40

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.

Returns:

  • (Integer)

    the dodge bonus value



161
162
163
164
165
166
# File 'documented/attributes/spellsong.rb', line 161

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 haste bonus for the tonis spell.

Returns:

  • (Integer)

    the haste bonus value



125
126
127
128
129
130
# File 'documented/attributes/spellsong.rb', line 125

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 bard level.

Returns:

  • (Integer)

    the valor bonus value



212
213
214
# File 'documented/attributes/spellsong.rb', line 212

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

.valorcostArray<Integer>

Calculates the cost associated with the valor spell.

Returns:

  • (Array<Integer>)

    an array containing the cost values



218
219
220
# File 'documented/attributes/spellsong.rb', line 218

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

.weaponcostArray<Integer>

Returns the weapon cost for spells.

Returns:

  • (Array<Integer>)

    an array containing the weapon cost values



248
249
250
# File 'documented/attributes/spellsong.rb', line 248

def self.weaponcost
  [12, 4]
end