From 9ccc06833377ba3cbad22321a49592c38f923273 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Fri, 1 May 2026 22:28:55 +0200 Subject: [PATCH] =?UTF-8?q?Am=C3=A9lioration=20du=20moral?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Les bon moments sont affichés en tooltips sur le moral Simplification moralIncDec: Utilisation d'un seul update --- changelog.md | 4 +++ module/actor.js | 28 ++++++++++----------- module/rdd-utility.js | 4 ++- templates/actor/carac-derivee.hbs | 2 +- templates/actor/tooltip-bonmoments.hbs | 10 ++++++++ templates/item/gemme-sheet.hbs | 1 - templates/roll/result/partial-apprecier.hbs | 6 ++++- templates/roll/result/partial-infojet.hbs | 1 - 8 files changed, 37 insertions(+), 19 deletions(-) create mode 100644 templates/actor/tooltip-bonmoments.hbs diff --git a/changelog.md b/changelog.md index 5d7baedd..7f655cd3 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,9 @@ # 13.0 +## 13.0.36 - Le bonheur des zyglutes d'Illisys + +- Les bon moments sont affichés en tooltip sur le moral + ## 13.0.36 - Les rêveries d'Illisys - Corrections v14 diff --git a/module/actor.js b/module/actor.js index 48a71bec..3b0a1d15 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1174,7 +1174,7 @@ export class RdDActor extends RdDBaseActorSang { /* -------------------------------------------- */ getSConst() { return RdDCarac.calculSConst(this.getConstitution()) } - + async _gainXpConstitutionJetEndurance() { await this.updateCaracXP('constitution', Misc.toInt(this.system.carac.constitution.xp) + 1) return `${this.name} a obtenu 1 sur son Jet d'Endurance et a gagné 1 point d'Expérience en Constitution. Ce point d'XP a été ajouté automatiquement.`; @@ -1214,22 +1214,22 @@ export class RdDActor extends RdDBaseActorSang { /* -------------------------------------------- */ async moralIncDec(ajustement, bonmoment = "") { - let moral = parseInt(this.system.compteurs.moral.value) + const moral = parseInt(this.system.compteurs.moral.value); if (ajustement != 0) { - if (ajustement > 0 && bonmoment != "" && bonmoment != undefined) { - await this.update({ 'system.compteurs.bonmoments': [...this.system.compteurs.bonmoments, bonmoment] }) - } const moralTheorique = moral + ajustement - if (moralTheorique > 3) { // exaltation - const exaltation = parseInt(this.system.compteurs.exaltation.value) + moralTheorique - 3 - await this.update({ 'system.compteurs.exaltation.value': exaltation }) + const newExaltation = parseInt(this.system.compteurs.exaltation.value) + Math.max(0, moralTheorique - 3) + const newDissolution = parseInt(this.system.compteurs.dissolution.value) + Math.max(0, - moralTheorique - 3) + const newMoral = Math.max(-3, Math.min(moralTheorique, 3)) + const moralUpdates = { + 'system.compteurs.exaltation.value': newExaltation, + 'system.compteurs.dissolution.value': newDissolution, + 'system.compteurs.moral.value': newMoral } - if (moralTheorique < -3) { // dissolution - const dissolution = parseInt(this.system.compteurs.dissolution.value) - 3 - moralTheorique - await this.update({ 'system.compteurs.dissolution.value': dissolution }) + if (ajustement > 0 && bonmoment != "" && bonmoment != undefined && !this.system.compteurs.bonmoments.includes(bonmoment)) { + moralUpdates['system.compteurs.bonmoments'] = [...this.system.compteurs.bonmoments, bonmoment] } - moral = Math.max(-3, Math.min(moralTheorique, 3)); - await this.update({ 'system.compteurs.moral.value': moral }) + await this.update(moralUpdates) + return newMoral } return moral } @@ -1571,7 +1571,7 @@ export class RdDActor extends RdDBaseActorSang { /* -------------------------------------------- */ async checkCompetenceXP(compName, newXP, display = true) { - return this.getCompetence(compName)?.checkCompetenceXP( newXP, display) + return this.getCompetence(compName)?.checkCompetenceXP(newXP, display) } /* -------------------------------------------- */ diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 46b54453..d6cf6c02 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -132,9 +132,9 @@ export class RdDUtility { 'systems/foundryvtt-reve-de-dragon/templates/actor/carac-derivee.hbs', 'systems/foundryvtt-reve-de-dragon/templates/actor/carac-creature.hbs', 'systems/foundryvtt-reve-de-dragon/templates/actor/carac-entitee.hbs', + 'systems/foundryvtt-reve-de-dragon/templates/actor/carac-total.hbs', 'systems/foundryvtt-reve-de-dragon/templates/actor/comp-creature.hbs', 'systems/foundryvtt-reve-de-dragon/templates/actor/comp-possession.hbs', - 'systems/foundryvtt-reve-de-dragon/templates/actor/carac-total.hbs', 'systems/foundryvtt-reve-de-dragon/templates/actor/competence.hbs', 'systems/foundryvtt-reve-de-dragon/templates/actor/competence-categorie.hbs', 'systems/foundryvtt-reve-de-dragon/templates/actor/xp-competences.hbs', @@ -173,6 +173,7 @@ export class RdDUtility { 'systems/foundryvtt-reve-de-dragon/templates/actor/liens-vehicules.hbs', 'systems/foundryvtt-reve-de-dragon/templates/actor/commerce-inventaire.hbs', 'systems/foundryvtt-reve-de-dragon/templates/actor/commerce-inventaire-item.hbs', + 'systems/foundryvtt-reve-de-dragon/templates/actor/tooltip-bonmoments.hbs', //Items 'systems/foundryvtt-reve-de-dragon/templates/scripts/autocomplete-script.hbs', 'systems/foundryvtt-reve-de-dragon/templates/scripts/autocomplete.hbs', @@ -300,6 +301,7 @@ export class RdDUtility { Handlebars.registerHelper('grammar-un', str => Grammar.articleIndetermine(str)); Handlebars.registerHelper('grammar-accord', (genre, ...args) => Grammar.accord(genre, args)); Handlebars.registerHelper('json-stringify', object => JSON.stringify(object)) + Handlebars.registerHelper('escapeHtml', object => foundry.utils.escapeHTML(object)) // math Handlebars.registerHelper('math-sum', (...values) => values.slice(0, -1).reduce(Misc.sum(), 0)) diff --git a/templates/actor/carac-derivee.hbs b/templates/actor/carac-derivee.hbs index 3130608a..067e149c 100644 --- a/templates/actor/carac-derivee.hbs +++ b/templates/actor/carac-derivee.hbs @@ -21,7 +21,7 @@
  • -