From 710a768bb61a004a4b50adcea6b7d596b2f5c9f0 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Wed, 21 Apr 2021 19:40:48 +0200 Subject: [PATCH] =?UTF-8?q?Rework=20jet=20=C3=A9thylisme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/actor.js | 3 ++- module/rdd-roll-ethylisme.js | 25 +++++++++++------------ templates/dialog-roll-ethylisme.html | 30 ++++++++++------------------ 3 files changed, 25 insertions(+), 33 deletions(-) diff --git a/module/actor.js b/module/actor.js index 66a9dedb..54d52034 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1590,7 +1590,8 @@ export class RdDActor extends Actor { etat: this.getEtatGeneral({ ethylisme: true }), diffNbDoses: -Number(actorData.data.compteurs.ethylisme.nb_doses || 0), finalLevel: 0, - diffConditions: 0 + diffConditions: 0, + ajustementsForce: CONFIG.RDD.difficultesLibres, } let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-ethylisme.html', rollData); new RdDRollDialogEthylisme(html, rollData, this, r => this.performEthylisme(r)).render(true); diff --git a/module/rdd-roll-ethylisme.js b/module/rdd-roll-ethylisme.js index 6eb77c34..0b4e636e 100644 --- a/module/rdd-roll-ethylisme.js +++ b/module/rdd-roll-ethylisme.js @@ -16,7 +16,7 @@ export class RdDRollDialogEthylisme extends Dialog { default: "rollButton", buttons: { "rollButton": { label: "Test d'éthylisme", callback: html => this.onButton(html) } } }; - let dialogOptions = { classes: ["rdddialog"], width: 400, height: 220, 'z-index': 99999 } + let dialogOptions = { classes: ["rdddialog"], width: 400, height: 270, 'z-index': 99999 } super(dialogConf, dialogOptions) //console.log("ETH", rollData); @@ -36,28 +36,27 @@ export class RdDRollDialogEthylisme extends Dialog { this.bringToTop(); // Ensure top level // Get the rollData stuff var rollData = this.rollData; - - function updateRollResult(rollData) { - - rollData.finalLevel = Number(rollData.etat) + Number(rollData.forceAlcool) + rollData.diffNbDoses; - - // Mise à jour valeurs - $("#roll-param").text(rollData.vieValue + " / " + Misc.toSignedString(rollData.finalLevel)); - $(".table-resolution").remove(); - $("#resolutionTable").append(RdDResolutionTable.buildHTMLTableExtract(rollData.vieValue, rollData.finalLevel)); - } + var dialog = this; // Setup everything onload $(function () { $("#forceAlcool").val(Misc.toInt(rollData.forceAlcool)); - updateRollResult(rollData); + dialog.updateRollResult(); }); // Update ! html.find('#forceAlcool').change((event) => { rollData.forceAlcool = Misc.toInt(event.currentTarget.value); // Update the selected bonus/malus - updateRollResult(rollData); + dialog.updateRollResult(); }); } + async updateRollResult() { + + this.rollData.finalLevel = Number(this.rollData.etat) + Number(this.rollData.forceAlcool) + this.rollData.diffNbDoses; + + // Mise à jour valeurs + $("#roll-param").text(this.rollData.vieValue + " / " + Misc.toSignedString(this.rollData.finalLevel)); + $(".table-resolution").remove(); + } } diff --git a/templates/dialog-roll-ethylisme.html b/templates/dialog-roll-ethylisme.html index af2aa4c6..4c07ddc9 100644 --- a/templates/dialog-roll-ethylisme.html +++ b/templates/dialog-roll-ethylisme.html @@ -1,27 +1,19 @@
- -
- - - -
- -
- +

Boire

+ Chope d'alcool +
+ + + + + +
- -
- -
- -
-
-