Skip to content

Commit

Permalink
Setting the correct damage type for Temp HP gains.
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Dec 12, 2023
1 parent 1f6619c commit 36bca26
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/dndbeyond/base/monster.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ 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 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 = [];
Expand All @@ -493,9 +493,10 @@ class Monster extends CharacterBase {
}
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("Healing");
damage_types.push(healingType);
}
}
let save = null;
Expand Down

0 comments on commit 36bca26

Please sign in to comment.