Fix: pas de message si carac exacte pas trouvée
La recherche se fait en deux temps, on avait un message d'erreur pour odorat-gout
This commit is contained in:
parent
f956da1fc0
commit
aa52e26e1a
@ -21,7 +21,7 @@ export class RdDBaseActor extends Actor {
|
||||
|
||||
static $findCaracByName(carac, name) {
|
||||
const caracList = Object.entries(carac);
|
||||
let entry = Misc.findFirstLike(name, caracList, { mapper: it => it[0], description: 'caractéristique' });
|
||||
let entry = Misc.findFirstLike(name, caracList, { mapper: it => it[0], description: 'caractéristique', onMessage: m => { } });
|
||||
if (!entry || entry.length == 0) {
|
||||
entry = Misc.findFirstLike(name, caracList, { mapper: it => it[1].label, description: 'caractéristique' });
|
||||
}
|
||||
|
@ -1,5 +1,12 @@
|
||||
import { Grammar } from "./grammar.js";
|
||||
|
||||
const DEFAULT_FIND_OPTIONS = {
|
||||
mapper: it => it.name,
|
||||
preFilter: it => true,
|
||||
description: 'valeur',
|
||||
onMessage: m => ui.notifications.info(m)
|
||||
}
|
||||
|
||||
/**
|
||||
* This class is intended as a placeholder for utility methods unrelated
|
||||
* to actual classes of the game system or of FoundryVTT
|
||||
@ -226,13 +233,7 @@ export class Misc {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static findFirstLike(value, elements, options = {}) {
|
||||
options = foundry.utils.mergeObject({
|
||||
mapper: it => it.name,
|
||||
preFilter: it => true,
|
||||
description: 'valeur',
|
||||
onMessage: m => ui.notifications.info(m)
|
||||
}, options, { overwrite: true, inplace: false });
|
||||
|
||||
options = foundry.utils.mergeObject(DEFAULT_FIND_OPTIONS, options, { overwrite: true, inplace: false });
|
||||
const subset = this.findAllLike(value, elements, options);
|
||||
if (subset.length == 0) {
|
||||
console.log(`Aucune ${options.description} pour ${value}`);
|
||||
@ -251,13 +252,7 @@ export class Misc {
|
||||
}
|
||||
|
||||
static findAllLike(value, elements, options = {}) {
|
||||
options = foundry.utils.mergeObject({
|
||||
mapper: it => it.name,
|
||||
preFilter: it => true,
|
||||
description: 'valeur',
|
||||
onMessage: m => ui.notifications.info(m)
|
||||
}, options);
|
||||
|
||||
options = foundry.utils.mergeObject(DEFAULT_FIND_OPTIONS, options, { overwrite: true, inplace: false });
|
||||
if (!value) {
|
||||
options.onMessage(`Pas de ${options.description} correspondant à une valeur vide`);
|
||||
return [];
|
||||
|
Loading…
x
Reference in New Issue
Block a user