Skip to content

Commit

Permalink
Merge pull request #1096 from ofMoons/master
Browse files Browse the repository at this point in the history
  • Loading branch information
kakaroto authored Dec 12, 2023
2 parents 2fce281 + 957288d commit 121676a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/dndbeyond/base/monster.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down

0 comments on commit 121676a

Please sign in to comment.