Fix regression with re-tiering adversaries when dealing non-hp damage

This commit is contained in:
Carlos Fernandez 2026-03-06 05:09:43 -05:00
parent 54ee029d02
commit 154612ca7d

View file

@ -264,12 +264,12 @@ export default class DhpAdversary extends DhCreature {
} }
// Update damage in item actions // Update damage in item actions
// Parse damage, and convert all formula matches in the descriptions to the new damage
for (const action of Object.values(item.system.actions)) { for (const action of Object.values(item.system.actions)) {
if (!action.damage) continue;
// Parse damage, and convert all formula matches in the descriptions to the new damage
try { try {
const result = this.#adjustActionDamage(action, { ...damageMeta, type: 'action' }); const result = this.#adjustActionDamage(action, { ...damageMeta, type: 'action' });
if (!result) continue;
for (const { previousFormula, formula } of Object.values(result)) { for (const { previousFormula, formula } of Object.values(result)) {
const oldFormulaRegexp = new RegExp( const oldFormulaRegexp = new RegExp(
previousFormula.replace(' ', '').replace('+', '(?:\\s)?\\+(?:\\s)?') previousFormula.replace(' ', '').replace('+', '(?:\\s)?\\+(?:\\s)?')
@ -371,9 +371,11 @@ export default class DhpAdversary extends DhCreature {
/** /**
* Updates damage to reflect a specific value. * Updates damage to reflect a specific value.
* @throws if damage structure is invalid for conversion * @throws if damage structure is invalid for conversion
* @returns the converted formula and value as a simplified term * @returns the converted formula and value as a simplified term, or null if it doesn't deal HP damage
*/ */
#adjustActionDamage(action, damageMeta) { #adjustActionDamage(action, damageMeta) {
if (!action.damage?.parts.hitPoints) return null;
const result = {}; const result = {};
for (const property of ['value', 'valueAlt']) { for (const property of ['value', 'valueAlt']) {
const data = action.damage.parts.hitPoints[property]; const data = action.damage.parts.hitPoints[property];