Resource/Uses max as FormulaField

This commit is contained in:
Dapoolp 2025-07-29 18:38:31 +02:00
parent 18aed3a9f0
commit a15028594d
13 changed files with 86 additions and 48 deletions

View file

@ -7,6 +7,7 @@ export default class RegisterHandlebarsHelpers {
includes: this.includes,
times: this.times,
damageFormula: this.damageFormula,
formulaValue: this.formulaValue,
damageSymbols: this.damageSymbols,
rollParsed: this.rollParsed,
hasProperty: foundry.utils.hasProperty,
@ -39,6 +40,15 @@ export default class RegisterHandlebarsHelpers {
return instances.join(traitTotal > 0 ? ' + ' : ' - ');
}
static formulaValue(formula, item) {
if(isNaN(formula)) {
const data = item.getRollData.bind(item)(),
roll = new Roll(Roll.replaceFormulaData(formula, data)).evaluateSync();
formula = roll.total;
}
return formula;
}
static damageSymbols(damageParts) {
const symbols = [...new Set(damageParts.reduce((a, c) => a.concat([...c.type]), []))].map(
p => CONFIG.DH.GENERAL.damageTypes[p].icon