Equiper des vêtements, bijoux, ...

Permettre d'équiper les objets "de base" en plus des armes et armures
This commit is contained in:
Vincent Vandemeulebrouck 2023-04-18 22:16:18 +02:00
parent 1b6c5256cc
commit 40c45c30de
4 changed files with 13 additions and 7 deletions

View File

@ -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

View File

@ -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() {

View File

@ -692,7 +692,7 @@
"capacite": 0
},
"objet": {
"templates": ["description", "inventaire"]
"templates": ["description", "equipement", "inventaire"]
},
"monnaie": {
"templates": ["description", "inventaire"]

View File

@ -28,7 +28,7 @@
<span class="equipement-actions item-controls">
{{#if options.isOwner}}
{{#unless item.estContenu}}
{{#if (or (eq item.type 'arme') (eq item.type 'armure') )}}
{{#if item.equipable}}
<a class="item-equip" title="Equiper">{{#if item.system.equipe}}<i class="fas fa-hand-rock"></i>{{else}}<i class="far fa-hand-paper"></i>{{/if}}</a>
{{/if}}
{{/unless}}