12.0.33 - la vieillesse d'Astrobazzarh #736
@ -21,7 +21,7 @@ export class RdDBaseActor extends Actor {
|
|||||||
|
|
||||||
static $findCaracByName(carac, name) {
|
static $findCaracByName(carac, name) {
|
||||||
const caracList = Object.entries(carac);
|
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) {
|
if (!entry || entry.length == 0) {
|
||||||
entry = Misc.findFirstLike(name, caracList, { mapper: it => it[1].label, description: 'caractéristique' });
|
entry = Misc.findFirstLike(name, caracList, { mapper: it => it[1].label, description: 'caractéristique' });
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
import { Grammar } from "./grammar.js";
|
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
|
* This class is intended as a placeholder for utility methods unrelated
|
||||||
* to actual classes of the game system or of FoundryVTT
|
* to actual classes of the game system or of FoundryVTT
|
||||||
@ -226,13 +233,7 @@ export class Misc {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static findFirstLike(value, elements, options = {}) {
|
static findFirstLike(value, elements, options = {}) {
|
||||||
options = foundry.utils.mergeObject({
|
options = foundry.utils.mergeObject(DEFAULT_FIND_OPTIONS, options, { overwrite: true, inplace: false });
|
||||||
mapper: it => it.name,
|
|
||||||
preFilter: it => true,
|
|
||||||
description: 'valeur',
|
|
||||||
onMessage: m => ui.notifications.info(m)
|
|
||||||
}, options, { overwrite: true, inplace: false });
|
|
||||||
|
|
||||||
const subset = this.findAllLike(value, elements, options);
|
const subset = this.findAllLike(value, elements, options);
|
||||||
if (subset.length == 0) {
|
if (subset.length == 0) {
|
||||||
console.log(`Aucune ${options.description} pour ${value}`);
|
console.log(`Aucune ${options.description} pour ${value}`);
|
||||||
@ -251,13 +252,7 @@ export class Misc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static findAllLike(value, elements, options = {}) {
|
static findAllLike(value, elements, options = {}) {
|
||||||
options = foundry.utils.mergeObject({
|
options = foundry.utils.mergeObject(DEFAULT_FIND_OPTIONS, options, { overwrite: true, inplace: false });
|
||||||
mapper: it => it.name,
|
|
||||||
preFilter: it => true,
|
|
||||||
description: 'valeur',
|
|
||||||
onMessage: m => ui.notifications.info(m)
|
|
||||||
}, options);
|
|
||||||
|
|
||||||
if (!value) {
|
if (!value) {
|
||||||
options.onMessage(`Pas de ${options.description} correspondant à une valeur vide`);
|
options.onMessage(`Pas de ${options.description} correspondant à une valeur vide`);
|
||||||
return [];
|
return [];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user