From db8fd6dbf868525309bd26cf32f3cf569151bfb9 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sat, 3 Dec 2022 22:01:06 +0100 Subject: [PATCH] Meilleur post to tchat --- module/environnement.js | 7 +-- module/item.js | 97 +++++++++++++++++++++-------------------- 2 files changed, 51 insertions(+), 53 deletions(-) diff --git a/module/environnement.js b/module/environnement.js index 8f14e477..3b5e3221 100644 --- a/module/environnement.js +++ b/module/environnement.js @@ -132,12 +132,6 @@ export class EnvironmentSheetHelper { }); } - /* -------------------------------------------- */ - static getHeaderButtons(sheet, buttons) { - buttons.unshift({ class: "post", icon: "fas fa-comment", onclick: ev => sheet.item.postItem() }); - return buttons; - } - static setPosition(sheet, superPosition) { const position = superPosition; const sheetHeader = sheet.element.find(".sheet-header"); @@ -155,6 +149,7 @@ export class EnvironmentSheetHelper { static activateListeners(sheet, html) { if (!sheet.options.editable) return; + html.find("input.input-selection-milieu").keypress(event => { if (event.keyCode == '13') { EnvironmentSheetHelper.onAddMilieu(html, sheet, event); diff --git a/module/item.js b/module/item.js index 7a19f3be..060151bc 100644 --- a/module/item.js +++ b/module/item.js @@ -333,7 +333,7 @@ export class RdDItem extends Item { /* -------------------------------------------- */ getProprietes() { - return this[`_${this.type}ChatData`](); + return this[`_${this.type}ChatData`]().filter(it => it != undefined); } /* -------------------------------------------- */ @@ -357,29 +357,31 @@ export class RdDItem extends Item { }); } - static propertyIfDefined(name, val, condition = (it) => true) { - return condition ? [`${name}: ${val}`] : []; + static propertyIfDefined(name, val, condition = true) { + return condition ? `${name}: ${val}` : undefined; } + _inventaireTemplateChatData() { + return [ + RdDItem.propertyIfDefined('Qualité', this.system.qualite, this.system.qualite != 0), + RdDItem.propertyIfDefined('Encombrement', this.system.encombrement) + // cout et quantité masqués + ] + } /* -------------------------------------------- */ _objetChatData() { - return [].concat( - RdDItem.propertyIfDefined('Résistance', this.system.resistance, this.system.resistance), - RdDItem.propertyIfDefined('Qualité', this.system.qualite, this.system.qualite), - RdDItem.propertyIfDefined('Encombrement', this.system.encombrement), - ); + return this._inventaireTemplateChatData() } /* -------------------------------------------- */ _nourritureboissonChatData() { - return [].concat( + return [ RdDItem.propertyIfDefined('Sustentation', this.system.sust, this.system.sust > 0), RdDItem.propertyIfDefined('Désaltère', this.system.desaltere, this.system.boisson), RdDItem.propertyIfDefined('Force alcool', this.system.force, this.system.boisson && this.system.alcoolise), RdDItem.propertyIfDefined('Exotisme', this.system.exotisme, this.system.exotisme < 0), - RdDItem.propertyIfDefined('Qualité', this.system.qualite, this.system.qualite), - RdDItem.propertyIfDefined('Encombrement', this.system.encombrement), - ); + ...this._inventaireTemplateChatData() + ] } /* -------------------------------------------- */ _armeChatData() { @@ -388,21 +390,19 @@ export class RdDItem extends Item { `Dommages: ${this.system.dommages}`, `Force minimum: ${this.system.force}`, `Resistance: ${this.system.resistance}`, - `Encombrement: ${this.system.encombrement}` + ...this._inventaireTemplateChatData() ] } /* -------------------------------------------- */ _conteneurChatData() { return [ `Capacité: ${this.system.capacite} Enc.`, - `Encombrement: ${this.system.encombrement}` + ...this._inventaireTemplateChatData() ] } /* -------------------------------------------- */ _munitionChatData() { - return [ - `Encombrement: ${this.system.encombrement}` - ] + return this._inventaireTemplateChatData() } /* -------------------------------------------- */ _armureChatData() { @@ -410,7 +410,7 @@ export class RdDItem extends Item { `Protection: ${this.system.protection}`, `Détérioration: ${this.system.deterioration}`, `Malus armure: ${this.system.malus}`, - `Encombrement: ${this.system.encombrement}` + ...this._inventaireTemplateChatData() ] } /* -------------------------------------------- */ @@ -444,16 +444,16 @@ export class RdDItem extends Item { _herbeChatData() { return [ `Milieu: ${this.system.milieu}`, - `Rareté: ${this.system.rarete}`, `Catégorie: ${this.system.categorie}`, + ...this._inventaireTemplateChatData() ] } /* -------------------------------------------- */ _ingredientChatData() { return [ `Milieu: ${this.system.milieu}`, - `Rareté: ${this.system.rarete}`, `Catégorie: ${this.system.categorie}`, + ...this._inventaireTemplateChatData() ] } /* -------------------------------------------- */ @@ -463,12 +463,9 @@ export class RdDItem extends Item { `Compétence: ${this.system.competence}`, `Périodicité: ${this.system.periodicite}`, `Fatigue: ${this.system.fatigue}`, - `Difficulté: ${this.system.difficulte}` - ].concat([ - this.system.cacher_points_de_tache ? [] : `Points de Tâche: ${this.system.points_de_tache}` - ]).concat([ + `Difficulté: ${this.system.difficulte}`, + RdDItem.propertyIfDefined('Points de Tâche', this.system.points_de_tache, this.system.cacher_points_de_tache), `Points de Tâche atteints: ${this.system.points_de_tache_courant}`] - ); } /* -------------------------------------------- */ _livreChatData() { @@ -476,8 +473,8 @@ export class RdDItem extends Item { `Compétence: ${this.system.competence}`, `Auteur: ${this.system.auteur}`, `Difficulté: ${this.system.difficulte}`, - `Points de Tâche: ${this.system.points_de_tache}`, - `Encombrement: ${this.system.encombrement}` + RdDItem.propertyIfDefined('Points de Tâche', this.system.points_de_tache, this.system.cacher_points_de_tache), + ...this._inventaireTemplateChatData() ] } /* -------------------------------------------- */ @@ -485,32 +482,44 @@ export class RdDItem extends Item { return [ `Rareté: ${this.system.rarete}`, `Catégorie: ${this.system.categorie}`, - `Encombrement: ${this.system.encombrement}`, + ...this._inventaireTemplateChatData() ] } /* -------------------------------------------- */ _queueChatData() { + function label(categorie) { + switch (categorie) { + case 'ideefixe': return 'Idée fixe'; + case 'lancinant': return 'Désir lancinant'; + } + return '' + } return [ - `Refoulement: ${this.system.refoulement}` + `Refoulement: ${this.system.refoulement}`, + `Catégorie: ${label(this.system.categorie)}`, + `Affecte: ${this.system.hautrevant ? 'les haut-rêvants' : 'tout le monde'}`, ] } /* -------------------------------------------- */ _ombreChatData() { - return [ - `Refoulement: ${this.system.refoulement}` - ] + return this._queueChatData() } /* -------------------------------------------- */ _souffleChatData() { - return []; + return [ + `Affecte: ${this.system.hautrevant ? 'les haut-rêvants' : 'tout le monde'}`, + ]; } /* -------------------------------------------- */ _teteChatData() { - return []; + return [ + `Affecte: ${this.system.hautrevant ? 'les haut-rêvants' : 'tout le monde'}`, + ]; } /* -------------------------------------------- */ _tarotChatData() { return [ + RdDItem.propertyIfDefined('Carte', RdDUtility.linkCompendium(this.pack, this.id, this.name), this.pack), `Concept: ${this.system.concept}`, `Aspect: ${this.system.aspect}`, ] @@ -524,10 +533,7 @@ export class RdDItem extends Item { } /* -------------------------------------------- */ _monnaieChatData() { - return [ - `Valeur en Sols: ${this.system.cout}`, - `Encombrement: ${this.system.encombrement}` - ] + return this._inventaireTemplateChatData() } /* -------------------------------------------- */ _meditationChatData() { @@ -551,9 +557,9 @@ export class RdDItem extends Item { ] } return [ - `Force: ${this.system.force}`, + `Force: ${this.system.formule}`, `Refoulement: ${this.system.refoulement}`, - `Présent de cités: ${this.system.presentCite}`, + RdDItem.propertyIfDefined('Présent de cités', '', this.system.presentCite), ] } /* -------------------------------------------- */ @@ -568,15 +574,12 @@ export class RdDItem extends Item { if (!this.system.identifie) { return [`Inconnue`] } - let properties = [ + return [ `Malignité: ${this.system.malignite}`, `Périodicité: ${this.system.periodicite}`, - `Dommages: ${this.system.dommages}` + `Dommages: ${this.system.dommages}`, + RdDItem.propertyIfDefined('Remedes', this.system.remedes, this.system.remedesconnus), ] - if (this.system.remedesconnus) { - properties.push(`Remedes: ${this.system.remedes}`) - } - return properties; } /* -------------------------------------------- */ @@ -591,7 +594,7 @@ export class RdDItem extends Item { `Taille: ${this.system.taille}`, `Inertie: ${this.system.inertie}`, `Enchantabilité: ${this.system.enchantabilite}`, - `Prix: ${this.system.cout}`, + ...this._inventaireTemplateChatData() ] }