diff --git a/module/actor/base-actor.js b/module/actor/base-actor.js index a10be819..544dd711 100644 --- a/module/actor/base-actor.js +++ b/module/actor/base-actor.js @@ -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' }); } diff --git a/module/misc.js b/module/misc.js index ed0dd0b6..40afa4d5 100644 --- a/module/misc.js +++ b/module/misc.js @@ -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 [];