Class: Lich::Gemstone::Society

Inherits:
Object
  • Object
show all
Defined in:
documented/gemstone/society.rb

Overview

The Society class provides accessors for a character’s society membership, rank, and task data.

All methods rely on Infomon or XMLData, and a future rewrite might shift responsibility to character-specific data models or direct game scraping.

Examples:

Accessing society information

membership = Lich::Gemstone::Society.membership

Class Method Summary collapse

Class Method Details

.define_name_methods(target_class, data) ⇒ Object

Defines singleton accessors for both short and long names on a given target class.

Method names are normalized using Util.normalize_name, which ensures compatibility with Ruby method naming (e.g., downcased, underscores instead of spaces, etc.).

Examples:

Defining name methods

Lich::Gemstone::Society.define_name_methods(SomeClass, data)

Parameters:

  • target_class (Class)

    The class to define singleton methods on (typically ‘self`)

  • data (Hash<String, Hash>)

    The metadata hash (e.g., ‘@@voln_symbols`)



152
153
154
155
156
157
158
159
160
# File 'documented/gemstone/society.rb', line 152

def self.define_name_methods(target_class, data)
  data.values.each do |entry|
    short_method = Lich::Util.normalize_name(entry[:short_name])
    long_method  = Lich::Util.normalize_name(entry[:long_name])

    target_class.define_singleton_method(short_method) { target_class[entry[:short_name]] }
    target_class.define_singleton_method(long_method)  { target_class[entry[:short_name]] }
  end
end

.favorInteger

Deprecated.

Use OrderOfVoln.favor instead. Deprecated 6/2025

Returns The amount of Voln favor.

Examples:

Getting deprecated favor

favor_amount = Lich::Gemstone::Society.favor

Returns:

  • (Integer)

    The amount of Voln favor



104
105
106
107
108
# File 'documented/gemstone/society.rb', line 104

def self.favor
  Lich.deprecated("Society.favor", "Society::OrderOfVoln.favor", caller[0], fe_log: false)
  # Infomon.get('resources.voln_favor')
  Societies::OrderOfVoln.favor
end

.lookup(name, lookups) ⇒ Hash?

Looks up an ability definition from a society hash using a normalized short or long name.

Examples:

Looking up an ability

ability = Lich::Gemstone::Society.lookup("Ability Name", lookups)

Parameters:

  • name (String)

    The user-facing name (short or long) of the ability

  • lookups (Hash<String, Hash>)

    The base hash keyed by short_name

Returns:

  • (Hash, nil)

    The matching entry from the base hash, or nil if not found



117
118
119
120
121
122
123
124
125
126
# File 'documented/gemstone/society.rb', line 117

def self.lookup(name, lookups)
  normalized = Lich::Util.normalize_name(name)

  lookups.find do |entry|
    [entry[:short_name], entry[:long_name]]
      .compact
      .map { |n| Lich::Util.normalize_name(n) }
      .include?(normalized)
  end
end

.memberString

Deprecated.

Use #membership instead. Deprecated 6/2025

Returns The current society membership.

Examples:

Getting deprecated membership

membership = Lich::Gemstone::Society.member

Returns:

  • (String)

    The current society membership



84
85
86
87
# File 'documented/gemstone/society.rb', line 84

def self.member
  Lich.deprecated("Society.member", "Society.membership", caller[0], fe_log: false)
  self.membership
end

.membershipString?

Retrieves the character’s society membership status.

Examples:

Getting membership status

society_name = Lich::Gemstone::Society.membership

Returns:

  • (String, nil)

    The name of the society:

    • “Order of Voln”

    • “Council of Light”

    • “Guardians of Sunfist”

    • or ‘nil`/“None” if not a member



23
24
25
# File 'documented/gemstone/society.rb', line 23

def self.membership
  Infomon.get("society.status")
end

.rankInteger

Retrieves the character’s current rank within their society.

Examples:

Getting rank

rank = Lich::Gemstone::Society.rank

Returns:

  • (Integer)

    The rank number, or 0 if not a member



45
46
47
# File 'documented/gemstone/society.rb', line 45

def self.rank
  Infomon.get("society.rank")
end

.resolve(value, context = nil) ⇒ Object

Resolves a value that may be a static literal or a lambda/proc.

If the value responds to ‘:call` (i.e., is a `Proc` or `lambda`), it is called and the result is returned. Otherwise, the value is returned as-is.

Examples:

Resolving a value

resolved_value = Lich::Gemstone::Society.resolve(value)

Parameters:

  • value (Object, Proc)

    The value to resolve

Returns:

  • (Object)

    The resolved value, or the original value if not callable



137
138
139
140
141
# File 'documented/gemstone/society.rb', line 137

def self.resolve(value, context = nil)
  return value.call if value.respond_to?(:call) && value.arity == 0
  return value.call(context) if value.respond_to?(:call) && value.arity == 1
  value
end

.serializeArray<(String, Integer)>

Bundles the current society status and rank into a simple structure.

Examples:

Serializing society data

data = Lich::Gemstone::Society.serialize

Returns:

  • (Array<(String, Integer)>)

    An array in the format ‘[status, rank]`



71
72
73
# File 'documented/gemstone/society.rb', line 71

def self.serialize
  [self.membership, self.rank]
end

.statusString?

Retrieves the character’s society membership status.

Examples:

Getting status

status = Lich::Gemstone::Society.status

Returns:

  • (String, nil)

    The name of the society:

    • “Order of Voln”

    • “Council of Light”

    • “Guardians of Sunfist”

    • or ‘nil`/“None” if not a member



36
37
38
# File 'documented/gemstone/society.rb', line 36

def self.status
  self.membership
end

.stepInteger

Deprecated.

Use #rank instead. Deprecated 6/2025

Returns The current society rank.

Examples:

Getting deprecated rank

rank = Lich::Gemstone::Society.step

Returns:

  • (Integer)

    The current society rank



94
95
96
97
# File 'documented/gemstone/society.rb', line 94

def self.step
  Lich.deprecated("Society.step", "Society.rank", caller[0], fe_log: false)
  self.rank
end

.taskString

Retrieves the current task assigned by the society, if any.

The current society task, or “You are not currently in a society.” if not a member, or “It is your eternal duty to release undead creatures from their suffering in the name of the Great Spirit Voln.” if a Voln Master.

Examples:

Getting current task

task_message = Lich::Gemstone::Society.task

Returns:

  • (String)

    The current society task message. Examples:

    • A task description

    • “You are not currently in a society.”

    • “It is your eternal duty to release undead creatures…” (Voln masters)



62
63
64
# File 'documented/gemstone/society.rb', line 62

def self.task
  XMLData.society_task
end