From 648848aa03dbcf6365a9002aa3371f2e9f7c4327 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sat, 27 Nov 2021 00:04:34 +0100 Subject: [PATCH] =?UTF-8?q?Recherche=20TMR=20par=20coordonn=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/rdd-commands.js | 10 +++++----- module/rdd-main.js | 2 +- module/tmr-utility.js | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/module/rdd-commands.js b/module/rdd-commands.js index f11803f0..5e1a1c6d 100644 --- a/module/rdd-commands.js +++ b/module/rdd-commands.js @@ -162,7 +162,7 @@ export class RdDCommands { if (rollMode === "blindroll") msg["blind"] = true; msg["type"] = 0; - let command = commandLine[0]; + let command = commandLine[0].toLowerCase(); let params = commandLine.slice(1); return this.process(command, params, content, msg); @@ -317,12 +317,12 @@ export class RdDCommands { } async findTMR(msg, params) { - const flat = Grammar.toLowerCaseNoAccent(Misc.join(params)); - const found = TMRUtility.findTMR(flat); + const search = Misc.join(params, ' '); + const found = TMRUtility.findTMR(search); if (found?.length > 0) { - return RdDCommands._chatAnswer(msg, `Les TMRs correspondant à '${flat}' sont:` + Misc.join(found.map(it => `
${it.coord}: ${it.label}`))); + return RdDCommands._chatAnswer(msg, `Les TMRs correspondant à '${search}' sont:` + Misc.join(found.map(it => `
${it.coord}: ${it.label}`))); } - return RdDCommands._chatAnswer(msg, 'Aucune TMR correspondant à ' + flat); + return RdDCommands._chatAnswer(msg, 'Aucune TMR correspondant à ' + search); } /* -------------------------------------------- */ diff --git a/module/rdd-main.js b/module/rdd-main.js index 175dfc2f..503854fe 100644 --- a/module/rdd-main.js +++ b/module/rdd-main.js @@ -300,7 +300,7 @@ Hooks.once('diceSoNiceReady', (dice3d) => RdDDice.diceSoNiceReady(dice3d)); Hooks.on("chatMessage", (html, content, msg) => { if (content[0] == '/') { let regExp = /(\S+)/g; - let commands = content.toLowerCase().match(regExp); + let commands = content.match(regExp); if (game.system.rdd.commands.processChatCommand(commands, content, msg)) { return false; } diff --git a/module/tmr-utility.js b/module/tmr-utility.js index 86cdea05..a54de95e 100644 --- a/module/tmr-utility.js +++ b/module/tmr-utility.js @@ -425,7 +425,8 @@ export class TMRUtility { } static findTMR(search) { - return TMRUtility.filterTMR(it => Grammar.toLowerCaseNoAccentNoSpace(it.label).match(search)); + const labelSearch = Grammar.toLowerCaseNoAccent(search) + return TMRUtility.filterTMR(it => Grammar.toLowerCaseNoAccent(it.label).match(labelSearch) || it.coord == search); } static filterTMRCoord(filter) {