|
|
|
@ -1,7 +1,9 @@
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
import { ChatUtility } from "./chat-utility.js";
|
|
|
|
|
import { DeDraconique } from "./de-draconique.js";
|
|
|
|
|
import { Misc } from "./misc.js";
|
|
|
|
|
import { RdDDice } from "./rdd-dice.js";
|
|
|
|
|
import { RdDResolutionTable } from "./rdd-resolution-table.js";
|
|
|
|
|
import { RdDRollResolution } from "./rdd-roll-resolution.js";
|
|
|
|
|
import { RdDRollTables } from "./rdd-rolltables.js";
|
|
|
|
@ -16,57 +18,67 @@ export class RdDCommands {
|
|
|
|
|
static init() {
|
|
|
|
|
if (!game.system.rdd.commands) {
|
|
|
|
|
const rddCommands = new RdDCommands();
|
|
|
|
|
rddCommands.registerCommand({ path: ["/aide"], descr: "Affiche l'aide pour toutes les commandes", func: (content, msg, params) => rddCommands.help(msg) });
|
|
|
|
|
rddCommands.registerCommand({ path: ["/help"], descr: "Affiche l'aide pour toutes les commandes", func: (content, msg, params) => rddCommands.help(msg) });
|
|
|
|
|
rddCommands.registerCommand({ path: ["/table", "queues"], descr: "Tire une Queue de Dragon", func: (content, msg, params) => RdDRollTables.getQueue() });
|
|
|
|
|
rddCommands.registerCommand({ path: ["/table", "ombre"], descr: "Tire une Ombre de Dragon", func: (content, msg, params) => RdDRollTables.getOmbre() });
|
|
|
|
|
rddCommands.registerCommand({ path: ["/table", "tetehr"], descr: "Tire une Tête de Dragon pour Hauts Revants", func: (content, msg, params) => RdDRollTables.getTeteHR() });
|
|
|
|
|
rddCommands.registerCommand({ path: ["/table", "tete"], descr: "Tire une Tête de Dragon", func: (content, msg, params) => RdDRollTables.getTete() });
|
|
|
|
|
rddCommands.registerCommand({ path: ["/table", "souffle"], descr: " Tire un Souffle de Dragon", func: (content, msg, params) => RdDRollTables.getSouffle() });
|
|
|
|
|
rddCommands.registerCommand({ path: ["/table", "tarot"], descr: "Tire une carte du Tarot Draconique", func: (content, msg, params) => RdDRollTables.getTarot() });
|
|
|
|
|
rddCommands.registerCommand({ path: ["/table", "tmr"], descr: "Tire une case aléatoire des Terre médiane", func: (content, msg, params) => TMRUtility.getTMRAleatoire() });
|
|
|
|
|
rddCommands.registerCommand({ path: ["/aide"], func: (content, msg, params) => rddCommands.help(msg), descr: "Affiche l'aide pour toutes les commandes" });
|
|
|
|
|
rddCommands.registerCommand({ path: ["/help"], func: (content, msg, params) => rddCommands.help(msg), descr: "Affiche l'aide pour toutes les commandes" });
|
|
|
|
|
rddCommands.registerCommand({ path: ["/table", "queues"], func: (content, msg, params) => RdDRollTables.getQueue(), descr: "Tire une Queue de Dragon" });
|
|
|
|
|
rddCommands.registerCommand({ path: ["/table", "ombre"], func: (content, msg, params) => RdDRollTables.getOmbre(), descr: "Tire une Ombre de Dragon" });
|
|
|
|
|
rddCommands.registerCommand({ path: ["/table", "tetehr"], func: (content, msg, params) => RdDRollTables.getTeteHR(), descr: "Tire une Tête de Dragon pour Hauts Revants" });
|
|
|
|
|
rddCommands.registerCommand({ path: ["/table", "tete"], func: (content, msg, params) => RdDRollTables.getTete(), descr: "Tire une Tête de Dragon" });
|
|
|
|
|
rddCommands.registerCommand({ path: ["/table", "souffle"], func: (content, msg, params) => RdDRollTables.getSouffle(), descr: " Tire un Souffle de Dragon" });
|
|
|
|
|
rddCommands.registerCommand({ path: ["/table", "tarot"], func: (content, msg, params) => RdDRollTables.getTarot(), descr: "Tire une carte du Tarot Draconique" });
|
|
|
|
|
rddCommands.registerCommand({ path: ["/table", "tmr"], func: (content, msg, params) => TMRUtility.getTMRAleatoire(), descr: "Tire une case aléatoire des Terre médiane" });
|
|
|
|
|
|
|
|
|
|
rddCommands.registerCommand({ path: ["/tmra"], descr: "Tire une case aléatoire des Terre médiane", func: (content, msg, params) => TMRUtility.getTMRAleatoire() });
|
|
|
|
|
rddCommands.registerCommand({ path: ["/tmrr"], descr: "Syntaxe: <strong>/tmrr case jet</strong><br>Détermine quelle est la rencontre dans la case pour le jet<br>Example: <strong>/tmrr forêt 50</strong>", func: (content, msg, params) => rddCommands.getRencontreTMR(params) });
|
|
|
|
|
rddCommands.registerCommand({ path: ["/tmra"], func: (content, msg, params) => TMRUtility.getTMRAleatoire(), descr: "Tire une case aléatoire des Terre médiane" });
|
|
|
|
|
rddCommands.registerCommand({
|
|
|
|
|
path: ["/rdd"], descr: `Effectue un jet de dés dans la table de résolution. Examples:
|
|
|
|
|
path: ["/tmrr"], func: (content, msg, params) => rddCommands.getRencontreTMR(params),
|
|
|
|
|
descr: "Syntaxe: <strong>/tmrr case jet</strong><br>Détermine quelle est la rencontre dans la case pour le jet<br>Example: <strong>/tmrr forêt 50</strong>"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
rddCommands.registerCommand({
|
|
|
|
|
path: ["/rdd"], func: (content, msg, params) => rddCommands.rollRdd(msg, params),
|
|
|
|
|
descr: `Effectue un jet de dés dans la table de résolution. Examples:
|
|
|
|
|
<br><strong>/rdd</strong> ouvre la table de résolution
|
|
|
|
|
<br><strong>/rdd 10 3</strong> effectue un jet 10 à +3
|
|
|
|
|
<br><strong>/rdd 10 +2</strong> effectue un jet 10 à +2
|
|
|
|
|
<br><strong>/rdd 15 -2</strong> effectue un jet 15 à -2
|
|
|
|
|
<br><strong>/rdd 15 0 s</strong> effectue un jet 15 à 0, avec significative requise
|
|
|
|
|
`, func: (content, msg, params) => rddCommands.rollRdd(msg, params)
|
|
|
|
|
`
|
|
|
|
|
});
|
|
|
|
|
rddCommands.registerCommand({ path: ["/ddr"], func: (content, msg, params) => rddCommands.rollDeDraconique(msg), descr: "Lance un Dé Draconique" });
|
|
|
|
|
|
|
|
|
|
rddCommands.registerCommand({ path: ["/payer"], descr: `Permet de payer un montant. Exemples:
|
|
|
|
|
rddCommands.registerCommand({
|
|
|
|
|
path: ["/payer"], func: (content, msg, params) => RdDUtility.afficherDemandePayer(params[0], params[1]),
|
|
|
|
|
descr: `Permet de payer un montant. Exemples:
|
|
|
|
|
<br><strong>/payer 5s 10d</strong> permet d'envoyer un message pour payer 5 sols et 10 deniers
|
|
|
|
|
<br><strong>/payer 10d</strong> permet d'envoyer un message pour payer 10 deniers
|
|
|
|
|
`, func: (content, msg, params) => RdDUtility.afficherDemandePayer(params[0], params[1])});
|
|
|
|
|
`
|
|
|
|
|
});
|
|
|
|
|
game.system.rdd.commands = rddCommands;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
|
this.commandsTable = {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
registerCommand(command) {
|
|
|
|
|
this._addCommand(this.commandsTable, command.path, command);
|
|
|
|
|
this._addCommand(this.commandsTable, command.path, '', command);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_addCommand(targetTable, path, command) {
|
|
|
|
|
_addCommand(targetTable, path, fullPath, command) {
|
|
|
|
|
if (!this._validateCommand(targetTable, path, command)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const term = path[0];
|
|
|
|
|
fullPath = fullPath+term+' '
|
|
|
|
|
if (path.length == 1) {
|
|
|
|
|
command.descr = `<strong>${fullPath}</strong>: ${command.descr}`;
|
|
|
|
|
targetTable[term] = command;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (!targetTable[term]) {
|
|
|
|
|
targetTable[term] = { subTable: {} };
|
|
|
|
|
}
|
|
|
|
|
this._addCommand(targetTable[term].subTable, path.slice(1), command)
|
|
|
|
|
this._addCommand(targetTable[term].subTable, path.slice(1), fullPath, command)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -122,24 +134,25 @@ export class RdDCommands {
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
help(msg, table = undefined) {
|
|
|
|
|
let list = []
|
|
|
|
|
this._buildSubTableHelp(list, '', table || this.commandsTable);
|
|
|
|
|
this._buildSubTableHelp(list, table || this.commandsTable);
|
|
|
|
|
const messageAide = list.reduce((a, b) => a + '</li><li class="list-item">' + b);
|
|
|
|
|
msg.whisper = [game.user._id];
|
|
|
|
|
msg.content = 'Commandes disponibles<ul class="alterne-list"><li class="list-item">' + list.reduce((a, b) => a + '</li><li class="list-item">' + b) + '</li></ul>';
|
|
|
|
|
msg.content = `Commandes disponibles<ul class="alterne-list"><li class="list-item">${messageAide}</li></ul>`;
|
|
|
|
|
ChatMessage.create(msg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
_buildSubTableHelp(list, path, table) {
|
|
|
|
|
_buildSubTableHelp(list, table) {
|
|
|
|
|
for (let [name, command] of Object.entries(table)) {
|
|
|
|
|
if (command) {
|
|
|
|
|
if (command.subTable) {
|
|
|
|
|
this._buildSubTableHelp(list, path + name + " ", command.subTable);
|
|
|
|
|
this._buildSubTableHelp(list, command.subTable);
|
|
|
|
|
} else {
|
|
|
|
|
list.push(`<strong>${path}${name}</strong>: ${command.descr}`);
|
|
|
|
|
list.push(command.descr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
return list.sort();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -181,5 +194,13 @@ export class RdDCommands {
|
|
|
|
|
msg.content = await RdDResolutionTable.explainRollDataV2(rollData);
|
|
|
|
|
ChatUtility.chatWithRollMode(msg, game.user.name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async rollDeDraconique(msg) {
|
|
|
|
|
let rollMode = game.settings.get("core", "rollMode");
|
|
|
|
|
let ddr = new DeDraconique().evaluate();
|
|
|
|
|
await RdDDice.show(ddr, rollMode);
|
|
|
|
|
msg.content = `Lancer d'un Dé draconique: ${ddr.total}`;
|
|
|
|
|
ChatUtility.createChatMessage(msg, rollMode, game.user.name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|