From d524dc35cea22f288dd5ccea402a5f7c38efdd18 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Tue, 12 Jan 2021 01:08:03 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20table=20r=C3=A9solution?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/rdd-roll-resolution-table.js | 50 +++++++++++++-------------- templates/dialog-roll-resolution.html | 2 -- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/module/rdd-roll-resolution-table.js b/module/rdd-roll-resolution-table.js index 6603babc..e988da68 100644 --- a/module/rdd-roll-resolution-table.js +++ b/module/rdd-roll-resolution-table.js @@ -70,44 +70,44 @@ export class RdDRollResolutionTable extends Dialog { this.bringToTop(); - var rollData = this.rollData; var dialog = this; - function updateRollResult(rollData) { - rollData.caracValue = parseInt(rollData.selectedCarac.value) - rollData.finalLevel = dialog._computeFinalLevel(rollData); - - // Mise à jour valeurs - $("#carac").val(rollData.caracValue); - $("#roll-param").text(rollData.selectedCarac.value + " / " + Misc.toSignedString(rollData.finalLevel)); - $(".table-resolution").remove(); - $("#resolutionTable").append(RdDResolutionTable.buildHTMLTable(rollData.caracValue, rollData.finalLevel, 1, 20, -10, 10)); - $(".table-proba-reussite").remove(); - $("#tableProbaReussite").append(RdDResolutionTable.buildHTMLResults(rollData.caracValue, rollData.finalLevel)); - } - // Setup everything onload - $(function () { - $("#diffLibre").val(Misc.toInt(rollData.diffLibre)); - $("#diffConditions").val(Misc.toInt(rollData.diffConditions)); - updateRollResult(rollData); - }); - + function onLoad(){ + $("#diffLibre").val(Misc.toInt(dialog.rollData.diffLibre)); + $("#diffConditions").val(Misc.toInt(dialog.rollData.diffConditions)); + dialog.updateRollResult(); + } + $(function () { onLoad();}); + // Update ! html.find('#diffLibre').change((event) => { - rollData.diffLibre = Misc.toInt(event.currentTarget.value); - updateRollResult(rollData); + this.rollData.diffLibre = Misc.toInt(event.currentTarget.value); + this.updateRollResult(); }); html.find('#diffConditions').change((event) => { rollData.diffConditions = Misc.toInt(event.currentTarget.value); - updateRollResult(rollData); + this.updateRollResult(); }); html.find('#carac').change((event) => { let caracKey = event.currentTarget.value; - this.rollData.selectedCarac = rollData.carac[caracKey]; - updateRollResult(rollData); + this.rollData.selectedCarac = this.rollData.carac[caracKey]; + this.updateRollResult(); }); } + async updateRollResult() { + let rollData = this.rollData; + rollData.caracValue = parseInt(rollData.selectedCarac.value) + rollData.finalLevel = this._computeFinalLevel(rollData); + + // Mise à jour valeurs + $("#carac").val(rollData.caracValue); + $("#roll-param").text(rollData.selectedCarac.value + " / " + Misc.toSignedString(rollData.finalLevel)); + $(".table-resolution").remove(); + $(".table-proba-reussite").remove(); + $("#tableResolution").append(RdDResolutionTable.buildHTMLTable(rollData.caracValue, rollData.finalLevel)); + $("#tableProbaReussite").append(RdDResolutionTable.buildHTMLResults(rollData.caracValue, rollData.finalLevel)); + } /* -------------------------------------------- */ _computeFinalLevel(rollData) { diff --git a/templates/dialog-roll-resolution.html b/templates/dialog-roll-resolution.html index 34feacf4..cd6a5a3f 100644 --- a/templates/dialog-roll-resolution.html +++ b/templates/dialog-roll-resolution.html @@ -28,8 +28,6 @@ {{/select}} -
-