mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-06-06 04:44:16 +02:00
Fixed so that replaceFormulaValue doesn't loose getter values
This commit is contained in:
parent
ccb0073cef
commit
49b5d2dcb0
1 changed files with 6 additions and 9 deletions
|
|
@ -189,17 +189,14 @@ export const getDeleteKeys = (property, innerProperty, innerPropertyDefaultValue
|
||||||
|
|
||||||
// Fix on Foundry native formula replacement for DH
|
// Fix on Foundry native formula replacement for DH
|
||||||
const nativeReplaceFormulaData = Roll.replaceFormulaData;
|
const nativeReplaceFormulaData = Roll.replaceFormulaData;
|
||||||
Roll.replaceFormulaData = function (formula, baseData = {}, { missing, warn = false } = {}) {
|
Roll.replaceFormulaData = function (formula, data = {}, { missing, warn = false } = {}) {
|
||||||
/* Inserting global data */
|
/* Inserting global data */
|
||||||
const data = {
|
const defaultingTypes = [
|
||||||
...baseData,
|
...Object.keys(CONFIG.DH.GENERAL.multiplierTypes).map(x => ({ term: x, default: 1 })),
|
||||||
partySize: game.actors?.party?.system.partyMembers.length ?? 0
|
{ term: 'partySize', default: game.actors?.party?.system.partyMembers.length ?? 0 }
|
||||||
};
|
];
|
||||||
|
|
||||||
const terms = Object.keys(CONFIG.DH.GENERAL.multiplierTypes).map(type => {
|
formula = defaultingTypes.reduce((a, c) => a.replaceAll(`@${c.term}`, data[c.term] ?? c.default), formula);
|
||||||
return { term: type, default: 1 };
|
|
||||||
});
|
|
||||||
formula = terms.reduce((a, c) => a.replaceAll(`@${c.term}`, data[c.term] ?? c.default), formula);
|
|
||||||
return nativeReplaceFormulaData(formula, data, { missing, warn });
|
return nativeReplaceFormulaData(formula, data, { missing, warn });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue