From 93b8f15df0002e9f1b79238d008f77decc96e9c8 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Wed, 2 Jun 2021 16:14:41 +0200 Subject: [PATCH] Fix: ne pas utiliser DsN sans canvas MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit dice3d n'est pas dispo si on n'a pas de canvas dans dice-so-nice 3.4.0 Du coup, plantage et aucun jet dans le système RdD pour un joueur qui n'a pas de scène. Accessoirement, dice-so-nice 3.4.0 plante à l'init, mais ça on n'y peut rien (Issue raised) --- module/rdd-dice.js | 51 +++++++++++++++++++++++++++------------------- module/rdd-main.js | 2 +- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/module/rdd-dice.js b/module/rdd-dice.js index a93e3816..c60f12d2 100644 --- a/module/rdd-dice.js +++ b/module/rdd-dice.js @@ -123,8 +123,15 @@ export class RdDDice { CONFIG.Dice.terms[DeDraconique.DENOMINATION] = DeDraconique; CONFIG.Dice.terms[DeHeure.DENOMINATION] = DeHeure; } + static onReady() { + if (game.modules.get("dice-so-nice")?.active) { + if (game.settings.get("core", "noCanvas")) { + ui.notifications.warn("Dice So Nice! n'affichera pas de dés car vous avez coché l'option de Foundry 'Scène de jeu désactivé' 'Disable Game Canvas' "); + } + } + } - static async roll(formula, options = { showDice: false, rollMode: undefined}) { + static async roll(formula, options = { showDice: false, rollMode: undefined }) { const roll = new Roll(formula); await roll.evaluate({ async: true }); if (options.showDice) { @@ -141,7 +148,7 @@ export class RdDDice { static async rollOneOf(array) { const roll = await RdDDice.rollTotal(`1d${array.length}`); - return array[roll-1]; + return array[roll - 1]; } static diceSoNiceReady(dice3d) { @@ -153,7 +160,7 @@ export class RdDDice { } /* -------------------------------------------- */ - static async show(roll, rollMode = undefined) { + static async show(roll, rollMode) { if (roll.showDice || game.settings.get(SYSTEM_RDD, "dice-so-nice") == true) { await this.showDiceSoNice(roll, rollMode); } @@ -161,25 +168,27 @@ export class RdDDice { } /* -------------------------------------------- */ - static async showDiceSoNice(roll, rollMode = undefined) { - if (game.modules.get("dice-so-nice") && game.modules.get("dice-so-nice").active) { - let whisper = null; - let blind = false; - rollMode = rollMode ?? game.settings.get("core", "rollMode"); - switch (rollMode) { - case "blindroll": //GM only - blind = true; - case "gmroll": //GM + rolling player - whisper = ChatUtility.getUsers(user => user.isGM); - break; - case "roll": //everybody - whisper = ChatUtility.getUsers(user => user.active); - break; - case "selfroll": - whisper = [game.user.id]; - break; + static async showDiceSoNice(roll, rollMode) { + if (game.modules.get("dice-so-nice")?.active) { + if (game.dice3d) { + let whisper = null; + let blind = false; + rollMode = rollMode ?? game.settings.get("core", "rollMode"); + switch (rollMode) { + case "blindroll": //GM only + blind = true; + case "gmroll": //GM + rolling player + whisper = ChatUtility.getUsers(user => user.isGM); + break; + case "roll": //everybody + whisper = ChatUtility.getUsers(user => user.active); + break; + case "selfroll": + whisper = [game.user.id]; + break; + } + await game.dice3d.showForRoll(roll, game.user, true, whisper, blind); } - await game.dice3d.showForRoll(roll, game.user, true, whisper, blind); } } } \ No newline at end of file diff --git a/module/rdd-main.js b/module/rdd-main.js index c8e2ed2d..1496a5bb 100644 --- a/module/rdd-main.js +++ b/module/rdd-main.js @@ -214,7 +214,7 @@ Hooks.once("ready", function () { StatusEffects.onReady(); RdDHerbes.initializeHerbes(); - + RdDDice.onReady(); /* -------------------------------------------- */ /* Affiche/Init le calendrier */ let calendrier = new RdDCalendrier();