From 80cac2fadb44a26036f1c10037a448f2ac12f5a3 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sun, 14 Dec 2025 21:35:43 +0100 Subject: [PATCH] =?UTF-8?q?Recherche=20des=20caract=C3=A9ristiques=20de=20?= =?UTF-8?q?cr=C3=A9ature?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit La recherche des caractéristiques de créatures cherche aussi dans les caractéristiques de leurs compétences --- module/actor/base-actor.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/module/actor/base-actor.js b/module/actor/base-actor.js index ba3f84b8..2113c8a1 100644 --- a/module/actor/base-actor.js +++ b/module/actor/base-actor.js @@ -23,7 +23,7 @@ export class RdDBaseActor extends Actor { } static $findCaracByName(carac, name) { - const caracList = Object.entries(carac); + const caracList = Object.entries(carac) let entry = Misc.findFirstLike(name, caracList, { mapper: it => it[0], description: 'caractéristique', onMessage: m => { } }); if (!entry || entry.length == 0) { entry = Misc.findFirstLike(name, caracList, { mapper: it => it[1].label, description: 'caractéristique' }); @@ -166,14 +166,22 @@ export class RdDBaseActor extends Actor { return this.system.sante.vie } - const carac = this.system.carac; + const carac = {} + foundry.utils.mergeObject(carac, this.system.carac, { overwrite: false }) + foundry.utils.mergeObject(carac, this.getCaracCompetenceCreature(), { overwrite: false }) return RdDBaseActor.$findCaracByName(carac, name); } + getCaracCompetenceCreature() { + return this.isCreatureOuEntite() + ? Object.fromEntries(this.itemTypes[ITEM_TYPES.competencecreature].map(it => [Grammar.toLowerCaseNoAccent(it.name), { label: it.name, value: it.system.carac_value }])) + : {} + } + mapCarac(caracCode) { return caracCode } getCaracByName(name) { - name = this.mapCarac(Grammar.toLowerCaseNoAccent(name)) + name = this.mapCarac(Grammar.toLowerCaseNoAccent(name)) ?? name switch (name) { case 'reve-actuel': case 'reve actuel': return this.getCaracReveActuel();