From fa75828bc1dfdcafb3b4090828dff7d15c7aa478 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Fri, 14 Oct 2022 00:40:56 +0200 Subject: [PATCH] =?UTF-8?q?Fix:=20r=C3=A9gression=20lancer=20de=20sorts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A cause du duplicate, les voies n'étaient plus des RdDItem, du coup, la méthode isCompetence de la recherche de compétences ne marche pas... Et le duplicate était inutile de toutes façons. --- module/actor.js | 7 +------ module/item-competence.js | 15 +++++++++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/module/actor.js b/module/actor.js index e21d8d0c..e7de17ce 100644 --- a/module/actor.js +++ b/module/actor.js @@ -2293,12 +2293,7 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ computeDraconicAndSortIndex(sortList) { - let draconicList = this.getDraconicList() - .map(it => { - it = duplicate(it) - it.system.defaut_carac = "reve"; - return it; - }); + let draconicList = this.getDraconicList(); for (let sort of sortList) { let draconicsSort = this.getDraconicsSort(draconicList, sort).map(it => it.name); for (let index = 0; index < draconicList.length && sort.system.listIndex == undefined; index++) { diff --git a/module/item-competence.js b/module/item-competence.js index 9530f0c9..c2cdcb78 100644 --- a/module/item-competence.js +++ b/module/item-competence.js @@ -84,7 +84,10 @@ export class RdDItemCompetence extends Item { /* -------------------------------------------- */ static getVoieDraconic(competences, voie) { - return RdDItemCompetence.findCompetence(competences.filter(it => RdDItemCompetence.isDraconic(it)), voie); + return RdDItemCompetence.findFirstItem(competences, voie, { + preFilter: it => it.isCompetence() && RdDItemCompetence.isDraconic(it), + description: 'Draconic', + }); } /* -------------------------------------------- */ @@ -219,9 +222,8 @@ export class RdDItemCompetence extends Item { if (idOrName == undefined) { return undefined; } - options = mergeObject(options, { preFilter: it => it.isCompetence(), description: 'compétence', }); - return list.find(it => it.id == idOrName && it.isCompetence()) - ?? Misc.findFirstLike(idOrName, list, options); + options = mergeObject(options, { preFilter: it => it.isCompetence(), description: 'compétence' }, {overwrite: false}); + return RdDItemCompetence.findFirstItem(list, idOrName, options); } /* -------------------------------------------- */ @@ -229,6 +231,11 @@ export class RdDItemCompetence extends Item { return Misc.findAllLike(name, list, { filter: it => it.isCompetence(), description: 'compétence' }); } + static findFirstItem(list, idOrName, options) { + return list.find(it => it.id == idOrName && options.preFilter(it)) + ?? Misc.findFirstLike(idOrName, list, options); + } + /* -------------------------------------------- */ static getCompetenceNextXp(niveau) { return RdDItemCompetence.getCompetenceXp(niveau + 1);