Amélioration /tmrr

- support des mauvaises rencontres avec /tmrr Mauvaise
- recherche "intelligente": /tmrr ci pour lancer une rencontre en cité
This commit is contained in:
Vincent Vandemeulebrouck
2022-11-17 01:22:45 +01:00
parent 8b6abcc8bb
commit c8526a2270
2 changed files with 22 additions and 11 deletions

View File

@ -286,6 +286,23 @@ export class TMRUtility {
const tmr = TMRMapping[coord];
return Grammar.articleDetermine(tmr.type) + ' ' + tmr.label;
}
static findTMRLike(type, options = {inclusMauvaise:true}) {
const choix = [...Object.values(TMRType)]
if (options.inclusMauvaise){
choix.push({name: 'Mauvaise'});
}
const selection = Misc.findAllLike(type, choix).map(it => it.name);
if (selection.length == 0) {
ui.notifications.warn(`Un type de TMR doit être indiqué, '${type}' n'est pas trouvé dans ${choix}`);
return undefined;
}
if (selection.length > 1) {
ui.notifications.warn(`Plusieurs types de TMR pourraient correspondre à '${type}': ${selection}`);
return undefined;
}
return selection[0];
}
static typeTmrName(type) {
return Misc.upperFirst(TMRType[Grammar.toLowerCaseNoAccent(type)].name);