Class: Lich::Gemstone::Society
- Inherits:
-
Object
- Object
- Lich::Gemstone::Society
- 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.
Direct Known Subclasses
Lich::Gemstone::Societies::CouncilOfLight, Lich::Gemstone::Societies::GuardiansOfSunfist, Lich::Gemstone::Societies::OrderOfVoln
Class Method Summary collapse
-
.define_name_methods(target_class, data) ⇒ Object
Defines singleton accessors for both short and long names on a given target class.
-
.favor ⇒ Integer
deprecated
Deprecated.
Use OrderOfVoln.favor instead. Deprecated 6/2025
-
.lookup(name, lookups) ⇒ Hash?
Looks up an ability definition from a society hash using a normalized short or long name.
-
.member ⇒ String
deprecated
Deprecated.
Use #membership instead. Deprecated 6/2025
-
.membership ⇒ String?
Retrieves the character’s society membership status.
-
.rank ⇒ Integer
Retrieves the character’s current rank within their society.
-
.resolve(value, context = nil) ⇒ Object
Resolves a value that may be a static literal or a lambda/proc.
-
.serialize ⇒ Array<(String, Integer)>
Bundles the current society status and rank into a simple structure.
-
.status ⇒ String?
Retrieves the character’s society membership status.
-
.step ⇒ Integer
deprecated
Deprecated.
Use #rank instead. Deprecated 6/2025
-
.task ⇒ String
Retrieves the current task assigned by the society, if any.
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.).
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 |
.favor ⇒ Integer
Use OrderOfVoln.favor instead. Deprecated 6/2025
Returns 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.
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 |
.member ⇒ String
Use #membership instead. Deprecated 6/2025
Returns 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 |
.membership ⇒ String?
Retrieves the character’s society membership status.
23 24 25 |
# File 'documented/gemstone/society.rb', line 23 def self.membership Infomon.get("society.status") end |
.rank ⇒ Integer
Retrieves the character’s current rank within their society.
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.
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 |
.serialize ⇒ Array<(String, Integer)>
Bundles the current society status and rank into a simple structure.
71 72 73 |
# File 'documented/gemstone/society.rb', line 71 def self.serialize [self.membership, self.rank] end |
.status ⇒ String?
Retrieves the character’s society membership status.
36 37 38 |
# File 'documented/gemstone/society.rb', line 36 def self.status self.membership end |
.step ⇒ Integer
Use #rank instead. Deprecated 6/2025
Returns 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 |
.task ⇒ String
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.
62 63 64 |
# File 'documented/gemstone/society.rb', line 62 def self.task XMLData.society_task end |