From bc32cd1ad4bb754a6dd81ad45dd4ce0c8dc381fb Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Thu, 12 Nov 2020 18:41:43 +0100 Subject: [PATCH] Simplification des recherches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit + fix: ne pas chercher les compétences ailleurs que dans les compétences --- module/actor.js | 22 ++++++---------------- module/rdd-utility.js | 7 +------ 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/module/actor.js b/module/actor.js index 0b61b321..031d20f6 100644 --- a/module/actor.js +++ b/module/actor.js @@ -671,24 +671,14 @@ export class RdDActor extends Actor { new RdDRollDialog("carac", html, rollData, this ).render(true); } - /* -------------------------------------------- */ - getSortList( ) { - let sortList = [] - for (const item of this.data.items) { - if (item.type == "sort" ) - sortList.push(item); - } - return sortList; + /* -------------------------------------------- */ + getSortList() { + return this.data.items.filter(item => item.type == "sort"); } - /* -------------------------------------------- */ - getDraconicList( ) { - let draconicList = [] - for (const item of this.data.items) { - if (item.type == "competence" && item.data.categorie == 'draconic' ) - draconicList.push(item); - } - return draconicList; + /* -------------------------------------------- */ + getDraconicList() { + return this.data.items.filter(item => item.data.categorie == 'draconic') } /* -------------------------------------------- */ diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 5e71b654..fe5b48ef 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -411,12 +411,7 @@ export class RdDUtility { /* -------------------------------------------- */ static findCompetence(compList, compName) { - for (const item of compList) { - if (item.name == compName) { - //console.log("Found item !", item); - return item; - } - } + return compList.find(item => item.name == compName && (item.type =="competence" || item.type =="competencecreature")) } /* -------------------------------------------- */