diff --git a/src/dndbeyond/base/monster.js b/src/dndbeyond/base/monster.js index ae7b480b..58b79329 100644 --- a/src/dndbeyond/base/monster.js +++ b/src/dndbeyond/base/monster.js @@ -472,7 +472,9 @@ class Monster extends CharacterBase { hit = description.slice(hit_idx); // Using match with global modifier then map to regular match because RegExp.matchAll isn't available on every browser const damage_regexp = new RegExp(/([\w]* )(?:([0-9]+)(?!d))?(?: *\(?([0-9]*d[0-9]+(?:\s*[-+]\s*[0-9]+)?(?: plus [^\)]+)?)\)?)? ([\w ]+?) damage/) + const healing_regexp = new RegExp(/gains (?:([0-9]+)(?!d))?(?: *\(?([0-9]*d[0-9]+(?:\s*[-+]\s*[0-9]+)?)(?: plus [^\)]+)?\)?)? (temporary)?\s*hit points/) const damage_matches = reMatchAll(damage_regexp, hit) || []; + const healing_matches = reMatchAll(healing_regexp, hit) || []; const damages = []; const damage_types = []; for (let dmg of damage_matches) { @@ -489,6 +491,14 @@ class Monster extends CharacterBase { damage_types.push(dmg[4]); } } + for (let dmg of healing_matches) { + const damage = dmg[2] || dmg[1]; + const healingType = dmg[3] ? "Temp HP" : "Healing" + if (damage) { + damages.push(damage.replace("plus", "+")); + damage_types.push(healingType); + } + } let save = null; const m = hit.match(/DC ([0-9]+) (.*?) saving throw/) let preDCDamages = damages.length;