Module: Lich::Gemstone::Combat::Definitions::Damage
- Defined in:
- documented/gemstone/combat/defs/damage.rb
Constant Summary collapse
- BASIC_DAMAGE =
Core damage patterns - most common
[ /\.\.\. and hit for (?<damage>\d+) points? of damage!/, /\.\.\. (?<damage>\d+) points? of damage!/, /\.\.\. hits for (?<damage>\d+) points? of damage!/ ].freeze
- SPELL_DAMAGE =
Spell damage patterns
[ /Consumed by the hallowed flames, (?<target>.+?) is ravaged for (?<damage>\d+) points? of damage!/, /Wisps of black smoke swirl around (?<target>.+?) and it bursts into flame causing (?<damage>\d+) points? of damage!/ ].freeze
- ENVIRONMENTAL_DAMAGE =
Environmental/cyclone damage patterns
[ /The whirlwind quickly swirls around (?<target>.+?), causing (?<damage>\d+) points? of damage!/, /The flickering flames quickly swirl around (?<target>.+?), causing (?<damage>\d+) points? of damage!/, /The shifting stones quickly orbit (?<target>.+?), causing (?<damage>\d+) points? of damage!/ ].freeze
- ALL_DAMAGE =
All damage patterns combined
(BASIC_DAMAGE + SPELL_DAMAGE + ENVIRONMENTAL_DAMAGE).freeze
- DAMAGE_DETECTOR =
Compiled regex for fast detection
Regexp.union(ALL_DAMAGE).freeze
Class Method Summary collapse
-
.parse(line) ⇒ Object
Parse damage from line.
Class Method Details
.parse(line) ⇒ Object
Parse damage from line
40 41 42 43 44 45 46 47 48 49 |
# File 'documented/gemstone/combat/defs/damage.rb', line 40 def self.parse(line) ALL_DAMAGE.each do |pattern| if (match = pattern.match(line)) result = { damage: match[:damage].to_i } result[:target] = match[:target] if match.names.include?('target') && match[:target] return result end end nil end |