diff --git a/module/actor.js b/module/actor.js index b4c90d44..87bd3385 100644 --- a/module/actor.js +++ b/module/actor.js @@ -3163,7 +3163,7 @@ export class RdDActor extends RdDBaseActor { /* -------------------------------------------- */ async equiperObjet(itemID) { let item = this.getEmbeddedDocument('Item', itemID); - if (item && ['arme', 'armure'].includes(item.type)) { + if (item?.isEquipable()) { const isEquipe = !item.system.equipe; await this.updateEmbeddedDocuments('Item', [{ _id: item.id, "system.equipe": isEquipe }]); this.computeEncTotal(); // Mise à jour encombrement diff --git a/module/item.js b/module/item.js index 4fc78004..679dd9da 100644 --- a/module/item.js +++ b/module/item.js @@ -34,6 +34,7 @@ const typesObjetsConnaissance = ["meditation", "recettealchimique", "sort"] const typesObjetsEffet = ["possession", "poison", "maladie", "blessure"] const typesObjetsCompetence = ["competence", "competencecreature"] const typesObjetsTemporels = ["blessure", "poison", "maladie", "queue", "ombre", "souffle", "signedraconique", "rencontre"] +const typesObjetsEquipable = ['arme', 'armure', 'objet']; const typesEnvironnement = typesInventaireMateriel; const encBrin = 0.00005; // un brin = 1 décigramme = 1/10g = 1/10000kg = 1/20000 enc const encPepin = 0.0007; /* un pépin de gemme = 1/10 cm3 = 1/1000 l = 3.5/1000 kg = 7/2000 kg = 7/1000 enc @@ -81,6 +82,10 @@ export const defaultItemImg = { /* -------------------------------------------- */ export class RdDItem extends Item { + static get defaultIcon() { + return undefined; + } + static getDefaultImg(itemType) { return game.system.rdd.itemClasses[itemType]?.defaultIcon ?? defaultItemImg[itemType]; } @@ -139,10 +144,6 @@ export class RdDItem extends Item { super(docData, context); } - static get defaultIcon() { - return undefined; - } - getUniteQuantite() { switch (this.type) { case "monnaie": return "(Pièces)" @@ -158,6 +159,10 @@ export class RdDItem extends Item { return ''; } + isEquipable() { + return typesObjetsEquipable.includes(this.type) + } + isCompetencePersonnage() { return this.type == 'competence' } isCompetenceCreature() { return this.type == 'competencecreature' } isConteneur() { return this.type == 'conteneur'; } @@ -367,6 +372,7 @@ export class RdDItem extends Item { } this.system.actionPrincipale = this.getActionPrincipale({ warnIfNot: false }); } + this.equipable = this.isEquipable(); } prepareDataPotion() { diff --git a/template.json b/template.json index 785059c7..2c7bf2e6 100644 --- a/template.json +++ b/template.json @@ -692,7 +692,7 @@ "capacite": 0 }, "objet": { - "templates": ["description", "inventaire"] + "templates": ["description", "equipement", "inventaire"] }, "monnaie": { "templates": ["description", "inventaire"] diff --git a/templates/actor/inventaire-item.html b/templates/actor/inventaire-item.html index a658fb12..79ba1eaf 100644 --- a/templates/actor/inventaire-item.html +++ b/templates/actor/inventaire-item.html @@ -28,7 +28,7 @@ {{#if options.isOwner}} {{#unless item.estContenu}} - {{#if (or (eq item.type 'arme') (eq item.type 'armure') )}} + {{#if item.equipable}} {{#if item.system.equipe}}{{else}}{{/if}} {{/if}} {{/unless}}