Module: Lich::Gemstone::Combat::Tracker
- Defined in:
- documented/gemstone/combat/tracker.rb
Overview
Combat tracking system
Main interface for the combat tracking system. Integrates with Lich’s Combat Tracker - Main interface for combat event processing Integrates with Lich’s game processing to track damage, wounds, and status effects
Constant Summary collapse
- DEFAULT_SETTINGS =
Default settings for combat tracking Default settings for combat tracking
{ enabled: false, # Disabled by default, user must enable track_damage: true, track_wounds: true, track_statuses: true, track_ucs: true, # Track UCS (position, tierup, smite) max_threads: 2, # Keep threading for performance debug: false, buffer_size: 200, # Increase for large combat chunks fallback_max_hp: 350, # Default max HP when template unavailable cleanup_interval: 100, # Cleanup creature registry every N chunks cleanup_max_age: 600 # Remove creatures older than N seconds (10 minutes) }.freeze
Class Attribute Summary collapse
-
.buffer ⇒ Object
readonly
Returns the value of attribute buffer.
-
.settings ⇒ Object
readonly
Returns the value of attribute settings.
Class Method Summary collapse
-
.combat_relevant?(line) ⇒ Boolean
Checks if a line of text is relevant to combat.
-
.configure(new_settings = {}) ⇒ void
Configures the combat tracker with new settings.
-
.debug? ⇒ Boolean
Checks if debug mode is enabled.
-
.disable! ⇒ void
Disables combat tracking.
-
.disable_debug! ⇒ void
Disables debug mode for combat tracking.
-
.enable! ⇒ void
Enables combat tracking.
-
.enable_debug! ⇒ void
Enables debug mode for combat tracking.
-
.enabled? ⇒ Boolean
Checks if combat tracking is enabled.
-
.fallback_hp ⇒ Integer
Retrieves the fallback maximum HP value.
-
.process(chunk) ⇒ void
Processes a chunk of combat data.
-
.set_fallback_hp(hp_value) ⇒ void
Sets the fallback maximum HP value.
-
.stats ⇒ Hash
Retrieves the current stats of the combat tracker.
Class Attribute Details
.buffer ⇒ Object (readonly)
Returns the value of attribute buffer.
48 49 50 |
# File 'documented/gemstone/combat/tracker.rb', line 48 def buffer @buffer end |
.settings ⇒ Object (readonly)
Returns the value of attribute settings.
48 49 50 |
# File 'documented/gemstone/combat/tracker.rb', line 48 def settings @settings end |
Class Method Details
.combat_relevant?(line) ⇒ Boolean
Checks if a line of text is relevant to combat
175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'documented/gemstone/combat/tracker.rb', line 175 def combat_relevant?(line) line.include?('swing') || line.include?('thrust') || line.include?('cast') || line.include?('gesture') || line.include?('points of damage') || line.include?('**') || # Flares line.include?('<pushBold/>') || # Creatures line.include?('AS:') || # Attack rolls line.include?('positioning against') || # UCS position line.include?('vulnerable to a followup') || # UCS tierup line.include?('crimson mist') || # UCS smite line.match?(/\b(?:hit|miss|parr|block|dodge)\b/i) end |
.configure(new_settings = {}) ⇒ void
This method returns an undefined value.
Configures the combat tracker with new settings
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'documented/gemstone/combat/tracker.rb', line 195 def configure(new_settings = {}) initialize! unless @initialized @settings.merge!(new_settings) # Save to Lich settings system for persistence save_settings # Reinitialize processor if thread count changed if new_settings.key?(:max_threads) shutdown_processor initialize_processor end respond "[Combat] Settings updated: #{@settings}" if debug? end |
.debug? ⇒ Boolean
Checks if debug mode is enabled
101 102 103 |
# File 'documented/gemstone/combat/tracker.rb', line 101 def debug? @settings[:debug] || $combat_debug end |
.disable! ⇒ void
This method returns an undefined value.
Disables combat tracking
82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'documented/gemstone/combat/tracker.rb', line 82 def disable! return unless @enabled initialize! unless @initialized @enabled = false @settings[:enabled] = false save_settings # Persist disabled state remove_downstream_hook shutdown_processor respond "[Combat] Combat tracking disabled" if debug? end |
.disable_debug! ⇒ void
This method returns an undefined value.
Disables debug mode for combat tracking
118 119 120 121 |
# File 'documented/gemstone/combat/tracker.rb', line 118 def disable_debug! configure(debug: false) respond "[Combat] Debug mode disabled" end |
.enable! ⇒ void
This method returns an undefined value.
Enables combat tracking
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'documented/gemstone/combat/tracker.rb', line 65 def enable! return if @enabled initialize! unless @initialized @enabled = true @settings[:enabled] = true # Force enabled in settings save_settings # Persist enabled state initialize_processor add_downstream_hook respond "[Combat] Combat tracking enabled" if debug? end |
.enable_debug! ⇒ void
This method returns an undefined value.
Enables debug mode for combat tracking
109 110 111 112 |
# File 'documented/gemstone/combat/tracker.rb', line 109 def enable_debug! configure(debug: true, enabled: true) respond "[Combat] Debug mode enabled" end |
.enabled? ⇒ Boolean
Checks if combat tracking is enabled
56 57 58 59 |
# File 'documented/gemstone/combat/tracker.rb', line 56 def enabled? initialize! unless @initialized @enabled && @settings[:enabled] end |
.fallback_hp ⇒ Integer
Retrieves the fallback maximum HP value
137 138 139 140 |
# File 'documented/gemstone/combat/tracker.rb', line 137 def fallback_hp initialize! unless @initialized @settings[:fallback_max_hp] end |
.process(chunk) ⇒ void
This method returns an undefined value.
Processes a chunk of combat data
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'documented/gemstone/combat/tracker.rb', line 147 def process(chunk) return unless enabled? return if chunk.empty? # Quick filter - only process if combat-related content present return unless chunk.any? { |line| combat_relevant?(line) } if @settings[:max_threads] > 1 @async_processor.process_async(chunk) else Processor.process(chunk) end # Periodic cleanup of old creature instances @chunks_processed += 1 if @chunks_processed >= @settings[:cleanup_interval] cleanup_creatures @chunks_processed = 0 end end |
.set_fallback_hp(hp_value) ⇒ void
This method returns an undefined value.
Sets the fallback maximum HP value
128 129 130 131 |
# File 'documented/gemstone/combat/tracker.rb', line 128 def set_fallback_hp(hp_value) configure(fallback_max_hp: hp_value.to_i) respond "[Combat] Fallback max HP set to #{hp_value}" end |
.stats ⇒ Hash
Retrieves the current stats of the combat tracker
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
# File 'documented/gemstone/combat/tracker.rb', line 215 def stats return { enabled: false } unless enabled? base_stats = { enabled: true, buffer_size: @buffer.size, settings: @settings } if @async_processor base_stats.merge(@async_processor.stats) else base_stats.merge(active: 0, total: 0) end end |