From a6ae7babbe7cd30d61ec87dd8133d1e650b62bd7 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Fri, 11 Oct 2024 00:15:15 +0200 Subject: [PATCH] Feuille PNJ suite --- changelog.md | 10 +++++ module/actor-sheet.js | 12 +++--- module/actor/base-actor-reve-sheet.js | 7 ++-- module/actor/base-actor-sang.js | 11 ++++- .../export-scriptarium/actor-encart-sheet.js | 39 +++++++++++++++--- templates/actor-creature-sheet.html | 4 +- templates/actor-entite-sheet.html | 4 +- templates/actor/carac-main.html | 4 +- .../export-scriptarium/actor-encart-sheet.hbs | 40 ++++++++++++++++--- .../actor/export-scriptarium/blessure.hbs | 5 +++ .../actor/export-scriptarium/blessures.hbs | 26 ++++++++++++ .../export-scriptarium/carac-compteur.hbs | 15 ++++--- .../carac-derivee-compteur.hbs | 19 +++------ .../export-scriptarium/carac-derivee.hbs | 2 +- templates/actor/export-scriptarium/carac.hbs | 2 +- .../actor/export-scriptarium/fatigue.hbs | 12 ++++++ templates/actor/header-buttons.html | 20 +++++----- templates/actor/header-hautreve.html | 12 +++--- 18 files changed, 175 insertions(+), 69 deletions(-) create mode 100644 templates/actor/export-scriptarium/blessure.hbs create mode 100644 templates/actor/export-scriptarium/blessures.hbs create mode 100644 templates/actor/export-scriptarium/fatigue.hbs diff --git a/changelog.md b/changelog.md index 04d5b726..19244f02 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,14 @@ # 12.0 +## 12.0.14 - Les légions d'Astrobazzarh +- Feuille de PNJ: + - boutons standard (encaissement, ...) + - boutons pour ajuster les compteurs + - visualisation des blessures + - click sur blessure pour ajouter/enlever + +## 12.0.13 - La Chance d'Astrobazzarh +- Fix: jets de caractéristiques + ## 12.0.12 - L'étalage d'Astrobazzarh - Fix: On peut de nouveau vendre des items sans propriétaire, depuis les compendiums ou depuis l'onglet des Objets - Début de Feuille PNJ au format des encarts Scriptarium diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 1a9d1567..faf3e52f 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -128,7 +128,7 @@ export class RdDActorSheet extends RdDBaseActorSangSheet { this.render(true); }); - this.html.find('.visu-tmr').click(async event => this.actor.displayTMR("visu")) + this.html.find('.button-tmr-visu').click(async event => this.actor.displayTMR("visu")) // Everything below here is only needed if the sheet is editable if (!this.options.editable) return; @@ -186,7 +186,7 @@ export class RdDActorSheet extends RdDBaseActorSangSheet { this.html.find('.item-equip').click(async event => this.actor.equiperObjet(RdDSheetUtility.getItemId(event))) this.html.find('.chance-actuelle').click(async event => this.actor.rollCarac('chance-actuelle')) - this.html.find('.chance-appel').click(async event => this.actor.rollAppelChance()) + this.html.find('.button-appel-chance').click(async event => this.actor.rollAppelChance()) this.html.find('[name="jet-astrologie"]').click(async event => this.actor.astrologieNombresAstraux()) this.html.find('.tache-label a').click(async event => this.actor.rollTache(RdDSheetUtility.getItemId(event))) @@ -234,10 +234,10 @@ export class RdDActorSheet extends RdDBaseActorSangSheet { }); // Display TMR - this.html.find('.monte-tmr').click(async event => this.actor.displayTMR("normal")) - this.html.find('.monte-tmr-rapide').click(async event => this.actor.displayTMR("rapide")) + this.html.find('.button-tmr').click(async event => this.actor.displayTMR("normal")) + this.html.find('.button-tmr-rapide').click(async event => this.actor.displayTMR("rapide")) - this.html.find('.repos').click(async event => await this.actor.repos()) + this.html.find('.button-repos').click(async event => await this.actor.repos()) this.html.find('.carac-xp-augmenter').click(async event => this.actor.updateCaracXPAuto(event.currentTarget.name.replace("augmenter.", ""))) this.html.find('.competence-xp-augmenter').click(async event => this.actor.updateCompetenceXPAuto(RdDSheetUtility.getItemId(event))) @@ -279,7 +279,7 @@ export class RdDActorSheet extends RdDBaseActorSangSheet { this.html.find('.moral-malheureux').click(async event => this.actor.jetDeMoral('malheureuse')) this.html.find('.moral-neutre').click(async event => this.actor.jetDeMoral('neutre')) this.html.find('.moral-heureux').click(async event => this.actor.jetDeMoral('heureuse')) - this.html.find('.ethylisme-test').click(async event => this.actor.jetEthylisme()) + this.html.find('.button-ethylisme').click(async event => this.actor.jetEthylisme()) this.html.find('.ptreve-actuel-plus').click(async event => this.actor.reveActuelIncDec(1)) this.html.find('.ptreve-actuel-moins').click(async event => this.actor.reveActuelIncDec(-1)) diff --git a/module/actor/base-actor-reve-sheet.js b/module/actor/base-actor-reve-sheet.js index 040a56c6..b57b0a8f 100644 --- a/module/actor/base-actor-reve-sheet.js +++ b/module/actor/base-actor-reve-sheet.js @@ -24,14 +24,15 @@ export class RdDBaseActorReveSheet extends RdDBaseActorSheet { // Everything below here is only needed if the sheet is editable if (!this.options.editable) return; - this.html.find('.encaisser-direct').click(async event => this.actor.encaisser()) - this.html.find('.roll-carac a').click(async event => this.actor.rollCarac(Grammar.toLowerCaseNoAccent(event.currentTarget.attributes.name.value))); + this.html.find('.button-encaissement').click(async event => this.actor.encaisser()) + this.html.find('.roll-carac').click(async event => { + this.actor.rollCarac(Grammar.toLowerCaseNoAccent(event.currentTarget.attributes['data-carac-name'].value))}); this.html.find('.roll-competence').click(async event => this.actor.rollCompetence(RdDSheetUtility.getItemId(event))); this.html.find('.endurance-plus').click(async event => this.actor.santeIncDec("endurance", 1)); this.html.find('.endurance-moins').click(async event => this.actor.santeIncDec("endurance", -1)); if (game.user.isGM) { - this.html.find('.remise-a-neuf').click(async event => this.actor.remiseANeuf()) + this.html.find('.button-remise-a-neuf').click(async event => this.actor.remiseANeuf()) this.html.find('.delete-active-effect').click(async event => this.actor.removeEffect(this.html.find(event.currentTarget).parents(".active-effect").data('effect'))); this.html.find('.enlever-tous-effets').click(async event => await this.actor.removeEffects()); } diff --git a/module/actor/base-actor-sang.js b/module/actor/base-actor-sang.js index 1a4ad1e5..6e784920 100644 --- a/module/actor/base-actor-sang.js +++ b/module/actor/base-actor-sang.js @@ -180,7 +180,7 @@ export class RdDBaseActorSang extends RdDBaseActorReve { } } const endActuelle = this.getEnduranceActuelle(); - const blessure = await RdDItemBlessure.createBlessure(this, encaissement.gravite, encaissement.dmg.loc.label, attacker); + const blessure = await RdDItemBlessure.createBlessure(this, encaissement.gravite, encaissement.dmg?.loc.label ??'', attacker); if (blessure.isCritique()) { encaissement.endurance = endActuelle; } @@ -196,6 +196,13 @@ export class RdDBaseActorSang extends RdDBaseActorReve { return blessure; } + async supprimerBlessure({gravite}) { + const toDelete = this.itemTypes[ITEM_TYPES.blessure].find(it => it.system.gravite == gravite)?.id + if (toDelete){ + await this.deleteEmbeddedDocuments('Item', [toDelete]); + } + } + async supprimerBlessures(filterToDelete) { const toDelete = this.filterItems(filterToDelete, ITEM_TYPES.blessure) .map(it => it.id); @@ -203,7 +210,7 @@ export class RdDBaseActorSang extends RdDBaseActorReve { } countBlessures(filter = it => !it.isContusion()) { - return this.filterItems(filter, 'blessure').length + return this.filterItems(filter, ITEM_TYPES.blessure).length } /* -------------------------------------------- */ diff --git a/module/actor/export-scriptarium/actor-encart-sheet.js b/module/actor/export-scriptarium/actor-encart-sheet.js index 8b997b95..cfd478a8 100644 --- a/module/actor/export-scriptarium/actor-encart-sheet.js +++ b/module/actor/export-scriptarium/actor-encart-sheet.js @@ -9,16 +9,19 @@ export class RdDActorExportSheet extends RdDActorSheet { static async init() { await loadTemplates([ "systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/arme.hbs", + "systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/blessure.hbs", + "systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/blessures.hbs", "systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/carac.hbs", "systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/carac-compteur.hbs", "systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/carac-derivee.hbs", "systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/carac-derivee-compteur.hbs", "systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/competences.hbs", "systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/esquive.hbs", + "systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/fatigue.hbs", "systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/protection.hbs", "systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/sort.hbs", ]) - Actors.registerSheet(SYSTEM_RDD, RdDActorExportSheet, { types: ["personnage"], makeDefault: false, label: "Feuille d'encart" }) + Actors.registerSheet(SYSTEM_RDD, RdDActorExportSheet, { types: ["personnage"], makeDefault: false, label: "Feuille simplifiée" }) } static get defaultOptions() { return foundry.utils.mergeObject(RdDActorSheet.defaultOptions, { @@ -39,6 +42,19 @@ export class RdDActorExportSheet extends RdDActorSheet { formData.export = this.getMappingValues(); formData.competences = this.getCompetences(CATEGORIES_COMPETENCES) formData.draconic = this.getCompetences(CATEGORIES_DRACONIC) + const legeres = this.actor.nbBlessuresLegeres() + const graves = this.actor.nbBlessuresGraves() + const critiques = this.actor.nbBlessuresCritiques() + formData.etat = { + surenc: this.actor.computeMalusSurEncombrement(), + fatigue: { + value: this.actor.getFatigueActuelle(), + max: this.actor.getFatigueMax(), + malus: this.actor.malusFatigue() + }, + blessures: legeres + graves + critiques, + blessure: [legeres > 0, legeres > 1, legeres > 2, legeres > 3, legeres > 4, graves > 0, graves > 1, critiques > 0], + } formData.options.exportScriptarium = OptionsAvancees.isUsing(EXPORT_CSV_SCRIPTARIUM) return formData } @@ -49,10 +65,10 @@ export class RdDActorExportSheet extends RdDActorSheet { colName: it.colName ?? it.column, column: it.column, rollClass: it.rollClass, - value: it.getter(this.actor, context) + value: String(it.getter(this.actor, context)) }])) } - + getCompetences(categories) { const competences = Mapping.getCompetencesCategorie(this.actor, categories) if (competences.length == 0) { @@ -68,7 +84,7 @@ export class RdDActorExportSheet extends RdDActorSheet { } const listCategorieByNiveau = niveaux.map(niveau => { const list = byNiveau[niveau].sort(Misc.ascending(it => it.name)) - return {niveau, list} + return { niveau, list } }) return Misc.concat(listCategorieByNiveau) }).filter(it => it != undefined) @@ -78,9 +94,20 @@ export class RdDActorExportSheet extends RdDActorSheet { activateListeners(html) { super.activateListeners(html); + + this.html.find('.click-blessure-remove').click(async event => + await this.actor.supprimerBlessure({ + gravite: this.html.find(event.currentTarget).data('gravite') + }) + ) + this.html.find('.click-blessure-add').click(async event => + await this.actor.ajouterBlessure({ + gravite: this.html.find(event.currentTarget).data('gravite') + // event.currentTarget.attributes['data-gravite'].value + }) + ) this.html.find('.button-export').click(async event => { - - ExportScriptarium.INSTANCE.exportActors([this.actor], + ExportScriptarium.INSTANCE.exportActors([this.actor], `${this.actor.uuid}-${this.actor.name}` ) }) diff --git a/templates/actor-creature-sheet.html b/templates/actor-creature-sheet.html index 2b63d62c..215fbf10 100644 --- a/templates/actor-creature-sheet.html +++ b/templates/actor-creature-sheet.html @@ -9,9 +9,9 @@

- + {{#if @root.options.isGM}} - + {{/if}}
diff --git a/templates/actor-entite-sheet.html b/templates/actor-entite-sheet.html index 93d93e88..3c8535b9 100644 --- a/templates/actor-entite-sheet.html +++ b/templates/actor-entite-sheet.html @@ -9,9 +9,9 @@

- + {{#if @root.options.isGM}} - + {{/if}}
diff --git a/templates/actor/carac-main.html b/templates/actor/carac-main.html index 8f31c909..3ed28231 100644 --- a/templates/actor/carac-main.html +++ b/templates/actor/carac-main.html @@ -7,7 +7,7 @@