Aide tchat dans un dialogue

This commit is contained in:
Vincent Vandemeulebrouck 2021-05-01 12:54:45 +02:00
parent c7ba56b90b
commit 8e565e3ca6
2 changed files with 43 additions and 9 deletions

View File

@ -166,11 +166,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 + '</li><li class="list-item">' + b);
RdDCommands._chatAnswer(msg, `Commandes disponibles<ul class="alterne-list"><li class="list-item">${messageAide}</li></ul>`);
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);
}
/* -------------------------------------------- */
@ -221,23 +235,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")
}
}

View File

@ -0,0 +1,20 @@
<h3>Dés spéciaux</h3>
<ul class="alterne-list">
<li class="list-item">
<strong>/roll 1d7</strong>: lance un dé de rencontre
</li>
<li class="list-item">
<strong>/roll 1dr</strong>: lance un dé draconique (de 0à 7, relance et additionne en cas de 7)
</li>
<li class="list-item">
<strong>/roll 1dh</strong>: lance le dé des heures (de 1 à 12)
</li>
</ul>
<h3>Commandes disponibles</h3>
<ul class="alterne-list">
{{#each commands as |command key|}}
<li class="list-item">
{{{command}}}
</li>
{{/each}}
</ul>