Commande /tmr
This commit is contained in:
parent
1bec52371a
commit
b8ba30a5a3
@ -101,6 +101,11 @@ export class Misc {
|
||||
return [...new Set(array)];
|
||||
}
|
||||
|
||||
static join(params, separator = '') {
|
||||
return params.reduce((a, b) => a + separator + b);
|
||||
}
|
||||
|
||||
|
||||
static data(it) {
|
||||
if (it instanceof Actor || it instanceof Item || it instanceof Combatant) {
|
||||
return it.data;
|
||||
@ -129,7 +134,7 @@ export class Misc {
|
||||
return Misc.firstConnectedGM()?.id ?? game.user.id;
|
||||
}
|
||||
|
||||
static getActiveUser(id){
|
||||
static getActiveUser(id) {
|
||||
return game.users.entities.find(u => u.id == id && u.active);
|
||||
}
|
||||
|
||||
@ -143,7 +148,7 @@ export class Misc {
|
||||
static isUniqueConnectedGM() {
|
||||
return game.user.id == Misc.firstConnectedGM()?.id;
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static findPlayer(name) {
|
||||
return Misc.findFirstLike(name, game.users, { description: 'joueur' });
|
||||
@ -173,7 +178,7 @@ export class Misc {
|
||||
let single = subset.find(it => Grammar.toLowerCaseNoAccent(options.mapper(it)) == Grammar.toLowerCaseNoAccent(value));
|
||||
if (!single) {
|
||||
single = subset[0];
|
||||
const choices = subset.map(it => options.mapper(it)).reduce((a, b) => `${a}<br>${b}`);
|
||||
const choices = Misc.join(subset.map(it => options.mapper(it)), '<br>');
|
||||
options.info(`Plusieurs choix de ${options.description}s possibles:<br>${choices}<br>Le premier sera choisi: ${mapToValue(single)}`);
|
||||
}
|
||||
return single;
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
import { DialogCreateSigneDraconique } from "./dialog-create-signedraconique.js";
|
||||
import { DialogStress } from "./dialog-stress.js";
|
||||
import { Grammar } from "./grammar.js";
|
||||
import { RdDItemCompetence } from "./item-competence.js";
|
||||
import { Misc } from "./misc.js";
|
||||
import { RdDCarac } from "./rdd-carac.js";
|
||||
@ -40,6 +41,11 @@ export class RdDCommands {
|
||||
descr: `Tire une case aléatoire des Terres médianes
|
||||
<br><strong>/tmra forêt</strong> détermine une 'forêt' aléatoire
|
||||
<br><strong>/tmra</strong> détermine une case aléatoire dans toutes les TMR` });
|
||||
rddCommands.registerCommand({
|
||||
path: ["/tmr"], func: (content, msg, params) => rddCommands.findTMR(msg, params),
|
||||
descr: `Cherche où se trouve une case des Terres médianes
|
||||
<br><strong>/tmr? sordide</strong> indique que la cité Sordide est en D13
|
||||
<br><strong>/tmr? foret</strong> donne la liste des TMR dont le nom contient "foret" (donc, toutes les forêts)` });
|
||||
rddCommands.registerCommand({
|
||||
path: ["/tmrr"], func: (content, msg, params) => rddCommands.getRencontreTMR(params),
|
||||
descr: `Détermine une rencontre dans un type de case
|
||||
@ -80,7 +86,7 @@ export class RdDCommands {
|
||||
<br><strong>/payer 10d</strong> permet d'envoyer un message pour payer 10 deniers`
|
||||
});
|
||||
rddCommands.registerCommand({
|
||||
path: ["/astro"], func: (content, msg, params) => RdDUtility.afficherHeuresChanceMalchance(RdDCommands.toParamString(params)),
|
||||
path: ["/astro"], func: (content, msg, params) => RdDUtility.afficherHeuresChanceMalchance(Misc.join(params, ' ')),
|
||||
descr: `Affiche les heures de chance et de malchance selon l'heure de naissance donnée en argument. Exemples pour l'heure de la Lyre:
|
||||
<br><strong>/astro 7</strong>
|
||||
<br><strong>/astro Lyre</strong>
|
||||
@ -113,10 +119,6 @@ export class RdDCommands {
|
||||
this.commandsTable = {};
|
||||
}
|
||||
|
||||
static toParamString(params) {
|
||||
return params.length == 1 ? params[0] : params.reduce((a, b) => `${a} ${b}`, '');
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
registerCommand(command) {
|
||||
this._addCommand(this.commandsTable, command.path, '', command);
|
||||
@ -251,7 +253,7 @@ export class RdDCommands {
|
||||
RdDRollResolutionTable.open();
|
||||
}
|
||||
else {
|
||||
let flatParams = params.reduce((a, b) => `${a} ${b}`);
|
||||
let flatParams = Misc.join(params, ' ');
|
||||
const numericParams = flatParams.match(rddRollNumeric);
|
||||
if (numericParams) {
|
||||
const carac = Misc.toInt(numericParams[1]);
|
||||
@ -272,7 +274,7 @@ export class RdDCommands {
|
||||
diff = 0;
|
||||
}
|
||||
const caracName = params[0];
|
||||
const compName = length > 1 ? params.slice(1, length).reduce((a, b) => `${a} ${b}`) : undefined;
|
||||
const compName = length > 1 ? Misc.join(params.slice(1, length), ' ') : undefined;
|
||||
for (let actor of actors) {
|
||||
await actor.rollCaracCompetence(caracName, compName, diff);
|
||||
}
|
||||
@ -314,6 +316,14 @@ export class RdDCommands {
|
||||
}
|
||||
}
|
||||
|
||||
async findTMR(msg, params) {
|
||||
const flat = Grammar.toLowerCaseNoAccent(Misc.join(params));
|
||||
const found = TMRUtility.findTMR(flat);
|
||||
if (found?.length > 0) {
|
||||
return RdDCommands._chatAnswer(msg, `Les TMRs correspondant à '${flat}' sont:` + Misc.join(found.map(it => `<br>${it.coord}: ${it.label}`)));
|
||||
}
|
||||
return RdDCommands._chatAnswer(msg, 'Aucune TMR correspondant à ' + flat);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getCoutXpComp(msg, params) {
|
||||
@ -359,7 +369,7 @@ export class RdDCommands {
|
||||
ui.notifications.warn("Seul le MJ est autorisé à utiliser la commande /stress");
|
||||
return false;
|
||||
}
|
||||
if (params.length == 0) {
|
||||
if (params.length < 3) {
|
||||
DialogStress.distribuerStress();
|
||||
}
|
||||
else {
|
||||
@ -369,8 +379,8 @@ export class RdDCommands {
|
||||
return;
|
||||
}
|
||||
|
||||
let motif = params[1];
|
||||
let name = params[2];
|
||||
let motif = params.slice(1, params.length - 2);
|
||||
let name = params[params.length - 1];
|
||||
if (name == undefined) {
|
||||
for (let actor of game.actors) {
|
||||
actor.distribuerStress('stress', stress, motif);
|
||||
|
@ -347,7 +347,7 @@ export class TMRUtility {
|
||||
return Grammar.articleDetermine(tmr.type) + ' ' + tmr.label;
|
||||
}
|
||||
|
||||
static typeTmrName(type){
|
||||
static typeTmrName(type) {
|
||||
return Misc.upperFirst(TMRType[Grammar.toLowerCaseNoAccent(type)].name);
|
||||
}
|
||||
static listSelectedTMR(typesTMR) {
|
||||
@ -424,6 +424,10 @@ export class TMRUtility {
|
||||
return Object.values(TMRMapping).filter(filter);
|
||||
}
|
||||
|
||||
static findTMR(search) {
|
||||
return TMRUtility.filterTMR(it => Grammar.toLowerCaseNoAccentNoSpace(it.label).match(search));
|
||||
}
|
||||
|
||||
static filterTMRCoord(filter) {
|
||||
return TMRUtility.filterTMR(filter).map(it => it.coord);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user