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
-
.command(entry, prefix, target = nil) ⇒ String
The command a society ability's
usesends, without sending it. -
.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 #member_of 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
.command(entry, prefix, target = nil) ⇒ String
The command a society ability's use sends, without sending it.
An entry with a :usage string sends that verb ("signal", "smite");
any other sends <prefix> <short_name> ("sign of striking"). A
GameObj or Integer target is appended as #id, a String as given.
150 151 152 153 154 155 |
# File 'documented/gemstone/society.rb', line 150 def self.command(entry, prefix, target = nil) base = entry[:usage] || "#{prefix} #{entry[:short_name]}" target = "##{target.id}" if target.respond_to?(:id) && !target.is_a?(String) target = "##{target}" if target.is_a?(Integer) "#{base} #{target}".strip end |
.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.).
Example:
"Symbol of Recognition" => `symbol_of_recognition`
"Kai's Strike" => `kais_strike`
170 171 172 173 174 175 176 177 178 |
# File 'documented/gemstone/society.rb', line 170 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.
95 96 97 98 99 |
# File 'documented/gemstone/society.rb', line 95 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.
109 110 111 112 113 114 115 116 117 118 |
# File 'documented/gemstone/society.rb', line 109 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 #member_of instead. Deprecated 6/2025
Returns The current society membership.
77 78 79 80 |
# File 'documented/gemstone/society.rb', line 77 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.
21 22 23 |
# File 'documented/gemstone/society.rb', line 21 def self.membership Infomon.get("society.status") end |
.rank ⇒ Integer
Retrieves the character's current rank within their society.
41 42 43 |
# File 'documented/gemstone/society.rb', line 41 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.
This allows society metadata fields such as :duration or :summary to be defined
as either static values or dynamically evaluated lambdas.
132 133 134 135 136 |
# File 'documented/gemstone/society.rb', line 132 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.
65 66 67 |
# File 'documented/gemstone/society.rb', line 65 def self.serialize [self.membership, self.rank] end |
.status ⇒ String?
Retrieves the character's society membership status.
33 34 35 |
# File 'documented/gemstone/society.rb', line 33 def self.status self.membership end |
.step ⇒ Integer
Use #rank instead. Deprecated 6/2025
Returns The current society rank.
86 87 88 89 |
# File 'documented/gemstone/society.rb', line 86 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.
57 58 59 |
# File 'documented/gemstone/society.rb', line 57 def self.task XMLData.society_task end |