diff --git a/module/actor.js b/module/actor.js index cf25a7a0..fab38106 100644 --- a/module/actor.js +++ b/module/actor.js @@ -203,8 +203,12 @@ export class RdDActor extends Actor { return duplicate(list[0]); } - getEncombrementTotal() { - return this.encTotal ? Math.floor(this.encTotal) : 0 + getEncTotal() { + return Math.floor(this.encTotal ?? 0); + } + + getSurenc(){ + return this.data.data.compteurs?.surenc?.value ?? 0; } /* -------------------------------------------- */ diff --git a/module/rdd-roll.js b/module/rdd-roll.js index 11a9ad05..f81d4aa5 100644 --- a/module/rdd-roll.js +++ b/module/rdd-roll.js @@ -46,10 +46,10 @@ export class RdDRoll extends Dialog { malusArmureValue: actor.isPersonnage() ? actor.data.data.attributs?.malusarmure?.value ?? 0 : 0, surencMalusFlag: actor.isPersonnage() ? (actor.data.data.compteurs.surenc.value < 0) : false, surencMalusValue: actor.isPersonnage() ? actor.data.data.compteurs.surenc.value : 0, - surencMalusApply: false, + useMalusSurenc: false, isMalusEncombrementTotal: RdDItemCompetence.isMalusEncombrementTotal(rollData.competence), useMalusEncTotal: false, - encTotal: actor.getEncombrementTotal(), + encTotal: actor.getEncTotal(), ajustementAstrologique: actor.ajustementAstrologique(), surprise: actor.getSurprise() } @@ -127,7 +127,7 @@ export class RdDRoll extends Dialog { // Sort management if (rollData.selectedSort) { - rollData.bonus = RdDItemSort.getCaseBonus(rollData.selectedSort, rollData.coord), + rollData.bonus = RdDItemSort.getCaseBonus(rollData.selectedSort, rollData.coord); //console.log("Toggle show/hide", rollData.selectedSort); HtmlUtility._showControlWhen($("#div-sort-difficulte"), RdDItemSort.isDifficulteVariable(rollData.selectedSort)) HtmlUtility._showControlWhen($("#div-sort-ptreve"), RdDItemSort.isCoutVariable(rollData.selectedSort)) @@ -210,8 +210,8 @@ export class RdDRoll extends Dialog { this.rollData.tactique = event.currentTarget.value; updateRollResult(rollData); }); - html.find('#surencMalusApply').change((event) => { - this.rollData.surencMalusApply = event.currentTarget.checked; + html.find('#useMalusSurenc').change((event) => { + this.rollData.useMalusSurenc = event.currentTarget.checked; updateRollResult(rollData); }); html.find('#useMalusEncTotal').change((event) => { @@ -260,7 +260,7 @@ export class RdDRoll extends Dialog { _computeFinalLevel(rollData) { const etat = this._isIgnoreEtatGeneral(rollData) ? 0 : Misc.toInt(rollData.etat); const diffConditions = Misc.toInt(rollData.diffConditions); - const malusEnc = (rollData.surencMalusApply) ? rollData.surencMalusValue : 0; + const malusSurenc = (rollData.useMalusSurenc) ? rollData.surencMalusValue : 0; const bonusTactique = RdDBonus.bonusAttaque(rollData.tactique); const malusEncTotal = (rollData.useMalusEncTotal) ? -rollData.encTotal : 0; const ajustementChance = RdDResolutionTable.isAjustementAstrologique(rollData) ? rollData.ajustementAstrologique : 0; @@ -272,7 +272,7 @@ export class RdDRoll extends Dialog { const diffCompetence = this._computeDiffCompetence(rollData); const diffMoral = rollData.selectedCarac == this.actor.data.data.carac.volonte ? rollData.moral : 0; - return etat + diffCompetence + diffLibre + diffMoral + diffConditions + malusEnc + malusEncTotal + malusArmureValue + diffMeditation + ajustementChance + bonusTactique; + return etat + diffCompetence + diffLibre + diffMoral + diffConditions + malusSurenc + malusEncTotal + malusArmureValue + diffMeditation + ajustementChance + bonusTactique; } /* -------------------------------------------- */ diff --git a/templates/dialog-roll-surenc.html b/templates/dialog-roll-surenc.html index 5f43511c..ae07c1bf 100644 --- a/templates/dialog-roll-surenc.html +++ b/templates/dialog-roll-surenc.html @@ -1,6 +1,6 @@ {{#if surencMalusFlag}}