Module: Lich::Gemstone::Mana

Defined in:
documented/gemstone/mana.rb

Overview

Mana management utilities for the MANA PULSE verb (Mana Control).

Constant Summary collapse

PULSE_RESULT =

Matches all possible server responses to the MANA PULSE command.

Examples:

"An invigorating rush of mana pulses through you" =~ Mana::PULSE_RESULT #=> 0
"You're already at full mana." =~ Mana::PULSE_RESULT #=> 0

See Also:

Regexp.union(
  /^An invigorating rush of mana pulses through you/i,
  /^You are too mentally fatigued to attempt this ability/i,
  /^You're already at full mana\./i,
  /^Your mana control skills are not yet advanced/i,
).freeze
PULSED =

Matches the successful mana pulse server response.

Examples:

"An invigorating rush of mana pulses through you" =~ Mana::PULSED #=> 0

See Also:

/^An invigorating rush of mana pulses through you/i.freeze

Class Method Summary collapse

Class Method Details

.pulse(spell = nil, timeout: 2) ⇒ Boolean

Send MANA PULSE, optionally only when it would help cast a given spell.

Parameters:

  • spell (Integer, Spell, nil) (defaults to: nil) —

    when given, pulse only if the spell is known and not affordable right now

  • timeout (Numeric) (defaults to: 2)

Returns:

  • (Boolean) —

    true when mana was gained, false when the game refused, nothing confirmed, or the spell did not need it



44
45
46
47
48
49
50
51
52
53
# File 'documented/gemstone/mana.rb', line 44

def self.pulse(spell = nil, timeout: 2)
  unless spell.nil?
    spell = Spell[spell] unless spell.is_a?(Spell)
    return false if spell.nil? || !spell.known? || spell.affordable?
  end
  waitrt?
  result = dothistimeout('mana pulse', timeout, PULSE_RESULT)
  sleep 0.2
  result.to_s =~ PULSED ? true : false
end