Fixed rollData for actions and fallback for lookup enricher (#1472)

This commit is contained in:
WBHarry 2025-12-25 13:12:25 +01:00 committed by GitHub
parent 50a307b271
commit fa21baf8bf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 12 deletions

View file

@ -162,18 +162,16 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
* @returns {object}
*/
getRollData(data = {}) {
if (!this.actor) return null;
const actorData = this.actor.getRollData(false);
const actorData = this.actor ? this.actor.getRollData(false) : {};
// Add Roll results to RollDatas
actorData.result = data.roll?.total ?? 1;
actorData.scale = data.costs?.length // Right now only return the first scalable cost.
? (data.costs.find(c => c.scalable)?.total ?? 1)
: 1;
actorData.roll = {};
return actorData;
return {
...actorData,
result: data.roll?.total ?? 1,
scale: data.costs?.length // Right now only return the first scalable cost.
? (data.costs.find(c => c.scalable)?.total ?? 1)
: 1,
roll: {}
};
}
/**

View file

@ -3,6 +3,11 @@ import { parseInlineParams } from './parser.mjs';
export default function DhLookupEnricher(match, { rollData }) {
const results = parseInlineParams(match[1], { first: 'formula' });
const element = document.createElement('span');
element.textContent = Roll.replaceFormulaData(String(results.formula), rollData);
const lookupCommand = match[0];
const lookupParam = match[1];
const lookupText = Roll.replaceFormulaData(String(results.formula), rollData);
element.textContent = lookupText === lookupParam ? lookupCommand : lookupText;
return element;
}