From e92f4130f283ce87d866935f0e0f15879770ab2c Mon Sep 17 00:00:00 2001 From: sladecraven Date: Sat, 5 Jun 2021 21:35:43 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20heure=20naissance=20et=20attaque=20sur=20?= =?UTF-8?q?v=C3=A9hicules?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/actor.js | 5 +++-- module/grammar.js | 5 +++++ module/rdd-calendrier.js | 5 +++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/module/actor.js b/module/actor.js index 9f8e58f7..194106a9 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1447,7 +1447,8 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ getSonne() { - return !this.isEntiteCauchemar() && (Misc.templateData(this).sante.sonne?.value ?? false); + let data = Misc.templateData(this); + return !this.isEntiteCauchemar() && (data.sante?.sonne?.value ?? false); } /* -------------------------------------------- */ @@ -3099,7 +3100,7 @@ export class RdDActor extends Actor { let itemData = Misc.data(item); if (itemData?.data) { const isEquipe = !itemData.data.equipe; - let update = { _id: item._id, "data.equipe": isEquipe }; + let update = { _id: item.id, "data.equipe": isEquipe }; await this.updateEmbeddedDocuments('Item', [update]); this.computeEncombrementTotalEtMalusArmure(); // Mise à jour encombrement this.computePrixTotalEquipement(); // Mis à jour du prix total de l'équipement diff --git a/module/grammar.js b/module/grammar.js index 7a35cebc..6bb642b4 100644 --- a/module/grammar.js +++ b/module/grammar.js @@ -24,6 +24,11 @@ export class Grammar { return words?.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "") ?? words; } + /* -------------------------------------------- */ + static toLowerCaseNoAccentNoSpace(words) { + return words?.toLowerCase().normalize("NFD").replace(/[ \u0300-\u036f]/g, "") ?? words; + } + /* -------------------------------------------- */ static articleDetermine(genre) { switch (Grammar.toLowerCaseNoAccent(genre)) { diff --git a/module/rdd-calendrier.js b/module/rdd-calendrier.js index a3013ab7..97273133 100644 --- a/module/rdd-calendrier.js +++ b/module/rdd-calendrier.js @@ -327,13 +327,14 @@ export class RdDCalendrier extends Application { } } + /* -------------------------------------------- */ findHeure(heure) { heure = Grammar.toLowerCaseNoAccent(heure); - let parHeureOuLabel = Object.values(heuresDef).filter(it => (it.heure+1) == heure || Grammar.toLowerCaseNoAccent(it.label) == heure); + let parHeureOuLabel = Object.values(heuresDef).filter(it => (it.heure+1) == heure || Grammar.toLowerCaseNoAccentNoSpace(it.label) == heure); if (parHeureOuLabel.length == 1) { return parHeureOuLabel[0]; } - let parLabelPartiel = Object.values(heuresDef).filter(it => Grammar.toLowerCaseNoAccent(it.label).includes(heure)); + let parLabelPartiel = Object.values(heuresDef).filter(it => Grammar.toLowerCaseNoAccentNoSpace(it.label).includes(heure)); const matchLength = heure.length; if(parLabelPartiel.length > 0) { parLabelPartiel.sort((a,b)=> (a.label.length - matchLength)^2 - (b.label.length- matchLength)^2);