From b54514a87909d46c8f8a3c15e43700675f164267 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Mon, 28 Dec 2020 00:45:24 +0100 Subject: [PATCH] Rituels - Ajust. astrologique #81 Ajout de l'ajustement astrologique sur les rituels Affichage de l'ajustement astrologique quand il s'applique --- module/rdd-roll.js | 27 +++++++++++++++++++-------- templates/dialog-competence.html | 6 ++++-- templates/dialog-roll-carac.html | 10 +++++----- templates/dialog-roll-sort.html | 14 ++++++-------- 4 files changed, 34 insertions(+), 23 deletions(-) diff --git a/module/rdd-roll.js b/module/rdd-roll.js index 27fbd436..46cbed5d 100644 --- a/module/rdd-roll.js +++ b/module/rdd-roll.js @@ -108,11 +108,9 @@ export class RdDRoll extends Dialog { var dialog = this; function updateRollResult(rollData) { - let caracValue = parseInt(rollData.selectedCarac.value) - let rollLevel = dialog._computeFinalLevel(rollData); rollData.dmg = rollData.attackerRoll ? rollData.attackerRoll.dmg : RdDBonus.dmg(rollData, actor.getBonusDegat()); - rollData.finalLevel = rollLevel; - rollData.caracValue = caracValue; + rollData.finalLevel = dialog._computeFinalLevel(rollData); + rollData.caracValue = parseInt(rollData.selectedCarac.value); rollData.coupsNonMortels = (rollData.attackerRoll ? rollData.attackerRoll.dmg.mortalite : rollData.dmg.mortalite) == 'non-mortel'; let dmgText = Misc.toSignedString(rollData.dmg.total); if (rollData.coupsNonMortels) { @@ -120,7 +118,10 @@ export class RdDRoll extends Dialog { } HtmlUtility._showControlWhen($(".diffMoral"), rollData.selectedCarac == actor.data.data.carac.volonte); - HtmlUtility._showControlWhen($(".etat-general"), !dialog._isIgnoreEtatGeneral(rollData)); + + HtmlUtility._showControlWhen($("#ajustements"), (!dialog._isIgnoreEtatGeneral(rollData)) || dialog._isAjustementAstrologique(rollData)); + HtmlUtility._showControlWhen($("#etat-general"), !dialog._isIgnoreEtatGeneral(rollData)); + HtmlUtility._showControlWhen($("#ajust-astrologique"), dialog._isAjustementAstrologique(rollData)); // Sort management if (rollData.selectedSort) { @@ -137,9 +138,9 @@ export class RdDRoll extends Dialog { $("#dmg-arme-actor").text(dmgText); $("#defenseur-surprise").text(RdDBonus.description(rollData.surpriseDefenseur)); $(".table-resolution").remove(); - $("#resolutionTable").append(RdDResolutionTable.buildHTMLTableExtract(caracValue, rollLevel)); + $("#resolutionTable").append(RdDResolutionTable.buildHTMLTableExtract(rollData.caracValue, rollData.finalLevel)); $(".span-valeur").remove(); - $("#resolutionValeurs").append(RdDResolutionTable.buildHTMLResults(caracValue, rollLevel)); + $("#resolutionValeurs").append(RdDResolutionTable.buildHTMLResults(rollData.caracValue, rollData.finalLevel)); } // Setup everything onload @@ -228,7 +229,7 @@ export class RdDRoll extends Dialog { const malusEnc = (rollData.surencMalusApply) ? rollData.surencMalusValue : 0; const bonusTactique = RdDBonus.bonusAttaque(rollData.tactique); const malusEncTotal = (rollData.useMalusEncTotal) ? -rollData.encTotal : 0; - const ajustementChance = rollData.selectedCarac.label.toLowerCase().includes('chance') ? rollData.ajustementAstrologique : 0; + const ajustementChance = this._isAjustementAstrologique(rollData) ? rollData.ajustementAstrologique : 0; // Gestion malus armure const malusArmureValue = this._computeMalusArmure(rollData); @@ -239,6 +240,16 @@ export class RdDRoll extends Dialog { return etat + diffCompetence + diffLibre + diffMoral + diffConditions + malusEnc + malusEncTotal + malusArmureValue + ajustementChance + bonusTactique; } + _isAjustementAstrologique(rollData) { + if (rollData.selectedCarac.label.toLowerCase().includes('chance')) { + return true; + } + if (rollData.selectedSort && rollData.selectedSort.data.isrituel) { + return true; + } + return false; + } + _computeDiffCompetence(rollData) { if (rollData.competence) { return Misc.toInt(rollData.competence.data.niveau); diff --git a/templates/dialog-competence.html b/templates/dialog-competence.html index a51923d0..01ea28dc 100644 --- a/templates/dialog-competence.html +++ b/templates/dialog-competence.html @@ -60,8 +60,10 @@ {{/if}}
- -     + + + +
{{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html"}} diff --git a/templates/dialog-roll-carac.html b/templates/dialog-roll-carac.html index bfaac5c0..10c4c40a 100644 --- a/templates/dialog-roll-carac.html +++ b/templates/dialog-roll-carac.html @@ -20,11 +20,11 @@ {{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html"}} -
- -
-
-     +
+ + + +
diff --git a/templates/dialog-roll-sort.html b/templates/dialog-roll-sort.html index 947e00b1..f539dac2 100644 --- a/templates/dialog-roll-sort.html +++ b/templates/dialog-roll-sort.html @@ -1,8 +1,6 @@
-

-
- +
@@ -59,11 +57,11 @@
-
- -
-
-     +
+ + + +