Class: Lich::Gemstone::Warcry

Inherits:
Object
  • Object
show all
Defined in:
lib/gemstone/psms/warcry.rb

Overview

Represents a Warcry in the game.

Constant Summary collapse

@@warcries =
{
  "bellow" => {
    :regex => /You glare at .+ and let out a nerve-shattering bellow!/,
  },
  "yowlp"  => {
    :regex => /You throw back your shoulders and let out a resounding yowlp!/,
    :buff  => "Yertie's Yowlp",
  },
  "growl"  => {
    :regex => /Your face contorts as you unleash a guttural, deep-throated growl at .+!/,
  },
  "shout"  => {
    :regex => /You let loose an echoing shout!/,
    :buff  => 'Empowered (+20)',
  },
  "cry"    => {
    :regex => /You stare down .+ and let out an eerie, modulating cry!/,
  },
  "holler" => {
    :regex => /You throw back your head and let out a thundering holler!/,
    :buff  => 'Enh. Health (+20)',
  },
}

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Object

Retrieves the warcry associated with the given name.

Examples:

Warcry['bellow']
# => <Warcry object>

Parameters:

  • name (String)

    The short name of the warcry.

Returns:

  • (Object)

    The warcry object or nil if not found.



53
54
55
# File 'lib/gemstone/psms/warcry.rb', line 53

def Warcry.[](name)
  return PSMS.assess(name, 'Warcry')
end

.affordable?(name) ⇒ Boolean

Checks if the specified warcry is affordable.

Examples:

Warcry.affordable?('bellow')
# => true

Parameters:

  • name (String)

    The short name of the warcry.

Returns:

  • (Boolean)

    True if the warcry is affordable, false otherwise.



77
78
79
# File 'lib/gemstone/psms/warcry.rb', line 77

def Warcry.affordable?(name)
  return PSMS.assess(name, 'Warcry', true)
end

.available?(name, min_rank: 1) ⇒ Boolean

Checks if the specified warcry is available for use.

Examples:

Warcry.available?('bellow', min_rank: 1)
# => true

Parameters:

  • name (String)

    The short name of the warcry.

  • min_rank (Integer) (defaults to: 1)

    The minimum rank to check against (default is 1).

Returns:

  • (Boolean)

    True if the warcry is known, affordable, and not on cooldown or debuffed, false otherwise.



89
90
91
# File 'lib/gemstone/psms/warcry.rb', line 89

def Warcry.available?(name, min_rank: 1)
  Warcry.known?(name, min_rank: min_rank) and Warcry.affordable?(name) and !Lich::Util.normalize_lookup('Cooldowns', name) and !Lich::Util.normalize_lookup('Debuffs', 'Overexerted')
end

.buffActive?(name) ⇒ Boolean

Checks if the specified warcry’s buff is currently active.

Examples:

Warcry.buffActive?('yowlp')
# => false

Parameters:

  • name (String)

    The short name of the warcry.

Returns:

  • (Boolean)

    True if the buff is active, false otherwise.



100
101
102
103
104
# File 'lib/gemstone/psms/warcry.rb', line 100

def Warcry.buffActive?(name)
  buff = @@warcries.fetch(PSMS.name_normal(name))[:buff]
  return false if buff.nil?
  Lich::Util.normalize_lookup('Buffs', buff)
end

.known?(name, min_rank: 1) ⇒ Boolean

Checks if the specified warcry is known with a minimum rank.

Examples:

Warcry.known?('bellow', min_rank: 1)
# => true

Parameters:

  • name (String)

    The short name of the warcry.

  • min_rank (Integer) (defaults to: 1)

    The minimum rank to check against (default is 1).

Returns:

  • (Boolean)

    True if the warcry is known and meets the rank requirement, false otherwise.



65
66
67
68
# File 'lib/gemstone/psms/warcry.rb', line 65

def Warcry.known?(name, min_rank: 1)
  min_rank = 1 unless min_rank >= 1 # in case a 0 or below is passed
  Warcry[name] >= min_rank
end

.regexp(name) ⇒ Regexp

Retrieves the regex pattern associated with the specified warcry.

Examples:

Warcry.regexp('bellow')
# => /You glare at .+ and let out a nerve-shattering bellow!/

Parameters:

  • name (String)

    The short name of the warcry.

Returns:

  • (Regexp)

    The regex pattern for the warcry.



163
164
165
# File 'lib/gemstone/psms/warcry.rb', line 163

def Warcry.regexp(name)
  @@warcries.fetch(PSMS.name_normal(name))[:regex]
end

.use(name, target = "", results_of_interest: nil) ⇒ String?

Note:

This method will wait for roundtime and casting roundtime before executing.

Uses the specified warcry on a target.

Examples:

Warcry.use('bellow', 'target_name')
# => "You let out a nerve-shattering bellow!"

Parameters:

  • name (String)

    The short name of the warcry.

  • target (String, Integer, GameObj) (defaults to: "")

    The target of the warcry (optional).

  • results_of_interest (Regexp, nil) (defaults to: nil)

    Additional regex to match results (optional).

Returns:

  • (String, nil)

    The result of the warcry usage or nil if not used.



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/gemstone/psms/warcry.rb', line 116

def Warcry.use(name, target = "", results_of_interest: nil)
  return unless Warcry.available?(name)
  return if Warcry.buffActive?(name)
  name_normalized = PSMS.name_normal(name)
  technique = @@warcries.fetch(name_normalized)
  usage = name_normalized
  return if usage.nil?

  in_cooldown_regex = /^#{name} is still in cooldown\./i

  results_regex = Regexp.union(
    PSMS::FAILURES_REGEXES,
    /^#{name} what\?$/i,
    in_cooldown_regex,
    technique[:regex],
    /^Roundtime: [0-9]+ sec\.$/,
  )

  if results_of_interest.is_a?(Regexp)
    results_regex = Regexp.union(results_regex, results_of_interest)
  end

  usage_cmd = "warcry #{usage}"
  if target.is_a?(GameObj)
    usage_cmd += " ##{target.id}"
  elsif target.is_a?(Integer)
    usage_cmd += " ##{target}"
  elsif target != ""
    usage_cmd += " #{target}"
  end
  waitrt?
  waitcastrt?
  usage_result = dothistimeout(usage_cmd, 5, results_regex)
  if usage_result == "You don't seem to be able to move to do that."
    100.times { break if clear.any? { |line| line =~ /^You regain control of your senses!$/ }; sleep 0.1 }
    usage_result = dothistimeout(usage_cmd, 5, results_regex)
  end
  usage_result
end

.warcry_lookupsArray<Hash>

Provides a list of warcry lookups with their long names, short names, and costs.

Examples:

Warcry.warcry_lookups
# => [{ long_name: 'bertrandts_bellow', short_name: 'bellow', cost: 20 }, ...]

Returns:

  • (Array<Hash>)

    An array of hashes containing warcry details.



13
14
15
16
17
18
19
20
# File 'lib/gemstone/psms/warcry.rb', line 13

def self.warcry_lookups
  [{ long_name: 'bertrandts_bellow',        short_name: 'bellow',         cost: 20 }, # @todo only 10 for single
   { long_name: 'carns_cry',                short_name: 'cry',            cost: 20 },
   { long_name: 'gerrelles_growl',          short_name: 'growl',          cost: 14 }, # @todo only 7 for single
   { long_name: 'horlands_holler',          short_name: 'holler',         cost: 20 },
   { long_name: 'seanettes_shout',          short_name: 'shout',          cost: 20 },
   { long_name: 'yerties_yowlp',            short_name: 'yowlp',          cost: 10 }]
end