Module: Lich::Gemstone::Combat::Definitions::UCS
- Defined in:
- documented/gemstone/combat/defs/ucs.rb
Overview
Definitions and parser for the Unarmed Combat System (UCS).
Provides patterns to match UCS combat events in game output and a parser to extract structured data: position tier changes, tierup vulnerabilities, and smite status updates (application and removal). Used to track combat mechanics in real-time.
Constant Summary collapse
- POSITION_PATTERN =
Pattern for position updates - use .+ not .* Example: "You have good positioning against a kobold."
/^You have (decent|good|excellent) positioning against.+<a exist="([0-9]+)"/i.freeze
- TIERUP_PATTERN =
Pattern for tierup vulnerability Example: "Strike leaves foe vulnerable to a followup jab attack!"
/Strike leaves foe vulnerable to a followup (jab|grapple|punch|kick) attack!/i.freeze
- SMITE_APPLIED_PATTERN =
Pattern for smite applied (crimson mist) Use .+ not .*
/^ *A crimson mist suddenly surrounds .+<a exist="([0-9]+)"/i.freeze
- SMITE_HELD_PATTERN =
Pattern for smite held in corporeal plane
/The crimson mist surrounding .+<a exist="([0-9]+)".+held in the corporeal plane/i.freeze
- SMITE_REMOVED_PATTERN =
Pattern for smite removed
/^ *The crimson mist surrounding .+<a exist="([0-9]+)".+returns to an ethereal state/i.freeze
- RELEVANT_SUBSTRINGS =
Literal substrings required by the patterns below - used as a cheap gate so non-UCS lines skip all five regexes.
['positioning against', 'vulnerable to a followup', 'crimson mist'].freeze
Class Method Summary collapse
-
.parse(line) ⇒ Object
Parse UCS-related events from a line Returns: { type: :position|:tierup|:smite_on|:smite_off, target_id: id, value: ... }.
-
.relevant?(line) ⇒ Boolean
Quick check whether a line could contain a UCS event.
Class Method Details
.parse(line) ⇒ Object
Parse UCS-related events from a line Returns: { type: :position|:tierup|:smite_on|:smite_off, target_id: id, value: ... }
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'documented/gemstone/combat/defs/ucs.rb', line 64 def parse(line) return nil unless relevant?(line) # Position update if (match = POSITION_PATTERN.match(line)) position = match[1] target_id = match[2].to_i return { type: :position, target_id: target_id, value: position } end # Tierup vulnerability if (match = TIERUP_PATTERN.match(line)) attack_type = match[1] return { type: :tierup, value: attack_type # Note: target_id comes from most recent target in combat context } end # Smite applied or held if (match = SMITE_APPLIED_PATTERN.match(line)) target_id = match[1].to_i return { type: :smite_on, target_id: target_id } end if (match = SMITE_HELD_PATTERN.match(line)) target_id = match[1].to_i return { type: :smite_on, target_id: target_id } end # Smite removed if (match = SMITE_REMOVED_PATTERN.match(line)) target_id = match[1].to_i return { type: :smite_off, target_id: target_id } end nil end |
.relevant?(line) ⇒ Boolean
Quick check whether a line could contain a UCS event
58 59 60 |
# File 'documented/gemstone/combat/defs/ucs.rb', line 58 def relevant?(line) RELEVANT_SUBSTRINGS.any? { |s| line.include?(s) } end |