From c251727dea284f33d848d2cc51577ce273ec29c6 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sat, 1 May 2021 12:54:45 +0200 Subject: [PATCH] Aide tchat dans un dialogue --- module/rdd-commands.js | 32 ++++++++++++++------ templates/settings/dialog-aide-commands.html | 20 ++++++++++++ 2 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 templates/settings/dialog-aide-commands.html diff --git a/module/rdd-commands.js b/module/rdd-commands.js index bce05efc..a4b8bf85 100644 --- a/module/rdd-commands.js +++ b/module/rdd-commands.js @@ -165,11 +165,25 @@ export class RdDCommands { } /* -------------------------------------------- */ - help(msg, table = undefined) { + async help(msg) { + this.help(msg, undefined); + } + async help(msg, table) { let list = [] this._buildSubTableHelp(list, table || this.commandsTable); - const messageAide = list.reduce((a, b) => a + '
  • ' + b); - RdDCommands._chatAnswer(msg, `Commandes disponibles`); + + let html = await renderTemplate("systems/foundryvtt-reve-de-dragon/templates/settings/dialog-aide-commands.html", { commands: list }); + let d = new Dialog( + { + title: "Commandes disponibles dans le tchat", + content: html, + buttons: {}, + }, + { + width: 600, height: 500, + }); + + d.render(true); } /* -------------------------------------------- */ @@ -220,23 +234,23 @@ export class RdDCommands { } let actors = canvas.tokens.controlled.map(it => it.actor).filter(it => it); - if (actors && actors.length > 0){ + if (actors && actors.length > 0) { let length = params.length; - let diff = Number(params[length-1]); - if (Number.isInteger(Number(diff))){ - length --; + let diff = Number(params[length - 1]); + if (Number.isInteger(Number(diff))) { + length--; } else { diff = 0; } const caracName = params[0]; - const compName = length>1 ? params.slice(1, length).reduce((a, b) => `${a} ${b}`): undefined; + const compName = length > 1 ? params.slice(1, length).reduce((a, b) => `${a} ${b}`) : undefined; for (let actor of actors) { await actor.rollCaracCompetence(caracName, compName, diff); } return; } - else{ + else { ui.notifications.warn("Sélectionnez au moins un personnage pour lancer les dés") } } diff --git a/templates/settings/dialog-aide-commands.html b/templates/settings/dialog-aide-commands.html new file mode 100644 index 00000000..8d39f597 --- /dev/null +++ b/templates/settings/dialog-aide-commands.html @@ -0,0 +1,20 @@ +

    Dés spéciaux

    + +

    Commandes disponibles

    + \ No newline at end of file