forked from public/foundryvtt-reve-de-dragon
Fix calcul de l'expérience
Ajout d'une commande pour calculer l'expérience pour augmenter
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
|
||||
import { ChatUtility } from "./chat-utility.js";
|
||||
import { DeDraconique } from "./de-draconique.js";
|
||||
import { RdDItemCompetence } from "./item-competence.js";
|
||||
import { Misc } from "./misc.js";
|
||||
import { RdDDice } from "./rdd-dice.js";
|
||||
import { RdDResolutionTable } from "./rdd-resolution-table.js";
|
||||
@ -30,8 +31,21 @@ export class RdDCommands {
|
||||
|
||||
rddCommands.registerCommand({ path: ["/tmra"], func: (content, msg, params) => TMRUtility.getTMRAleatoire(), descr: "Tire une case aléatoire des Terres médianes" });
|
||||
rddCommands.registerCommand({
|
||||
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>Exemple: <strong>/tmrr forêt 50</strong>"
|
||||
path: ["/tmrr"], func: (content, msg, params) => rddCommands.getRencontreTMR(msg, params),
|
||||
descr: "Exemple: <strong>/tmrr forêt 47</strong><br>Détermine quelle est la rencontre dans une case 'forêt' pour un jet de dé de 47"
|
||||
});
|
||||
|
||||
rddCommands.registerCommand({
|
||||
path: ["/xp", "comp"], func: (content, msg, params) => rddCommands.getCoutXpComp(msg, params),
|
||||
descr: `Détermine le coût d'expérience pour augmenter une compétence. Exemples:
|
||||
<br>/xp comp -6 1: pour passer de -6 à +1
|
||||
<br>/xp comp +4: pour atteindre le niveau 4 (depuis +3)`
|
||||
});
|
||||
|
||||
rddCommands.registerCommand({
|
||||
path: ["/xp", "carac"], func: (content, msg, params) => rddCommands.getCoutXpCarac(msg, params),
|
||||
descr: `Détermine le coût d'expérience pour augmenter une caractéristique. Exemples:
|
||||
<br>/xp carac 15: coût pour atteindre 15 (depuis 14)`
|
||||
});
|
||||
|
||||
rddCommands.registerCommand({
|
||||
@ -129,8 +143,9 @@ export class RdDCommands {
|
||||
}
|
||||
}
|
||||
if (command && command.func) {
|
||||
if (command.func(content, msg, params) === false) {
|
||||
this._displayHelp(msg, `${path}: ${command.descr}`);
|
||||
const result = command.func(content, msg, params);
|
||||
if (result == false) {
|
||||
RdDCommands._chatAnswer(msg, command.descr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -142,8 +157,13 @@ export class RdDCommands {
|
||||
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>`);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static _chatAnswer(msg, content) {
|
||||
msg.whisper = [game.user._id];
|
||||
msg.content = `Commandes disponibles<ul class="alterne-list"><li class="list-item">${messageAide}</li></ul>`;
|
||||
msg.content = content;
|
||||
ChatMessage.create(msg);
|
||||
}
|
||||
|
||||
@ -161,7 +181,7 @@ export class RdDCommands {
|
||||
return list.sort();
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getRencontreTMR(params) {
|
||||
if (params.length == 2) {
|
||||
return TMRUtility.getRencontre(params[0], params[1])
|
||||
@ -171,6 +191,7 @@ export class RdDCommands {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollRdd(msg, params) {
|
||||
if (params.length == 0) {
|
||||
RdDRollResolutionTable.open();
|
||||
@ -188,6 +209,7 @@ export class RdDCommands {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollRdDNumeric(msg, carac, diff, significative = false) {
|
||||
let rollData = {
|
||||
caracValue: carac,
|
||||
@ -197,15 +219,38 @@ export class RdDCommands {
|
||||
show: { title: "Table de résolution" }
|
||||
};
|
||||
await RdDResolutionTable.rollData(rollData);
|
||||
msg.content = await RdDResolutionTable.buildRollDataHtml(rollData);
|
||||
ChatUtility.createChatWithRollMode(game.user.name, msg);
|
||||
RdDCommands._chatAnswer(msg, await RdDResolutionTable.buildRollDataHtml(rollData));
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollDeDraconique(msg) {
|
||||
let ddr = new DeDraconique().evaluate();
|
||||
await RdDDice.show(ddr, rollMode);
|
||||
msg.content = `Lancer d'un Dé draconique: ${ddr.total}`;
|
||||
ChatUtility.createChatWithRollMode(game.user.name, msg);
|
||||
RdDCommands._chatAnswer(msg, `Lancer d'un Dé draconique: ${ddr.total}`);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getCoutXpComp(msg, params) {
|
||||
if (params && (params.length == 1 || params.length == 2)) {
|
||||
let to = params.length == 1 ? Number(params[0]) : Number(params[1]);
|
||||
let from = params.length == 1 ? to - 1 : Number(params[0]);
|
||||
RdDCommands._chatAnswer(msg, `Coût pour passer une compétence de ${from} à ${to}: ${RdDItemCompetence.getDeltaXp(from, to)}`);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getCoutXpCarac(msg, params) {
|
||||
if (params && params.length == 1) {
|
||||
let to = Number(params[0]);
|
||||
RdDCommands._chatAnswer(msg, `Coût pour passer une caractéristique de ${to - 1} à ${to}: ${RdDUtility.getCaractXp(to)}`);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user