Module: Lich::Gemstone::Combat::Definitions::Resolutions
- Defined in:
- documented/gemstone/combat/defs/outcomes.rb
Overview
Parses combat resolution (roll) lines - the numeric line that decides an attack (AS/DS, CS/TD, UAF/UDF, SMR/SSR, and friends) - into a typed hash of its components.
Defined Under Namespace
Classes: ResolutionDef
Constant Summary collapse
- RESOLUTION_DEFS =
All resolution definitions, in match-priority order.
[ ResolutionDef.new(:as_ds, [ # optional "+ N +" term = True Strike bonus; the die is not # always d100 there either (d80, d40 at higher tiers) /AS: (?<as>[+\-\d]+) vs DS: (?<ds>[+\-\d]+) with AvD: (?<avd>[+\-\d]+) \+ (?:(?<bonus>\d+) \+ )?d\d+ roll: (?<roll>[+\-\d]+) = (?<result>[+\-\d]+)/ ].freeze), ResolutionDef.new(:cs_td, [ /CS: (?<cs>[+\-\d]+) - TD: (?<td>[+\-\d]+) \+ CvA: (?<cva>[+\-\d]+) \+ d\d+: (?<roll>[+\-\d]+) \+ Bonus: (?<bonus>[+\-\d]+) == (?<result>[+\-\d]+)/, # trailing "- N" modifier (Torment 718, Untrammel 209, Vertigo 1219) /CS: (?<cs>[+\-\d]+) - TD: (?<td>[+\-\d]+) \+ CvA: (?<cva>[+\-\d]+) \+ d\d+: (?<roll>[+\-\d]+)(?: - (?<penalty>[+\-\d]+))? == (?<result>[+\-\d]+)/ ].freeze), ResolutionDef.new(:uaf_udf, [ /UAF: (?<uaf>\d+) vs UDF: (?<udf>\d+) = (?<total>[.\d]+) \* MM: (?<mm>\d+) \+ d\d+: (?<roll>\d+) = (?<result>\d+)/ ].freeze), ResolutionDef.new(:smr, [ # Penalty term and negative results are both live (Rysk logs) /\[SMR result: (?<result>-?\d+) \(Open d100: (?<roll>[+\-\d]+)(?:, Bonus: (?<bonus>[+\-\d]+))?(?:, Penalt(?:y|ies): (?<penalty>[+\-\d]+))?\)\]/ ].freeze), # Standard Save Roll - follows intimidation/terrorize checks ResolutionDef.new(:ssr, [ /\[SSR result: (?<result>-?\d+) \(Open d100: (?<roll>[+\-\d]+)\)\]/ ].freeze), # Imbed/crystal activation roll - sits between a wand wave and # its spell cast ("1d100: 30 + Modifiers: 375 == 405"); gives # the otherwise fact-less :wand event its roll (round-6, from # the fury/divine_fury real-feed capture) ResolutionDef.new(:activation, [ /1d100: (?<roll>[+\-\d]+) \+ Modifiers: (?<mods>[+\-\d]+) == (?<result>[+\-\d]+)/ ].freeze), # Legacy maneuver roll (lowercase "open", no SMR prefix). Most # cmans were converted to SMR but the old format is kept as a # fallback - it costs one gate literal and catches stragglers. ResolutionDef.new(:maneuver_roll, [ /\[Roll result: (?<result>-?\d+) \(open d100: (?<roll>-?\d+)\)(?:,? (?:Bonus: (?<bonus>-?\d+)|Penalt(?:y|ies): (?<penalty>-?\d+)))?\]/ ].freeze), # Fear resolution (Sheer fear) - its own roll grammar entirely ResolutionDef.new(:fear, [ /FS: (?<fs>[+\-\d]+) - FD: (?<fd>[+\-\d]+) \+ FvP: (?<fvp>[+\-\d]+) \+ d100\(L\): (?<roll>[+\-\d]+) = (?<result>[+\-\d]+)/ ].freeze) ].freeze
- RESOLUTION_LOOKUP =
Flattened [pattern, type] pairs in definition order.
RESOLUTION_DEFS.flat_map { |d| d.patterns.map { |rx| [rx, d.type] } }.freeze
- CRIT_RIDER_PATTERNS =
Crit RIDER maneuvers: a leg/knockdown crit rolls an SMR of its own AFTER the damage settles, then prints the fall. That roll belongs to the hit that caused it, not to the next attack - without this it was orphaned into a synthetic :unknown attack against whatever creature was current (2026-09-07 hunt log, spectral_bloom leg crit on a skald -> "unknown" on the mastodon).
[ # (the pronoun is a link in the live feed - hunt log 2026-09-07 21:03) /Despite desperate windmilling to catch #{MK_PRE}(?:his|her|its|their)#{MK_POST} balance, .+? topples/ ].freeze
Class Method Summary collapse
-
.crit_rider_line?(line) ⇒ Boolean
True when it narrates a crit-knockdown rider.
-
.parse(line) ⇒ Hash?
Parses a single roll line into its numeric components.
Class Method Details
.crit_rider_line?(line) ⇒ Boolean
Returns true when it narrates a crit-knockdown rider.
467 468 469 |
# File 'documented/gemstone/combat/defs/outcomes.rb', line 467 def self.crit_rider_line?(line) CRIT_RIDER_PATTERNS.any? { |rx| rx.match?(line) } end |
.parse(line) ⇒ Hash?
Parses a single roll line into its numeric components.
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 |
# File 'documented/gemstone/combat/defs/outcomes.rb', line 478 def self.parse(line) return nil unless GATE.match?(line) || ALWAYS_SCAN.any? { |rx| rx.match?(line) } RESOLUTION_LOOKUP.each do |rx, type| next unless (match = rx.match(line)) result = { type: type } match.names.each do |cap| next unless match[cap] result[cap.to_sym] = match[cap].include?('.') ? match[cap].to_f : match[cap].to_i end return result end nil end |