Class: Lich::Gemstone::Societies::GuardiansOfSunfist

Inherits:
Lich::Gemstone::Society show all
Defined in:
documented/gemstone/societies/guardians_of_sunfist.rb

Overview

Represents the Guardians of Sunfist society.

This class provides methods to access and use sigils associated with the Guardians of Sunfist.

Constant Summary collapse

@@sunfist_sigils =
{
  "sigil_of_recognition"      => {
    rank: 1,
    short_name: "recognition",
    long_name: "Sigil of Recognition",
    type: :utility,
    spell_number: 9701,
    cost: { stamina: 0, mana: 0 },
    duration: nil,
    summary: "Detects members and/or foes of the Guardians of Sunfist in the same room."
  },
  "sigil_of_location"         => {
    rank: 2,
    short_name: "location",
    long_name: "Sigil of Location",
    spell_number: 9702,
    cost: { stamina: 0, mana: 0 },
    duration: nil,
    summary: "Detects nearby foes and warcamps; reveals paths to them."
  },
  "sigil_of_contact"          => {
    rank: 3,
    short_name: "contact",
    long_name: "Sigil of Contact",
    spell_number: 9703,
    cost: { stamina: 0, mana: 1 },
    duration: 1140, # 19 minutes
    summary: "Activates the ESP (amunet) network."
  },
  "sigil_of_resolve"          => {
    rank: 4,
    short_name: "resolve",
    long_name: "Sigil of Resolve",
    spell_number: 9704,
    cost: { stamina: 5, mana: 0 },
    duration: 90,
    summary: -> { "Increases Climbing, Swimming, and Survival skills equal to half current rank (#{(Society.rank / 2).floor}) for 90 seconds." }
  },
  "sigil_of_minor_bane"       => {
    rank: 5,
    short_name: "minor bane",
    long_name: "Sigil of Minor Bane",
    spell_number: 9705,
    cost: { stamina: 3, mana: 3 },
    duration: 60,
    summary: "Adds +5 AS (for any target) and grants heavy damage weighting (against foes) to melee, ranged and bolt attacks for 60 seconds."
  },
  "sigil_of_bandages"         => {
    rank: 6,
    short_name: "bandages",
    long_name: "Sigil of Bandages",
    spell_number: 9706,
    cost: { stamina: 10, mana: 0 },
    duration: 300,
    summary: "Allows you to perform actions with bandaged wounds that would normally break them for 5 minutes."
  },
  "sigil_of_defense"          => {
    rank: 7,
    short_name: "defense",
    long_name: "Sigil of Defense",
    spell_number: 9707,
    cost: { stamina: 5, mana: 5 },
    duration: 300,
    summary: -> { "Increases +1 DS per rank (#{Society.rank}) for 5 minutes." }
  },
  "sigil_of_offense"          => {
    rank: 8,
    short_name: "offense",
    long_name: "Sigil of Offense",
    spell_number: 9708,
    cost: { stamina: 5, mana: 5 },
    duration: 300,
    summary: -> { "Increases +1 AS per rank (#{Society.rank}) for 5 minutes." }
  },
  "sigil_of_distraction"      => {
    rank: 9,
    short_name: "distraction",
    long_name: "Sigil of Distraction",
    spell_number: 9709,
    cost: { stamina: 10, mana: 5 },  ## TODO: Figure out how to calc room version cost instead
    duration: nil,
    summary: "Decreases enemies' chances to evade, parry, and block."
  },
  "sigil_of_minor_protection" => {
    rank: 10,
    short_name: "minor protection",
    long_name: "Sigil of Minor Protection",
    spell_number: 9710,
    cost: { stamina: 10, mana: 5 },
    duration: 60,
    summary: "Adds +5 DS and grants heavy damage padding for 1 minute. Can be stacked up to 3 minutes."
  },
  "sigil_of_focus"            => {
    rank: 11,
    short_name: "focus",
    long_name: "Sigil of Focus",
    spell_number: 9711,
    cost: { stamina: 5, mana: 5 },
    duration: 60,
    summary: -> { "Increases +1 TD per rank (#{Society.rank}) for 1 minute. Can be stacked up to 3 minutes." }
  },
  "sigil_of_intimidation"     => {
    rank: 12,
    short_name: "intimidation",
    long_name: "Sigil of Intimidation",
    spell_number: 9712,
    cost: { stamina: 10, mana: 5 },
    duration: nil,
    summary: "Decreases enemies' AS/DS by 20."
  },
  "sigil_of_mending"          => {
    rank: 13,
    short_name: "mending",
    long_name: "Sigil of Mending",
    spell_number: 9713,
    cost: { stamina: 15, mana: 10 },
    duration: 600,
    summary: "Increases HP recovery by 15 and allows all healing herbs to be eaten in 3 seconds for 10 minutes."
  },
  "sigil_of_concentration"    => {
    rank: 14,
    short_name: "concentration",
    long_name: "Sigil of Concentration",
    spell_number: 9714,
    cost: { stamina: 30, mana: 0 },
    duration: 600,
    summary: "Increases mana recovery by +5 mana per pulse for 10 minutes."
  },
  "sigil_of_major_bane"       => {
    rank: 15,
    short_name: "major bane",
    long_name: "Sigil of Major Bane",
    spell_number: 9715,
    cost: { stamina: 10, mana: 10 },
    duration: 60,
    summary: "Adds +10 AS (all attacks) and grants heavy crit weighting to attacks (against foes) for 1 minute."
  },
  "sigil_of_determination"    => {
    rank: 16,
    short_name: "determination",
    long_name: "Sigil of Determination",
    spell_number: 9716,
    cost: { stamina: 30, mana: 0 },
    duration: 300,
    summary: "Ignores penalties while performing tasks when a character has injuries for 5 minutes."
  },
  "sigil_of_health"           => {
    rank: 17,
    short_name: "health",
    long_name: "Sigil of Health",
    spell_number: 9717,
    cost: { stamina: 20, mana: 10 },
    duration: nil,
    summary: -> { "Instantly recover 15 HP or half of your lost HP, whichever is greater (right now: #{[((Char.max_health - Char.health) / 2), 15].max})." }
  },
  "sigil_of_power"            => {
    rank: 18,
    short_name: "power",
    long_name: "Sigil of Power",
    spell_number: 9718,
    cost: { stamina: 50, mana: 0 },
    duration: nil,
    summary: "Convert 50 stamina to 25 mana."
  },
  "sigil_of_major_protection" => {
    rank: 19,
    short_name: "major protection",
    long_name: "Sigil of Major Protection",
    spell_number: 9719,
    cost: { stamina: 15, mana: 10 },
    duration: 60,
    summary: "Adds +10 DS and grants heavy crit padding for 1 minute. Can be stacked up to 3 minutes."
  },
  "sigil_of_escape"           => {
    rank: 20,
    short_name: "escape",
    long_name: "Sigil of Escape",
    spell_number: 9720,
    cost: { stamina: 75, mana: 15 }, ## TODO: figure out higher cost?
    duration: nil,
    summary: "Teleports you to a safe location. The emergency version can be used while stunned, bound, in RT, etc., at higher cost."
  }
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Lich::Gemstone::Society

define_name_methods, favor, lookup, member, membership, resolve, serialize, status, step, task

Class Method Details

.[](name) ⇒ Hash?

Retrieves the sigil metadata by its name.

Examples:

sigil = GuardiansOfSunfist["sigil_of_recognition"]
#=> retrieves the metadata for the Sigil of Recognition

Parameters:

  • name (String)

    the name of the sigil to retrieve

Returns:

  • (Hash, nil)

    the sigil metadata or nil if not found



205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'documented/gemstone/societies/guardians_of_sunfist.rb', line 205

def self.[](name)
  lookup = Society.lookup(name, sigil_lookups)
  return nil unless lookup

  key = lookup[:short_name]
  sigil = @@sunfist_sigils.values.find { |entry| entry[:short_name] == key }
  return nil unless sigil

  sigil.transform_values do |v|
    if v.respond_to?(:call)
      v.arity == 1 ? v.call(sigil) : v.call
    else
      v
    end
  end
end

.affordable?(sigil_name) ⇒ Boolean

Checks if the sigil can be afforded based on the member's resources.

Parameters:

  • sigil_name (String)

    the name of the sigil to check

Returns:

  • (Boolean)

    true if the sigil can be afforded, false otherwise



283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'documented/gemstone/societies/guardians_of_sunfist.rb', line 283

def self.affordable?(sigil_name)
  return false unless member?
  sigil = self[sigil_name]
  return false unless sigil

  cost = sigil[:cost] || {}
  stamina_cost = cost[:stamina].to_i
  mana_cost = cost[:mana].to_i

  unless stamina_cost.zero?
    return false unless Char.stamina >= stamina_cost
  end

  unless mana_cost.zero?
    return false unless Char.mana >= mana_cost
  end

  return true
end

.allArray<Hash>

Retrieves all sigils with their metadata.

Returns:

  • (Array<Hash>)

    an array of hashes containing all sigil metadata



317
318
319
# File 'documented/gemstone/societies/guardians_of_sunfist.rb', line 317

def self.all
  @@sunfist_sigils.values.map { |entry| entry.transform_values { |v| Society.resolve(v, entry) } }
end

.available?(sigil_name) ⇒ Boolean

Checks if a sigil is available for use based on membership and affordability.

Parameters:

  • sigil_name (String)

    the name of the sigil to check

Returns:

  • (Boolean)

    true if the sigil is available, false otherwise



308
309
310
311
# File 'documented/gemstone/societies/guardians_of_sunfist.rb', line 308

def self.available?(sigil_name)
  return false unless member?
  known?(sigil_name) && affordable?(sigil_name)
end

.known?(sigil_name) ⇒ Boolean

Checks if a sigil is known and accessible based on the member's rank.

Parameters:

  • sigil_name (String)

    the name of the sigil to check

Returns:

  • (Boolean)

    true if the sigil is known and accessible, false otherwise



242
243
244
245
246
247
248
# File 'documented/gemstone/societies/guardians_of_sunfist.rb', line 242

def self.known?(sigil_name)
  return false unless member?
  sigil = self[sigil_name]
  return false unless sigil

  sigil[:rank] <= self.rank
end

.master?Boolean

Checks if the current character is a master member of the Guardians of Sunfist.

Returns:

  • (Boolean)

    true if the character is a master, false otherwise



335
336
337
338
# File 'documented/gemstone/societies/guardians_of_sunfist.rb', line 335

def self.master?
  return false unless member?
  Society.rank == 20
end

.member?(rank = nil) ⇒ Boolean

Checks if the current character is a member of the Guardians of Sunfist.

Parameters:

  • rank (Integer, nil) (defaults to: nil)

    the rank to check against, or nil to check membership only

Returns:

  • (Boolean)

    true if the character is a member, false otherwise



326
327
328
329
# File 'documented/gemstone/societies/guardians_of_sunfist.rb', line 326

def self.member?(rank = nil)
  return false unless Society.membership == "Guardians of Sunfist"
  rank.nil? || Society.rank == rank
end

.rankInteger

Retrieves the rank of the current member of the Guardians of Sunfist.

Returns:

  • (Integer)

    the rank of the member, or 0 if not a member



344
345
346
347
# File 'documented/gemstone/societies/guardians_of_sunfist.rb', line 344

def self.rank
  return 0 unless member?
  Society.rank
end

.sigil_lookupsArray<Hash>

Provides a list of all sigil lookups with their metadata.

Returns:

  • (Array<Hash>)

    an array of hashes containing sigil metadata



226
227
228
229
230
231
232
233
234
235
# File 'documented/gemstone/societies/guardians_of_sunfist.rb', line 226

def self.sigil_lookups
  @@sunfist_sigils.map do |_, sigil|
    {
      long_name: sigil[:long_name],
      short_name: sigil[:short_name],
      rank: sigil[:rank],
      cost: sigil[:cost],
    }
  end
end

.use(sigil_name, target = nil) ⇒ void

This method returns an undefined value.

Uses a sigil on a target if the member is eligible.

Parameters:

  • sigil_name (String)

    the name of the sigil to use

  • target (String, nil) (defaults to: nil)

    the target for the sigil, if applicable



256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# File 'documented/gemstone/societies/guardians_of_sunfist.rb', line 256

def self.use(sigil_name, target = nil)
  unless member?
    Lich::Messaging.msg("error", "Not a member of Guardians of Sunfist, can't use: #{sigil_name}")
    return
  end
  sigil = self[sigil_name]

  unless sigil
    Lich::Messaging.msg("error", "Unknown sigil: #{sigil_name}")
    return
  end

  if available?(sigil_name)
    command = sigil[:usage] || "sigil of #{sigil[:short_name]}"
    waitrt?
    waitcastrt?
    fput "#{command} #{target}".strip
  else
    Lich::Messaging.msg("warn", "You cannot use the #{sigil_name} sigil right now.")
  end
end

Instance Method Details

#selfObject

Dynamically defines singleton methods for each Guardians of Sunfist sigil.

Each method allows accessing the sigil's metadata by calling either its short name or long name as a method. For example:

GuardiansOfSunfist.resolve        #=> metadata for Sigil of Resolve
GuardiansOfSunfist["Sigil of Resolve"] #=> same result

Dynamically defines singleton methods for each Guardians of Sunfist sigil.

Each method allows accessing the sigil's metadata by calling either its short name or long name as a method. For example:

GuardiansOfSunfist.resolve        #=> metadata for Sigil of Resolve
GuardiansOfSunfist["Sigil of Resolve"] #=> same result


365
# File 'documented/gemstone/societies/guardians_of_sunfist.rb', line 365

define_name_methods(self, @@sunfist_sigils)