Fix /rdd [carac]
- en cas de carac exact (reve), choisir cette caractéristique (pas de message par rapport à reve-actuel) - support /rdd odorat-gout
This commit is contained in:
@ -38,6 +38,29 @@ const tableCaracDerivee = {
|
||||
|
||||
export class RdDCarac {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static findCarac(carac, name) {
|
||||
|
||||
const pairs = Object.entries(carac)
|
||||
.filter(([key, value]) => key.includes(name) || Grammar.toLowerCaseNoAccent(value.label).includes(name));
|
||||
|
||||
let c = pairs.find(([key, value]) => key == name || Grammar.toLowerCaseNoAccent(value.label) == name);
|
||||
if (c) {
|
||||
return c[1];
|
||||
}
|
||||
|
||||
pairs.sort((a, b) => a[0].length- b[0].length);
|
||||
if (pairs.length > 0) {
|
||||
c = pairs[0][1];
|
||||
if (pairs.length > 1) {
|
||||
const labels = pairs.map(pair => pair[1].label).reduce((a, b) => `${a}<br>${b}`);
|
||||
ui.notifications.info(`Plusieurs caractéristiques possibles:<br>${labels}<br>La première sera choisie: ${c.label}.`);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
static isAgiliteOuDerivee(selectedCarac) {
|
||||
return selectedCarac?.label.match(/(Agilité|Dérobée)/);
|
||||
}
|
||||
|
Reference in New Issue
Block a user