Module: Lich::Gemstone::Enhancive
- Defined in:
- documented/attributes/enhancive.rb
Overview
Access enhancive bonuses tracked on your character.
Provides singleton methods to query current stat, skill, resource, martial knowledge,
and spell enhancements granted by enhancive items. Data is stored in Infomon and
populated by the game parser. Call .refresh to trigger a full data update.
Constant Summary collapse
- STATS =
Stats - all 10 stats including influence
%i[strength constitution dexterity agility discipline aura logic intuition wisdom influence].freeze
- STAT_ABBREV =
Map of uppercase stat abbreviations to their symbol names.
{ 'STR' => :strength, 'CON' => :constitution, 'DEX' => :dexterity, 'AGI' => :agility, 'DIS' => :discipline, 'AUR' => :aura, 'LOG' => :logic, 'INT' => :intuition, 'WIS' => :wisdom, 'INF' => :influence }.freeze
- STAT_CAP =
40- BONUS_SKILLS =
Skills that appear as "Bonus" in output (same as Skills module list)
%i[ two_weapon_combat armor_use shield_use combat_maneuvers edged_weapons blunt_weapons two_handed_weapons ranged_weapons thrown_weapons polearm_weapons brawling ambush multi_opponent_combat physical_fitness dodging arcane_symbols magic_item_use spell_aiming harness_power elemental_mana_control mental_mana_control spirit_mana_control elemental_lore_air elemental_lore_earth elemental_lore_fire elemental_lore_water spiritual_lore_blessings spiritual_lore_religion spiritual_lore_summoning sorcerous_lore_demonology sorcerous_lore_necromancy mental_lore_divination mental_lore_manipulation mental_lore_telepathy mental_lore_transference mental_lore_transformation survival disarming_traps picking_locks stalking_and_hiding perception climbing swimming first_aid trading pickpocketing ].freeze
- SKILL_CAP =
50- RESOURCES =
Resources
%i[max_mana max_health max_stamina mana_recovery stamina_recovery].freeze
- RESOURCE_CAPS =
Maximum values that each resource can be enhanced to.
{ max_mana: 600, max_health: 300, max_stamina: 300, mana_recovery: 50, stamina_recovery: 50 }.freeze
- SKILL_NAME_MAP =
Mapping from game output names to internal names
{ 'Two Weapon Combat' => :two_weapon_combat, 'Armor Use' => :armor_use, 'Shield Use' => :shield_use, 'Combat Maneuvers' => :combat_maneuvers, 'Edged Weapons' => :edged_weapons, 'Blunt Weapons' => :blunt_weapons, 'Two-Handed Weapons' => :two_handed_weapons, 'Ranged Weapons' => :ranged_weapons, 'Thrown Weapons' => :thrown_weapons, 'Polearm Weapons' => :polearm_weapons, 'Brawling' => :brawling, 'Ambush' => :ambush, 'Multi Opponent Combat' => :multi_opponent_combat, 'Physical Fitness' => :physical_fitness, 'Dodging' => :dodging, 'Arcane Symbols' => :arcane_symbols, 'Magic Item Use' => :magic_item_use, 'Spell Aiming' => :spell_aiming, 'Harness Power' => :harness_power, 'Elemental Mana Control' => :elemental_mana_control, 'Mental Mana Control' => :mental_mana_control, 'Spirit Mana Control' => :spirit_mana_control, 'Elemental Lore - Air' => :elemental_lore_air, 'Elemental Lore - Earth' => :elemental_lore_earth, 'Elemental Lore - Fire' => :elemental_lore_fire, 'Elemental Lore - Water' => :elemental_lore_water, 'Spiritual Lore - Blessings' => :spiritual_lore_blessings, 'Spiritual Lore - Religion' => :spiritual_lore_religion, 'Spiritual Lore - Summoning' => :spiritual_lore_summoning, 'Sorcerous Lore - Demonology' => :sorcerous_lore_demonology, 'Sorcerous Lore - Necromancy' => :sorcerous_lore_necromancy, 'Mental Lore - Divination' => :mental_lore_divination, 'Mental Lore - Manipulation' => :mental_lore_manipulation, 'Mental Lore - Telepathy' => :mental_lore_telepathy, 'Mental Lore - Transference' => :mental_lore_transference, 'Mental Lore - Transformation' => :mental_lore_transformation, 'Survival' => :survival, 'Disarming Traps' => :disarming_traps, 'Picking Locks' => :picking_locks, 'Stalking and Hiding' => :stalking_and_hiding, 'Perception' => :perception, 'Climbing' => :climbing, 'Swimming' => :swimming, 'First Aid' => :first_aid, 'Trading' => :trading, 'Pickpocketing' => :pickpocketing }.freeze
- RESOURCE_NAME_MAP =
Map of game output display names to internal resource symbol names.
Used by the parser to convert "Max Mana", "Max Health", etc. from game output to internal symbols for storage in Infomon.
{ 'Max Mana' => :max_mana, 'Max Health' => :max_health, 'Max Stamina' => :max_stamina, 'Mana Recovery' => :mana_recovery, 'Stamina Recovery' => :stamina_recovery }.freeze
- MARTIAL_SKILL_CAP =
Martial Knowledge Skills (CMan-based enhancives) These appear as "+X ranks" in the output rather than bonus format Derived dynamically from CMan module at runtime to stay DRY
5- MARTIAL_SPECIAL_NAMES =
Special display name mappings for CMan skills with apostrophes These can't be auto-generated from the symbol name
{ :acrobats_leap => "Acrobat's Leap", :executioners_stance => "Executioner's Stance", :griffins_voice => "Griffin's Voice", :predators_eye => "Predator's Eye" }.freeze
Class Method Summary collapse
-
.active? ⇒ Boolean
ACTIVE STATE === Whether enhancives are currently active (toggled on).
-
.active_last_updated ⇒ Object
Returns Time when active state was last updated, or nil if never.
-
.health ⇒ OpenStruct
Convenience alias for
max_health. -
.item_count ⇒ Object
STATISTICS ACCESSORS ===.
-
.knows_spell?(spell_num) ⇒ Boolean
Check if enhancives grant knowledge of a specific spell.
-
.last_updated ⇒ Object
LAST UPDATED === Returns Time when enhancive data was last refreshed, or nil if never.
-
.mana ⇒ Object
Convenience aliases.
-
.martial_display_to_symbol(display_name) ⇒ Object
Convert display name to symbol (e.g., "Combat Focus" => :combat_focus).
-
.martial_skill(skill_symbol) ⇒ Object
MARTIAL KNOWLEDGE SKILL ACCESSORS === Dynamic accessor for any martial skill by symbol Returns OpenStruct with :ranks and :cap.
-
.martial_skills ⇒ Object
Get all martial skills with non-zero values Scans all CMan skills from the CMan module.
-
.martial_skills_list ⇒ Object
Get list of all martial skill symbols from CMan module Returns empty array if CMan not yet loaded.
-
.martial_symbol_to_display(symbol) ⇒ Object
Convert symbol to display name (e.g., :combat_focus => "Combat Focus").
-
.over_cap_skills ⇒ Object
Get all over-cap skills.
-
.over_cap_stats ⇒ Object
Get all over-cap stats.
-
.pauses ⇒ Object
Number of enhancive pauses available.
-
.property_count ⇒ Integer
Returns the number of unique enhancive properties currently active.
-
.refresh(silent: false, quiet: true) ⇒ Object
Blocks until complete.
-
.refresh_status(silent: false, quiet: true) ⇒ Object
Trigger refresh of active state and pauses only (lightweight) Blocks until complete.
-
.reset_all ⇒ Object
RESET METHOD (called by parser before populating new data) === Resets all enhancive values to 0/empty Critical because game output only shows non-zero values.
-
.skill_over_cap?(skill) ⇒ Boolean
Check if a skill is over cap.
-
.spells ⇒ Object
SPELL ACCESSORS === Returns array of spell numbers that enhancives grant self-knowledge of.
-
.stamina ⇒ OpenStruct
Convenience alias for
max_stamina. -
.stat_over_cap?(stat) ⇒ Boolean
UTILITY METHODS === Check if a stat is over cap.
-
.total_amount ⇒ Integer
Returns the total aggregate enhancive bonus value across all items and properties.
Class Method Details
.active? ⇒ Boolean
ACTIVE STATE ===
Whether enhancives are currently active (toggled on)
333 334 335 |
# File 'documented/attributes/enhancive.rb', line 333 def self.active? Infomon.get_bool("enhancive.active") end |
.active_last_updated ⇒ Object
Returns Time when active state was last updated, or nil if never
338 339 340 341 |
# File 'documented/attributes/enhancive.rb', line 338 def self.active_last_updated = Infomon.get_updated_at("enhancive.active") ? Time.at() : nil end |
.health ⇒ OpenStruct
Convenience alias for max_health.
287 288 289 |
# File 'documented/attributes/enhancive.rb', line 287 def self.health max_health end |
.item_count ⇒ Object
STATISTICS ACCESSORS ===
313 314 315 |
# File 'documented/attributes/enhancive.rb', line 313 def self.item_count Infomon.get("enhancive.stats.item_count").to_i end |
.knows_spell?(spell_num) ⇒ Boolean
Check if enhancives grant knowledge of a specific spell
308 309 310 |
# File 'documented/attributes/enhancive.rb', line 308 def self.knows_spell?(spell_num) spells.include?(spell_num.to_i) end |
.last_updated ⇒ Object
LAST UPDATED ===
Returns Time when enhancive data was last refreshed, or nil if never
350 351 352 353 |
# File 'documented/attributes/enhancive.rb', line 350 def self.last_updated = Infomon.get_updated_at("enhancive.stats.item_count") ? Time.at() : nil end |
.mana ⇒ Object
Convenience aliases
280 281 282 |
# File 'documented/attributes/enhancive.rb', line 280 def self.mana max_mana end |
.martial_display_to_symbol(display_name) ⇒ Object
Convert display name to symbol (e.g., "Combat Focus" => :combat_focus)
156 157 158 159 160 161 162 163 |
# File 'documented/attributes/enhancive.rb', line 156 def self.martial_display_to_symbol(display_name) # Check special names first (reverse lookup) special = MARTIAL_SPECIAL_NAMES.key(display_name) return special if special # Standard conversion: lowercase, replace spaces with underscores display_name.downcase.gsub(' ', '_').to_sym end |
.martial_skill(skill_symbol) ⇒ Object
MARTIAL KNOWLEDGE SKILL ACCESSORS ===
Dynamic accessor for any martial skill by symbol Returns OpenStruct with :ranks and :cap
265 266 267 268 269 270 |
# File 'documented/attributes/enhancive.rb', line 265 def self.martial_skill(skill_symbol) OpenStruct.new( ranks: Infomon.get("enhancive.martial.#{skill_symbol}").to_i, cap: MARTIAL_SKILL_CAP ) end |
.martial_skills ⇒ Object
Get all martial skills with non-zero values Scans all CMan skills from the CMan module
274 275 276 277 |
# File 'documented/attributes/enhancive.rb', line 274 def self.martial_skills martial_skills_list.select { |s| martial_skill(s).ranks > 0 } .map { |s| { name: s, ranks: martial_skill(s).ranks } } end |
.martial_skills_list ⇒ Object
Get list of all martial skill symbols from CMan module Returns empty array if CMan not yet loaded
167 168 169 170 171 |
# File 'documented/attributes/enhancive.rb', line 167 def self.martial_skills_list return [] unless defined?(Lich::Gemstone::CMan) Lich::Gemstone::CMan.cman_lookups.map { |cman| cman[:long_name].to_sym } end |
.martial_symbol_to_display(symbol) ⇒ Object
Convert symbol to display name (e.g., :combat_focus => "Combat Focus")
149 150 151 152 153 |
# File 'documented/attributes/enhancive.rb', line 149 def self.martial_symbol_to_display(symbol) return MARTIAL_SPECIAL_NAMES[symbol] if MARTIAL_SPECIAL_NAMES.key?(symbol) symbol.to_s.split('_').map(&:capitalize).join(' ') end |
.over_cap_skills ⇒ Object
Get all over-cap skills
373 374 375 |
# File 'documented/attributes/enhancive.rb', line 373 def self.over_cap_skills BONUS_SKILLS.select { |s| skill_over_cap?(s) rescue false } end |
.over_cap_stats ⇒ Object
Get all over-cap stats
368 369 370 |
# File 'documented/attributes/enhancive.rb', line 368 def self.over_cap_stats STATS.select { |s| stat_over_cap?(s) } end |
.pauses ⇒ Object
Number of enhancive pauses available
344 345 346 |
# File 'documented/attributes/enhancive.rb', line 344 def self.pauses Infomon.get("enhancive.pauses").to_i end |
.property_count ⇒ Integer
Returns the number of unique enhancive properties currently active.
320 321 322 |
# File 'documented/attributes/enhancive.rb', line 320 def self.property_count Infomon.get("enhancive.stats.property_count").to_i end |
.refresh(silent: false, quiet: true) ⇒ Object
Blocks until complete
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
# File 'documented/attributes/enhancive.rb', line 380 def self.refresh(silent: false, quiet: true) respond "Refreshing enhancive data..." unless quiet # First get status (active state + pauses) Lich::Util.issue_command( "invento enh", /^You are (?:currently|not currently|now|already|no longer)/, /<prompt/, include_end: true, timeout: 5, silent: silent, usexml: true, quiet: quiet ) # Then get full totals # TODO: Update start pattern once GM adds proper start message to invento enhancive totals # Current pattern is fragile - if player has no stat enhancives, output starts with Skills/Resources Lich::Util.issue_command( "invento enhancive totals", /^<pushBold\/>(?:Stats:|Skills:|Resources:)|^No enhancive item bonuses found\./, /<prompt/, include_end: true, timeout: 5, silent: silent, usexml: true, quiet: quiet ) respond "Enhancive data refreshed." unless quiet end |
.refresh_status(silent: false, quiet: true) ⇒ Object
Trigger refresh of active state and pauses only (lightweight) Blocks until complete
405 406 407 408 409 410 411 412 |
# File 'documented/attributes/enhancive.rb', line 405 def self.refresh_status(silent: false, quiet: true) Lich::Util.issue_command( "invento enh", /^You are (?:currently|not currently|now|already|no longer)/, /<prompt/, include_end: true, timeout: 5, silent: silent, usexml: true, quiet: quiet ) end |
.reset_all ⇒ Object
RESET METHOD (called by parser before populating new data) ===
Resets all enhancive values to 0/empty Critical because game output only shows non-zero values
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 |
# File 'documented/attributes/enhancive.rb', line 417 def self.reset_all batch = [] # Reset all stats to 0 STATS.each do |stat| batch.push(["enhancive.stat.#{stat}", 0]) end # Reset all skills to 0 BONUS_SKILLS.each do |skill| batch.push(["enhancive.skill.#{skill}.ranks", 0]) batch.push(["enhancive.skill.#{skill}.bonus", 0]) end # Reset all resources to 0 RESOURCES.each do |resource| batch.push(["enhancive.resource.#{resource}", 0]) end # Reset all martial knowledge skills to 0 # Uses CMan module to get full list of possible martial skills martial_skills_list.each do |skill| batch.push(["enhancive.martial.#{skill}", 0]) end # Reset spells to empty array batch.push(["enhancive.spells", ""]) # Reset statistics to 0 batch.push(["enhancive.stats.item_count", 0]) batch.push(["enhancive.stats.property_count", 0]) batch.push(["enhancive.stats.total_amount", 0]) Infomon.upsert_batch(batch) end |
.skill_over_cap?(skill) ⇒ Boolean
Check if a skill is over cap
362 363 364 365 |
# File 'documented/attributes/enhancive.rb', line 362 def self.skill_over_cap?(skill) s = send(skill) s.bonus > SKILL_CAP end |
.spells ⇒ Object
SPELL ACCESSORS ===
Returns array of spell numbers that enhancives grant self-knowledge of
300 301 302 303 304 305 |
# File 'documented/attributes/enhancive.rb', line 300 def self.spells raw = Infomon.get("enhancive.spells") return [] if raw.nil? || raw.empty? raw.to_s.split(',').map(&:to_i) end |
.stamina ⇒ OpenStruct
Convenience alias for max_stamina.
294 295 296 |
# File 'documented/attributes/enhancive.rb', line 294 def self.stamina max_stamina end |
.stat_over_cap?(stat) ⇒ Boolean
UTILITY METHODS ===
Check if a stat is over cap
357 358 359 |
# File 'documented/attributes/enhancive.rb', line 357 def self.stat_over_cap?(stat) send(stat).value > STAT_CAP end |