From 941548fcad3e4d355cb76256533a5467fa66fbdc Mon Sep 17 00:00:00 2001 From: LeRatierBretonnier Date: Sun, 29 Mar 2026 21:51:06 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20d=C3=A9river=20lvl=20des=20jauges=20(ble?= =?UTF-8?q?ssures/destin/spleen)=20depuis=20les=20cases=20coch=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Les niveaux sont maintenant calculés automatiquement dans prepareDerivedData() plutôt que stockés indépendamment — décocher une case met correctement lvl à jour. Suppression des inputs manuels lvl dans le template (inutiles car dérivés). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- module/models/character.mjs | 5 +++++ templates/character-blessures.hbs | 18 +++--------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/module/models/character.mjs b/module/models/character.mjs index e709ca4..0902d93 100644 --- a/module/models/character.mjs +++ b/module/models/character.mjs @@ -170,6 +170,11 @@ export default class CelestopolCharacter extends foundry.abstract.TypeDataModel faction.value = [1,2,3,4,5,6,7,8,9].filter(i => faction[`level${i}`]).length } + // Calcul automatique du niveau des jauges depuis les cases cochées + this.blessures.lvl = [1,2,3,4,5,6,7,8].filter(i => this.blessures[`b${i}`]?.checked).length + this.destin.lvl = [1,2,3,4,5,6,7,8].filter(i => this.destin[`d${i}`]?.checked).length + this.spleen.lvl = [1,2,3,4,5,6,7,8].filter(i => this.spleen[`s${i}`]?.checked).length + // Initiative PJ : 4 + Mobilité (Corps) + Inspiration (Cœur) [après calcul des domaines] this.initiative = 4 + (this.stats.corps.mobilite?.value ?? 0) + (this.stats.coeur.inspiration?.value ?? 0) } diff --git a/templates/character-blessures.hbs b/templates/character-blessures.hbs index 4199fc0..6511cb8 100644 --- a/templates/character-blessures.hbs +++ b/templates/character-blessures.hbs @@ -22,11 +22,7 @@
- {{#if isEditMode}} - - {{else}} - {{system.blessures.lvl}} - {{/if}} + {{system.blessures.lvl}}
@@ -49,11 +45,7 @@
- {{#if isEditMode}} - - {{else}} - {{system.destin.lvl}} - {{/if}} + {{system.destin.lvl}}
@@ -76,11 +68,7 @@
- {{#if isEditMode}} - - {{else}} - {{system.spleen.lvl}} - {{/if}} + {{system.spleen.lvl}}