Module: Lich::Gemstone::Effects

Defined in:
documented/gemstone/effects.rb

Defined Under Namespace

Classes: Registry

Constant Summary collapse

Spells =

A registry for active spells.

See Also:

Registry.new("Active Spells")
Buffs =

A registry for buffs.

See Also:

Registry.new("Buffs")
Debuffs =

A registry for debuffs.

See Also:

Registry.new("Debuffs")
Cooldowns =

A registry for cooldowns.

See Also:

Registry.new("Cooldowns")

Class Method Summary collapse

Class Method Details

.displayvoid

This method returns an undefined value.

Displays the current effects in a formatted table.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'documented/gemstone/effects.rb', line 78

def self.display
  effect_out = Terminal::Table.new :headings => ["ID", "Type", "Name", "Duration"]
  titles = ["Spells", "Cooldowns", "Buffs", "Debuffs"]
  existing_spell_nums = []
  active_spells = Spell.active
  active_spells.each { |s| existing_spell_nums << s.num }
  circle = nil
  [Effects::Spells, Effects::Cooldowns, Effects::Buffs, Effects::Debuffs].each { |effect|
    title = titles.shift
    id_effects = effect.to_h.select { |k, _v| k.is_a?(Integer) }
    text_effects = effect.to_h.reject { |k, _v| k.is_a?(Integer) }
    if id_effects.length != text_effects.length
      # has spell names disabled
      text_effects = id_effects
    end
    if id_effects.length == 0
      effect_out.add_row ["", title, "No #{title.downcase} found!", ""]
    else
      id_effects.each { |sn, end_time|
        stext = text_effects.shift[0]
        duration = ((end_time - Time.now) / 60.to_f)
        if duration < 0
          next
        elsif duration > 86400
          duration = "Indefinite"
        else
          duration = duration.as_time
        end
        if Spell[sn].circlename && circle != Spell[sn].circlename && title == 'Spells'
          circle = Spell[sn].circlename
        end
        effect_out.add_row [sn, title, stext, duration]
        existing_spell_nums.delete_if { |s| Spell[s].name =~ /#{Regexp.escape(stext)}/ || stext =~ /#{Regexp.escape(Spell[s].name)}/ || s == sn }
      }
    end
    effect_out.add_separator unless title == 'Debuffs' && existing_spell_nums.empty?
  }
  existing_spell_nums.each { |sn|
    effect_out.add_row [sn, "Other", Spell[sn].name, (Spell[sn].timeleft.as_time)]
  }
  Lich::Messaging.mono(effect_out.to_s)
end