diff --git a/module/rolldata-ajustements.js b/module/rolldata-ajustements.js index 457c9153..df601186 100644 --- a/module/rolldata-ajustements.js +++ b/module/rolldata-ajustements.js @@ -64,19 +64,19 @@ export const referenceAjustements = { }, encTotal: { isVisible: (rollData, actor) => RdDCarac.isAgiliteOuDerobee(rollData.selectedCarac) && RdDItemCompetence.isMalusEncombrementTotal(rollData.competence), - isUsed: (rollData, actor) => !rollData.oeuvre && RdDCarac.isAgiliteOuDerobee(rollData.selectedCarac) && RdDItemCompetence.isMalusEncombrementTotal(rollData.competence) && rollData.use.encTotal, + isUsed: (rollData, actor) => !rollData.oeuvre && RdDCarac.isAgiliteOuDerobee(rollData.selectedCarac) && RdDItemCompetence.isMalusEncombrementTotal(rollData.competence) && rollData.use?.encTotal, getLabel: (rollData, actor) => 'Encombrement total', getValue: (rollData, actor) => -actor.getEncTotal() }, surenc: { isVisible: (rollData, actor) => RdDCarac.isActionPhysique(rollData.selectedCarac) && actor.isSurenc(), - isUsed: (rollData, actor) => rollData.use?.surenc && RdDCarac.isActionPhysique(rollData.selectedCarac), + isUsed: (rollData, actor) => rollData.use.surenc && RdDCarac.isActionPhysique(rollData.selectedCarac), getLabel: (rollData, actor) => 'Sur-encombrement', getValue: (rollData, actor) => actor.computeMalusSurEncombrement() }, moral: { isVisible: (rollData, actor) => actor.isPersonnage() && RdDCarac.isActionPhysique(rollData.selectedCarac) && rollData.use?.moral, - isUsed: (rollData, actor) => rollData.use?.moral, + isUsed: (rollData, actor) => rollData.use.moral, getLabel: (rollData, actor) => 'Appel au moral', getValue: (rollData, actor) => 1 }, @@ -84,7 +84,7 @@ export const referenceAjustements = { isVisible: (rollData, actor) => actor.isPersonnage() && RdDCarac.isVolonte(rollData.selectedCarac), isUsed: (rollData, actor) => rollData.use.coeur != undefined, getLabel: (rollData, actor) => 'Ajustement de cœur', - getValue: (rollData, actor) => -2 * (rollData.use.coeur?.coeur ?? 0) + getValue: (rollData, actor) => -2 * (rollData.use?.coeur?.coeur ?? 0) }, moralTotal: { isUsed: (rollData, actor) => RdDCarac.isVolonte(rollData.selectedCarac), @@ -141,7 +141,7 @@ export const referenceAjustements = { getLabel: (rollData, actor) => "Force de l'alcool: ", getValue: (rollData, actor) => rollData.forceAlcool, }, - ethylisme:{ + ethylisme: { isVisible: (rollData, actor) => rollData.ethylisme != undefined, isUsed: (rollData, actor) => rollData.ethylisme != undefined, getLabel: (rollData, actor) => "Ethylisme - " + RdDUtility.getNomEthylisme(rollData.ethylisme), @@ -159,7 +159,9 @@ export class RollDataAjustements { /* -------------------------------------------- */ static calcul(rollData, actor) { - rollData.ajustements = {}; + // s'assurer de la correction des infos rollData + mergeObject(rollData, { ajustements: {}, use: {} }, { overwrite: false }) + for (var key in referenceAjustements) { const reference = referenceAjustements[key]; rollData.ajustements[key] = {