From 1a346a21c350eafb3a0181c0d708e732b1a02ef4 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Tue, 7 Feb 2023 18:05:25 +0100 Subject: [PATCH 1/3] Recherche dans les commerces --- module/actor/base-actor-sheet.js | 42 +++++++++---------- templates/actor/commerce-inventaire-item.html | 2 + templates/actor/commerce-inventaire.html | 3 ++ 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/module/actor/base-actor-sheet.js b/module/actor/base-actor-sheet.js index c4d09424..ea512b1c 100644 --- a/module/actor/base-actor-sheet.js +++ b/module/actor/base-actor-sheet.js @@ -52,28 +52,28 @@ export class RdDBaseActorSheet extends ActorSheet { this.objetVersConteneur = RdDUtility.buildArbreDeConteneurs(formData.conteneurs, formData.objets); formData.conteneurs = RdDUtility.conteneursRacine(formData.conteneurs); - this._appliquerRechercheObjets(formData.objets, formData.conteneurs, this.options.recherche); + this._appliquerRechercheObjets(formData.objets, formData.conteneurs); return formData; } - _appliquerRechercheObjets(objets, conteneurs, recherche) { - if (recherche) { - this._setConteneursVisibles(objets, conteneurs); + _appliquerRechercheObjets(objets, conteneurs) { + if (this.options.recherche?.text) { + const recherche = this.options.recherche; + const allVisible = objets.filter(it => it.isNomTypeLike(recherche.text)).map(it => it.id); + let addVisible = conteneurs.filter(it => it.isNomTypeLike(recherche.text)).map(it => it.id) + do { + allVisible.push(...addVisible) + const parentsIds = conteneurs.filter(it => it.system.contenu.find(id => allVisible.includes(id))).map(it => it.id) + addVisible = parentsIds.filter(id => !allVisible.includes(id)) + } + while (addVisible.length > 0) + objets.forEach(it => it.system.isHidden = !allVisible.includes(it.id)) + conteneurs.forEach(it => it.system.isHidden = !allVisible.includes(it.id)) } - } - - _setConteneursVisibles(objets, conteneurs) { - const recherche = this.options.recherche; - const allVisible = objets.filter(it => it.isNomTypeLike(recherche.text)).map(it => it.id); - let addVisible = conteneurs.filter(it => it.isNomTypeLike(recherche.text)).map(it => it.id) - do { - allVisible.push(...addVisible) - const parentsIds = conteneurs.filter(it => it.system.contenu.find(id => allVisible.includes(id))).map(it => it.id) - addVisible = parentsIds.filter(id => !allVisible.includes(id)) + else { + objets.forEach(it => it.system.isHidden = false) + conteneurs.forEach(it => it.system.isHidden = false) } - while (addVisible.length > 0) - objets.forEach(it => it.system.isHidden = !allVisible.includes(it.id)) - conteneurs.forEach(it => it.system.isHidden = !allVisible.includes(it.id)) } /* -------------------------------------------- */ @@ -164,12 +164,8 @@ export class RdDBaseActorSheet extends ActorSheet { .each((index, field) => { this._rechercheSelectArea(field); }) - .keyup(async event => { - this._rechercherKeyup(event); - }) - .change(async event => - this.options.recherche = this._optionRecherche(event.currentTarget) - ); + .keyup(async event => this._rechercherKeyup(event)) + .change(async event => this._rechercherKeyup(event)); } _rechercherKeyup(event) { diff --git a/templates/actor/commerce-inventaire-item.html b/templates/actor/commerce-inventaire-item.html index e057f84c..5a8683ce 100644 --- a/templates/actor/commerce-inventaire-item.html +++ b/templates/actor/commerce-inventaire-item.html @@ -1,3 +1,4 @@ +{{#unless item.system.isHidden}} {{#if (ne item.type 'monnaie')}}
  • @@ -57,3 +58,4 @@
  • {{/if}} +{{/unless}} \ No newline at end of file diff --git a/templates/actor/commerce-inventaire.html b/templates/actor/commerce-inventaire.html index f4fc2b81..16f95c72 100644 --- a/templates/actor/commerce-inventaire.html +++ b/templates/actor/commerce-inventaire.html @@ -4,6 +4,9 @@ Nouvel objet Tout vider {{/if}} + + + {{#unless system.illimite}} {{#if calc.surEncombrementMessage}}{{calc.surEncombrementMessage}} ‐{{/if}} From 4ee44458361da469fd9f221da4e7b8a17c72ce2a Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Tue, 7 Feb 2023 18:06:15 +0100 Subject: [PATCH 2/3] Fix: message sur jet de moral neutre --- module/actor.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/module/actor.js b/module/actor.js index f6cade15..acf82344 100644 --- a/module/actor.js +++ b/module/actor.js @@ -457,7 +457,20 @@ export class RdDActor extends RdDBaseActor { async _jetDeMoralChateauDormant(message) { const jetMoral = await this._jetDeMoral('neutre'); - message.content += jetMoral.ajustement == 0 ? ' -- le moral reste stable' : ' -- le moral retourne vers 0'; + message.content += ' -- le moral ' + this._messageAjustementMoral(jetMoral.ajustement); + } + _messageAjustementMoral(ajustement) { + switch (Math.sign(ajustement)) { + case 1: + return `remonte de ${ajustement}`; + case -1: + return `diminue de ${-ajustement}`; + case 0: + return 'reste stable'; + default: + console.error(`Le signe de l'ajustement de moral ${ajustement} est ${Math.sign(ajustement)}, ce qui est innatendu`) + return `est ajusté de ${ajustement} (bizarre)`; + } } /* -------------------------------------------- */ From 59641bf5cf00249b792b20a96a2e696448fc6adb Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Tue, 7 Feb 2023 18:08:13 +0100 Subject: [PATCH 3/3] Version 10.6.13 Recherche dans les commerces --- system.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system.json b/system.json index 18d4a7c5..1b2908d1 100644 --- a/system.json +++ b/system.json @@ -1,8 +1,8 @@ { "id": "foundryvtt-reve-de-dragon", "title": "Rêve de Dragon", - "version": "10.6.12", - "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.6.12.zip", + "version": "10.6.13", + "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.6.13.zip", "manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json", "compatibility": { "minimum": "10",