From 52fff9e79ec87ad0b478e7a5a3b87fd4dbe5c3f8 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Mon, 28 Jun 2021 20:19:02 +0200 Subject: [PATCH] =?UTF-8?q?#194=20:=20Saisie=20manuelle=20du=20r=C3=A9sult?= =?UTF-8?q?at?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/rdd-calendrier.js | 2 +- module/rdd-resolution-table.js | 9 ++++++--- module/rdd-roll.js | 7 ++++++- templates/dialog-competence.html | 7 +++++++ 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/module/rdd-calendrier.js b/module/rdd-calendrier.js index e4479202..d5c67c3c 100644 --- a/module/rdd-calendrier.js +++ b/module/rdd-calendrier.js @@ -213,7 +213,7 @@ export class RdDCalendrier extends Application { newList[i] = await this.ajouterNombreAstral(dayIndex, showDice ); } } - console.log("SAVE list", newList, jourCourant); + //console.log("SAVE list", newList, jourCourant); this.listeNombreAstral = newList; game.settings.set("foundryvtt-reve-de-dragon", "liste-nombre-astral", this.listeNombreAstral); } diff --git a/module/rdd-resolution-table.js b/module/rdd-resolution-table.js index 2649d1fc..bb0a37c9 100644 --- a/module/rdd-resolution-table.js +++ b/module/rdd-resolution-table.js @@ -114,7 +114,7 @@ export class RdDResolutionTable { chances.showDice = rollData.showDice; chances.rollMode = rollData.rollMode; - let rolled = await this.rollChances(chances, rollData.diviseurSignificative); + let rolled = await this.rollChances(chances, rollData.diviseurSignificative, rollData.forceDiceResult); rolled.caracValue = caracValue; rolled.finalLevel = finalLevel; rolled.bonus = rollData.bonus; @@ -163,8 +163,11 @@ export class RdDResolutionTable { } /* -------------------------------------------- */ - static async rollChances(chances, diviseur) { - chances.roll = await RdDDice.rollTotal("1d100", chances); + static async rollChances(chances, diviseur, forceDiceResult = -1) { + if (forceDiceResult <= 0 || forceDiceResult > 100) { + forceDiceResult = -1; + } + chances.roll = await RdDDice.rollTotal((forceDiceResult == -1) ? "1d100" : `${forceDiceResult}`, chances); mergeObject(chances, this.computeReussite(chances, chances.roll, diviseur), { overwrite: true }); return chances; } diff --git a/module/rdd-roll.js b/module/rdd-roll.js index ac756586..335c2082 100644 --- a/module/rdd-roll.js +++ b/module/rdd-roll.js @@ -61,7 +61,9 @@ export class RdDRoll extends Dialog { encTotal: actor.getEncTotal(), ajustementAstrologique: actor.ajustementAstrologique(), surprise: actor.getSurprise(false), - canClose: true + canClose: true, + isGM: game.user.isGM, + forceDiceResult: -1 }; mergeObject(rollData, defaultRollData, { recursive: true, overwrite: false }); @@ -189,6 +191,9 @@ export class RdDRoll extends Dialog { this.rollData.diffConditions = Misc.toInt(event.currentTarget.value); // Update the selected bonus/malus this.updateRollResult(); }); + html.find('#force-dice-result').change((event) => { + this.rollData.forceDiceResult = Misc.toInt(event.currentTarget.value); + }); html.find('#carac').change((event) => { let caracKey = event.currentTarget.value; this.rollData.selectedCarac = this.rollData.carac[caracKey]; // Update the selectedCarac diff --git a/templates/dialog-competence.html b/templates/dialog-competence.html index afc60424..9fe5f5c0 100644 --- a/templates/dialog-competence.html +++ b/templates/dialog-competence.html @@ -60,6 +60,13 @@ {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-surenc.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-enctotal.html"}} + + {{#if isGM}} +
+ +
+ {{/if}} +