From 8ab796400460f0e934b335fd3a4b9165958fe83c Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Tue, 22 Mar 2022 23:36:46 +0100 Subject: [PATCH] =?UTF-8?q?Message=20sur=20les=20comp=C3=A9tences=20tronc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Amélioration: ne liste que les compétences inférieures --- module/actor.js | 10 +++++++--- module/item-competence.js | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/module/actor.js b/module/actor.js index 71a82c8a..354bb2e4 100644 --- a/module/actor.js +++ b/module/actor.js @@ -964,11 +964,15 @@ export class RdDActor extends Actor { async updateCompetence(idOrName, compValue) { let competence = this.getCompetence(idOrName); if (competence) { - let troncList = RdDItemCompetence.isTronc(competence.name); let nouveauNiveau = compValue ?? RdDItemCompetence.getNiveauBase(Misc.data(competence).data.categorie); - if (troncList) { + const tronc = RdDItemCompetence.getListTronc(competence.name).filter(it => { + const comp = this.getCompetence(it); + const niveauTr = comp? Misc.data(comp).data.niveau : 0; + return niveauTr < 0 && niveauTr < nouveauNiveau; + }); + if (tronc.length > 0) { let message = "Vous avez modifié une compétence 'tronc'. Vérifiez que les compétences suivantes évoluent ensemble jusqu'au niveau 0 : "; - for (let troncName of troncList) { + for (let troncName of tronc) { message += "
" + troncName; } ChatMessage.create({ diff --git a/module/item-competence.js b/module/item-competence.js index 268e4116..5c7f3156 100644 --- a/module/item-competence.js +++ b/module/item-competence.js @@ -113,14 +113,14 @@ export class RdDItemCompetence extends Item { } /* -------------------------------------------- */ - static isTronc(compName) { + static getListTronc(compName) { for (let troncList of competenceTroncs) { for (let troncName of troncList) { if (troncName == compName) return troncList; } } - return false; + return []; } /* -------------------------------------------- */