diff --git a/module/actor.js b/module/actor.js
index 26364e91..ea056810 100644
--- a/module/actor.js
+++ b/module/actor.js
@@ -3148,7 +3148,7 @@ export class RdDActor extends Actor {
return carac.chance;
}
let entry = Misc.findFirstLike(name, Object.entries(carac), { mapper: it => it[1].label, description: 'caractéristique' });
- return entry.length > 0 ? carac[entry[0]] : undefined;
+ return entry && entry.length > 0 ? carac[entry[0]] : undefined;
}
/* -------------------------------------------- */
diff --git a/module/item-competence.js b/module/item-competence.js
index 5c7f3156..0bfe17b1 100644
--- a/module/item-competence.js
+++ b/module/item-competence.js
@@ -212,8 +212,11 @@ export class RdDItemCompetence extends Item {
/* -------------------------------------------- */
static findCompetence(list, idOrName, options = {}) {
+ if (idOrName == undefined) {
+ return undefined;
+ }
options = mergeObject(options, {
- filter: it => RdDItemCompetence.isCompetence(it),
+ preFilter: it => RdDItemCompetence.isCompetence(it),
description: 'compétence',
});
return list.find(it => it.id == idOrName && RdDItemCompetence.isCompetence(it))
diff --git a/module/misc.js b/module/misc.js
index 59fc080c..3b6dbb40 100644
--- a/module/misc.js
+++ b/module/misc.js
@@ -192,7 +192,7 @@ export class Misc {
if (!single) {
single = subset[0];
const choices = Misc.join(subset.map(it => options.mapper(it)), '
');
- options.info(`Plusieurs choix de ${options.description}s possibles:
${choices}
Le premier sera choisi: ${mapToValue(single)}`);
+ options.onMessage(`Plusieurs choix de ${options.description}s possibles:
${choices}
Le premier sera choisi: ${options.mapper(single)}`);
}
return single;
}
@@ -211,7 +211,7 @@ export class Misc {
}
value = Grammar.toLowerCaseNoAccent(value);
const subset = elements.filter(options.preFilter)
- .filter(it => Grammar.toLowerCaseNoAccent(options.mapper(it)).includes(value));
+ .filter(it => Grammar.toLowerCaseNoAccent(options.mapper(it))?.includes(value));
if (subset.length == 0) {
options.onMessage(`Pas de ${options.description} correspondant à ${value}`);
}
diff --git a/module/rdd-commands.js b/module/rdd-commands.js
index fdddcb05..4aecbcbf 100644
--- a/module/rdd-commands.js
+++ b/module/rdd-commands.js
@@ -276,9 +276,11 @@ export class RdDCommands {
diff = 0;
}
const caracName = params[0];
- const compName = length > 1 ? Misc.join(params.slice(1, length), ' ') : undefined;
- for (let actor of actors) {
- await actor.rollCaracCompetence(caracName, compName, diff);
+ let competence = length > 1 ? actors[0].getCompetence(Misc.join(params.slice(1, length), ' ')) : undefined;
+ if (competence) {
+ for (let actor of actors) {
+ await actor.rollCaracCompetence(caracName, competence.name, diff);
+ }
}
return;
}