Merge branch 'refactor/84-data-models-structure' into feature/109-LevelUp-Followup

This commit is contained in:
WBHarry 2025-06-13 14:14:02 +02:00
commit 7a090ea203
81 changed files with 2465 additions and 1032 deletions

View file

@ -122,14 +122,16 @@ export const getCommandTarget = () => {
return target;
};
export const setDiceSoNiceForDualityRoll = (rollResult, advantage, disadvantage) => {
export const setDiceSoNiceForDualityRoll = (rollResult, advantageState) => {
const diceSoNicePresets = getDiceSoNicePresets();
rollResult.dice[0].options.appearance = diceSoNicePresets.hope;
rollResult.dice[1].options.appearance = diceSoNicePresets.fear;
if (advantage) {
rollResult.dice[2].options.appearance = diceSoNicePresets.advantage;
} else if (disadvantage) {
rollResult.dice[2].options.appearance = diceSoNicePresets.disadvantage;
if (rollResult.dice[2]) {
if (advantageState === true) {
rollResult.dice[2].options.appearance = diceSoNicePresets.advantage;
} else if (advantageState === false) {
rollResult.dice[2].options.appearance = diceSoNicePresets.disadvantage;
}
}
};
@ -222,3 +224,14 @@ export const getDeleteKeys = (property, innerProperty, innerPropertyDefaultValue
return acc;
}, {});
};
// Fix on Foundry native formula replacement for DH
const nativeReplaceFormulaData = Roll.replaceFormulaData;
Roll.replaceFormulaData = function (formula, data, { missing, warn = false } = {}) {
const terms = [
{ term: 'prof', default: 1 },
{ term: 'cast', default: 1 }
];
formula = terms.reduce((a, c) => a.replaceAll(`@${c.term}`, data[c.term] ?? c.default), formula);
return nativeReplaceFormulaData(formula, data, { missing, warn });
};