From c1a5bd6eb3e92c794c2becf78c2bcf23f8ba5c66 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Mon, 20 Nov 2023 00:37:43 +0100 Subject: [PATCH] =?UTF-8?q?Fix:=20jets=20d'encaissement=20forc=C3=A9s=20pa?= =?UTF-8?q?r=20le=20Gardien?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Les jets d'encaissement forcés par le gardien ne peuvent plus donner le deuxième d10 négatif si le MJ force un résultat inférieur à 11 --- module/rdd-dice.js | 51 +++++++++++++--------------------------------- 1 file changed, 14 insertions(+), 37 deletions(-) diff --git a/module/rdd-dice.js b/module/rdd-dice.js index 7dd9fa22..e9f9dcc2 100644 --- a/module/rdd-dice.js +++ b/module/rdd-dice.js @@ -164,7 +164,7 @@ export class RdDDice { if (options.showDice == HIDE_DICE || !game.modules.get("dice-so-nice")?.active || !game.dice3d) { return; } - + let { whisper, blind } = RdDDice._getWhisperBlind(options); if (options.forceDiceResult?.total) { let terms = await RdDDice._getForcedTerms(options); @@ -197,48 +197,25 @@ export class RdDDice { function terms1d100(total) { const unites = total % 10; const dizaines = Math.floor(total / 10); - return [{ - resultLabel: dizaines * 10, - d100Result: total, - result: dizaines, - type: "d100", - vectors: [], - options: {} - }, - { - resultLabel: unites, - d100Result: total, - result: unites, - type: "d10", - vectors: [], - options: {} - }]; + return [ + { type: "d100", result: dizaines, resultLabel: dizaines * 10, vectors: [], options: {}, d100Result: total }, + { type: "d10", result: unites, resultLabel: unites, vectors: [], options: {}, d100Result: total } + ]; } async function terms2d10(total) { - if (total>20 || total<2) { return undefined } - let first = await RdDDice.d10(); - let second = Math.min(total-first, 10); - first = Math.max(first, total-second); - return [{ - resultLabel:first, - result: first, - type: "d10", - vectors: [], - options: {} - }, - { - resultLabel: second, - result: second, - type: "d10", - vectors: [], - options: {} - }]; + if (total > 20 || total < 2) { return undefined } + const first = await RdDDice.fakeD10(Math.min(10, total - 1)); + const second = total - first; + return [ + { type: "d10", result: first, resultLabel: first, vectors: [], options: {} }, + { type: "d10", result: second, resultLabel: second, vectors: [], options: {} } + ]; } } - static async d10() { - let roll = new Roll('1d10'); + static async fakeD10(faces) { + let roll = new Roll(`1d${faces}`); await roll.evaluate({ async: true }); return roll.total; }