diff --git a/changelog.md b/changelog.md index d2e45754..1b1c70eb 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ # v10.7 - L'os de Sémolosse +## v10.7.20 - la poigne de Sémolosse +- correction de méthodes qui filtrent les items + - recherche de cases TMR + - recherche de tâches de lecture + - recherche d'armure (pour le malus armure) + - recherche de potions + ## v10.7.20 - la poigne de Sémolosse - correction de l'empoignade - les items d'empoignade sont ajoutés par le MJ quand nécessaire diff --git a/module/actor.js b/module/actor.js index 8c0f2581..725e4582 100644 --- a/module/actor.js +++ b/module/actor.js @@ -298,7 +298,7 @@ export class RdDActor extends RdDBaseActor { /* -------------------------------------------- */ async verifierPotionsEnchantees() { - let potionsEnchantees = this.filterItems(it => it.type == 'potion' && it.system.categorie.toLowerCase().includes('enchant')); + let potionsEnchantees = this.filterItems(it => it.system.categorie.toLowerCase().includes('enchant'), 'potion'); for (let potion of potionsEnchantees) { if (!potion.system.prpermanent) { console.log(potion); @@ -1124,7 +1124,7 @@ export class RdDActor extends RdDBaseActor { /* -------------------------------------------- */ async computeMalusArmure() { if (this.isPersonnage()) { - const malusArmure = this.filterItems(it => it.type == 'armure' && it.system.equipe) + const malusArmure = this.filterItems(it => it.system.equipe, 'armure') .map(it => it.system.malus ?? 0) .reduce(Misc.sum(), 0); // Mise à jour éventuelle du malus armure @@ -1297,8 +1297,7 @@ export class RdDActor extends RdDBaseActor { /* -------------------------------------------- */ buildTMRInnaccessible() { - const tmrInnaccessibles = this.filterItems(it => Draconique.isCaseTMR(it) && - EffetsDraconiques.isInnaccessible(it)); + const tmrInnaccessibles = this.filterItems(it => Draconique.isCaseTMR(it) && EffetsDraconiques.isInnaccessible(it)); return tmrInnaccessibles.map(it => it.system.coord); } @@ -2363,8 +2362,7 @@ export class RdDActor extends RdDBaseActor { /* -------------------------------------------- */ async creerTacheDepuisLivre(item, options = { renderSheet: true }) { const nomTache = "Lire " + item.name; - const filterTacheLecture = it => it.type == 'tache' && it.name == nomTache; - let tachesExistantes = this.filterItems(filterTacheLecture); + let tachesExistantes = findTache(nomTache); if (tachesExistantes.length == 0) { const tache = { name: nomTache, type: 'tache', @@ -2380,13 +2378,17 @@ export class RdDActor extends RdDBaseActor { } } await this.createEmbeddedDocuments('Item', [tache], options); - tachesExistantes = this.filterItems(filterTacheLecture); + tachesExistantes = findTache(nomTache) } return tachesExistantes.length > 0 ? tachesExistantes[0] : undefined; + + function findTache(name) { + return this.filterItems(it => it.name == name, 'tache'); + } } blessuresASoigner() { - // TODO or not TODO: filtrer les blessures poour lesquels on ne peut plus faire de premiers soins? + // TODO or not TODO: filtrer les blessures pour lesquelles on ne peut plus faire de premiers soins? return this.filterItems(it => it.system.gravite > 0 && it.system.gravite <= 6 && !(it.system.premierssoins.done && it.system.soinscomplets.done), 'blessure') } diff --git a/module/actor/base-actor.js b/module/actor/base-actor.js index 29e82b7e..ae7c35ff 100644 --- a/module/actor/base-actor.js +++ b/module/actor/base-actor.js @@ -119,7 +119,7 @@ export class RdDBaseActor extends Actor { } listItems(type = undefined) { return (type ? this.itemTypes[type] : this.items); } - filterItems(filter, type = undefined) { return type ? this.itemTypes[type]?.filter(filter) ?? [] : []; } + filterItems(filter, type = undefined) { return (type ? this.itemTypes[type] : this.items)?.filter(filter); } findItemLike(idOrName, type) { return this.getItem(idOrName, type) ?? Misc.findFirstLike(idOrName, this.listItems(type), { description: Misc.typeName('Item', type) }); diff --git a/system.json b/system.json index e25d61e5..2557aa2a 100644 --- a/system.json +++ b/system.json @@ -1,8 +1,8 @@ { "id": "foundryvtt-reve-de-dragon", "title": "Rêve de Dragon", - "version": "10.7.20", - "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.7.20.zip", + "version": "10.7.21", + "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.7.21.zip", "manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json", "compatibility": { "minimum": "10",