Module: Lich::Gemstone::Combat::Definitions::UCS

Defined in:
documented/gemstone/combat/defs/ucs.rb

Overview

Unarmed Combat System (UCS) tracking patterns and parser.

Provides regex patterns for detecting and parsing UCS events from game output: position tier changes, tierup vulnerabilities, and smite status changes. Methods are provided to check line relevance and parse events into structured event hashes with type, target ID, tier, and value fields.

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
POSITION_INBOUND_PATTERN =

Inbound mirror of POSITION_PATTERN: the creature's tier against US, printed as the second line of its UCS attack block (round-14 sweep: 40/40 sandwiched between the "attempts to jab you!" initiation and the UAF/UDF roll; only "decent" attested but the vocabulary is shared). Example: "The triton brawler has decent positioning against you."

/<a exist="([0-9]+)"[^>]*>[^<]+<\/a>(?:<popBold\/>)? has (decent|good|excellent) positioning against you\./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
POSITION_TIERS =

Positioning tier words -> ordinal, so the recorder can persist positioning as a number (its value column is numeric) and queries can compare outbound vs inbound tiers directly.

{ 'decent' => 1, 'good' => 2, 'excellent' => 3 }.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

Class Method Details

.parse(line) ⇒ Object

Parse UCS-related events from a line Returns: { type: :position|:position_inbound|:tierup|:smite_on|:smite_off, target_id: id, value: ... } Position types also carry tier: 1..3 (see POSITION_TIERS).



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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'documented/gemstone/combat/defs/ucs.rb', line 72

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,
      tier: POSITION_TIERS[position.downcase]
    }
  end

  # Creature's position against us (per-swing attack
  # metadata, not persistent state - it prints inside the
  # inbound UCS attack block)
  if (match = POSITION_INBOUND_PATTERN.match(line))
    position = match[2]
    return {
      type: :position_inbound,
      target_id: match[1].to_i,
      value: position,
      tier: POSITION_TIERS[position.downcase]
    }
  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

Returns:

  • (Boolean)


65
66
67
# File 'documented/gemstone/combat/defs/ucs.rb', line 65

def relevant?(line)
  RELEVANT_SUBSTRINGS.any? { |s| line.include?(s) }
end