From b74fc27079b2cf72ea6c96f907d95bc8bdbb32ac Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Mon, 23 Oct 2023 23:37:47 +0200 Subject: [PATCH] Minor cleanup --- module/actor.js | 12 ++++++------ module/item-arme.js | 12 ++++++------ module/item-competencecreature.js | 2 +- module/time/rdd-calendrier.js | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/module/actor.js b/module/actor.js index 7aebcedd..be0b90cf 100644 --- a/module/actor.js +++ b/module/actor.js @@ -291,13 +291,13 @@ export class RdDActor extends RdDBaseActor { } getPossession(possessionId) { - return this.items.find(it => it.type == TYPES.possession && it.system.possessionid == possessionId); + return this.itemTypes[TYPES.possession].find(it => it.system.possessionid == possessionId); } getPossessions() { - return this.items.filter(it => it.type == TYPES.possession); + return this.itemTypes[TYPES.possession]; } getEmpoignades() { - return this.items.filter(it => it.type == TYPES.empoignade); + return this.itemTypes[TYPES.empoignade]; } getDemiReve() { return this.system.reve.tmrpos.coord; @@ -549,7 +549,7 @@ export class RdDActor extends RdDBaseActor { /* -------------------------------------------- */ async _recuperationBlessures(message, isMaladeEmpoisonne) { const timestamp = game.system.rdd.calendrier.getTimestamp() - const blessures = this.filterItems(it => it.system.gravite > 0, 'blessure').sort(Misc.ascending(it => it.system.gravite)) + const blessures = this.filterItems(it => it.system.gravite > 0, TYPES.blessure).sort(Misc.ascending(it => it.system.gravite)) await Promise.all(blessures.map(b => b.recuperationBlessure({ actor: this, @@ -563,7 +563,7 @@ export class RdDActor extends RdDBaseActor { } async supprimerBlessures(filterToDelete) { - const toDelete = this.filterItems(filterToDelete, 'blessure') + const toDelete = this.filterItems(filterToDelete, TYPES.blessure) .map(it => it.id); await this.deleteEmbeddedDocuments('Item', toDelete); } @@ -571,7 +571,7 @@ export class RdDActor extends RdDBaseActor { /* -------------------------------------------- */ async _recupererVie(message, isMaladeEmpoisonne) { const tData = this.system - let blessures = this.filterItems(it => it.system.gravite > 0, 'blessure'); + let blessures = this.filterItems(it => it.system.gravite > 0, TYPES.blessure); if (blessures.length > 0) { return } diff --git a/module/item-arme.js b/module/item-arme.js index b4f50d6c..f1fa40c7 100644 --- a/module/item-arme.js +++ b/module/item-arme.js @@ -20,14 +20,14 @@ const nomCategorieParade = { export class RdDItemArme extends Item { static isArme(item) { - return RdDItemCompetenceCreature.getCategorieAttaque(item) || item.type == 'arme'; + return RdDItemCompetenceCreature.getCategorieAttaque(item) || item.type == TYPES.arme; } /* -------------------------------------------- */ static getArme(arme) { switch (arme ? arme.type : '') { - case 'arme': return arme; - case 'competencecreature': + case TYPES.arme: return arme; + case TYPES.competencecreature: return RdDItemCompetenceCreature.armeCreature(arme); } return RdDItemArme.mainsNues(); @@ -68,14 +68,14 @@ export class RdDItemArme extends Item { return armeData.system.categorie_parade; } // pour compatibilité avec des personnages existants - if (armeData.type == 'competencecreature' || armeData.system.categorie == 'creature') { + if (armeData.type == TYPES.competencecreature || armeData.system.categorie == 'creature') { return armeData.system.categorie_parade || (armeData.system.isparade ? 'armes-naturelles' : ''); } if (!armeData.type.match(/arme|competencecreature/)) { return ''; } if (armeData.system.competence == undefined) { - return 'competencecreature'; + return TYPES.competencecreature; } let compname = armeData.system.competence.toLowerCase(); if (compname.match(/^(dague de jet|javelot|fouet|arc|arbalête|fronde|hache de jet|fléau)$/)) return ''; @@ -179,7 +179,7 @@ export class RdDItemArme extends Item { static corpsACorps(mainsNuesActor) { const corpsACorps = { name: 'Corps à corps', - type: 'arme', + type: TYPES.arme, img: 'systems/foundryvtt-reve-de-dragon/icons/competence_corps_a_corps.webp', system: { equipe: true, diff --git a/module/item-competencecreature.js b/module/item-competencecreature.js index 426a7aab..85f3f291 100644 --- a/module/item-competencecreature.js +++ b/module/item-competencecreature.js @@ -1,5 +1,5 @@ -import { RdDItem, TYPES } from "./item.js"; +import { TYPES } from "./item.js"; import { RdDCombatManager } from "./rdd-combat.js"; const categories = { diff --git a/module/time/rdd-calendrier.js b/module/time/rdd-calendrier.js index 0d62ca20..aeaadcc4 100644 --- a/module/time/rdd-calendrier.js +++ b/module/time/rdd-calendrier.js @@ -364,7 +364,7 @@ export class RdDCalendrier extends Application { if (request.rolled.isSuccess) { if (request.rolled.isPart) { // Gestion expérience (si existante) - request.competence = actor.getCompetence("astrologie") + request.competence = actor.getCompetence('Astrologie') request.selectedCarac = actor.system.carac["vue"]; actor.appliquerAjoutExperience(request, 'hide'); }