From e8a59b56a4ab14bcf4f99dca92848917a281ed33 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Thu, 25 Mar 2021 01:57:48 +0100 Subject: [PATCH] =?UTF-8?q?Fix:=20privil=C3=A9gier=20le=20nom=20exact?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/item-competence.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/module/item-competence.js b/module/item-competence.js index a07482b9..dacf1b9f 100644 --- a/module/item-competence.js +++ b/module/item-competence.js @@ -190,10 +190,13 @@ export class RdDItemCompetence extends Item { if (competences.length == 0) { return undefined; } - const competence = competences[0]; - if (competences.length>1) { - const names = competences.map(it => it.name).reduce((a, b) => `${a}
${b}`); - ui.notifications.info(`Plusieurs compétences possibles:
${names}
La première sera choisie: ${competence.name}`); + let competence = competences.find(it => Grammar.toLowerCaseNoAccent(it.name) == name); + if (!competence) { + competence = competences[0]; + if (competences.length>1) { + const names = competences.map(it => it.name).reduce((a, b) => `${a}
${b}`); + ui.notifications.info(`Plusieurs compétences possibles:
${names}
La première sera choisie: ${competence.name}`); + } } return competence; }