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

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

Constant Summary collapse

POSITION_PATTERN =

Pattern for position updates - use .+ not .* Example: “You have good positioning against a kobold.” 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!” 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 .* 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 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 Pattern for smite removed

/^ *The crimson mist surrounding .+<a exist="([0-9]+)".+returns to an ethereal state/i.freeze

Class Method Summary collapse

Class Method Details

.parse(line) ⇒ Hash?

Parses a line of text to extract combat information.

This method matches the line against various patterns to determine the type of combat event and returns relevant data.

Examples:

Parsing a position update

result = UCS.parse("You have good positioning against a kobold.")
# => {:type=>:position, :target_id=>1, :value=>"good"}

Parameters:

  • line (String)

    The line of text to parse.

Returns:

  • (Hash, nil)

    A hash containing the parsed data or nil if no match is found.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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
# File 'documented/gemstone/combat/defs/ucs.rb', line 45

def parse(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