Amelioration des commandes de tchat et aide

This commit is contained in:
2020-09-13 22:46:42 +02:00
parent 18be421ce5
commit cec65edb83
6 changed files with 89 additions and 22 deletions

View File

@ -1,6 +1,7 @@
/* Common useful functions shared between objects */
import { RdDActor } from "./actor.js";
import { TMRUtility } from "./tmr-utility.js";
const level_category = {
"generale": "-4",
@ -76,6 +77,12 @@ const fatigueMarche = { "aise": { "4":1, "6":2, "8":3, "10":4, "12":6 },
"malaise": { "4":2, "6":3, "8":4, "10":6 },
"difficile": { "4":3, "6":4, "8":6 },
"tresdifficile": { "4":4, "6":6 } }
/* Static tables for commands /table */
const table2func = { "queues": {descr: "queues : Tire une queue de Dragon", func: TMRUtility.getQueue},
"ombre": { descr: "ombre: Tire une Ombre de Dragon", func: TMRUtility.getOmbre },
"tetehr": {descr: "tetehr: Tire une Tête de Dragon pour Hauts Revants", fund: TMRUtility.getTeteHR},
"tete" : { descr: "tete: Tire une Tête de Dragon", func: TMRUtility.getTete},
"souffle": { descr: "souffle: Tire un Souffle de Dragon", func: TMRUtility.getSouffle} };
/* -------------------------------------------- */
export class RdDUtility {
@ -587,4 +594,43 @@ export class RdDUtility {
}
/* -------------------------------------------- */
/* Display help for /table */
static displayHelpTable( msg )
{
msg.content = "";
for (let [name, tableData] of Object.entries(table2func)) {
msg.content += "<br>" + tableData.descr;
}
ChatMessage.create( msg );
}
/* -------------------------------------------- */
/* Manage chat commands */
static processChatCommand( commands, content, msg ) {
// Setup new message's visibility
let rollMode = game.settings.get("core", "rollMode");
if (["gmroll", "blindroll"].includes(rollMode)) msg["whisper"] = ChatMessage.getWhisperIDs("GM");
if (rollMode === "blindroll") msg["blind"] = true;
msg["type"] = 0;
let command = commands[0];
// Roll on a table
if (command === "/table") {
if ( commands[1] ) {
let tableName = commands[1].toLowerCase();
table2func[tableName]();
} else {
this.displayHelpTable( msg );
}
return false
} else if (command === "/tmrr") {
TMRUtility.getRencontre(commands[1], commands[2] )
return false
}
return true;
}
}