From 424b616891af93a4cbe2606c59a9e175aba092b3 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sat, 5 Dec 2020 02:22:37 +0100 Subject: [PATCH] Organisation du rappel de blessures --- module/actor-creature-sheet.js | 5 ++--- module/actor-humanoide-sheet.js | 6 +++--- module/actor-sheet.js | 6 +++--- module/actor.js | 27 +++++++++++++++++++++++++++ templates/actor-creature-sheet.html | 4 +--- templates/actor-humanoide-sheet.html | 4 +--- templates/actor-sheet.html | 17 +---------------- 7 files changed, 38 insertions(+), 31 deletions(-) diff --git a/module/actor-creature-sheet.js b/module/actor-creature-sheet.js index 793ad9b3..28d238aa 100644 --- a/module/actor-creature-sheet.js +++ b/module/actor-creature-sheet.js @@ -42,9 +42,8 @@ export class RdDActorCreatureSheet extends ActorSheet { data.data.caracSum = sum; data.data.carac.taille.isTaille = true; // To avoid button link; - data.data.nbLegeres = this.actor.countBlessures(data.data.blessures.legeres.liste ); - data.data.nbGraves = this.actor.countBlessures(data.data.blessures.graves.liste ); - data.data.nbCritiques = this.actor.countBlessures(data.data.blessures.critiques.liste ); + data.data.blessures.resume = this.actor.computeResumeBlessure(data.data.blessures); + data.data.isGM = game.user.isGM; data.data.competencecreature = data.itemsByType["competencecreature"]; diff --git a/module/actor-humanoide-sheet.js b/module/actor-humanoide-sheet.js index b321a3e5..b3e20751 100644 --- a/module/actor-humanoide-sheet.js +++ b/module/actor-humanoide-sheet.js @@ -41,9 +41,9 @@ export class RdDActorHumanoideSheet extends ActorSheet { data.data.caracSum = sum; data.data.carac.taille.isTaille = true; // To avoid button link; - data.data.nbLegeres = this.actor.countBlessures(data.data.blessures.legeres.liste ); - data.data.nbGraves = this.actor.countBlessures(data.data.blessures.graves.liste ); - data.data.nbCritiques = this.actor.countBlessures(data.data.blessures.critiques.liste ); + data.data.carac.chance.isChance = true; // Ajouter chance actuelle et utiliser; + data.data.compteurs.chance.isChance = true; + data.data.blessures.resume = this.actor.computeResumeBlessure(data.data.blessures); data.data.competencecreature = data.itemsByType["competencecreature"]; data.data.isGM = game.user.isGM; diff --git a/module/actor-sheet.js b/module/actor-sheet.js index e050bacf..73368005 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -90,9 +90,9 @@ export class RdDActorSheet extends ActorSheet { this.armesList = duplicate(data.data.combat); data.data.carac.taille.isTaille = true; // To avoid button link; - data.data.nbLegeres = this.actor.countBlessures(data.data.blessures.legeres.liste ); - data.data.nbGraves = this.actor.countBlessures(data.data.blessures.graves.liste ); - data.data.nbCritiques = this.actor.countBlessures(data.data.blessures.critiques.liste ); + data.data.carac.chance.isChance = true; // Ajouter chance actuelle et utiliser; + data.data.compteurs.chance.isChance = true; + data.data.blessures.resume = this.actor.computeResumeBlessure(data.data.blessures); // Mise à jour de l'encombrement total this.actor.computeEncombrementTotalEtMalusArmure(); diff --git a/module/actor.js b/module/actor.js index cc9d99e0..44e2b663 100644 --- a/module/actor.js +++ b/module/actor.js @@ -862,6 +862,33 @@ export class RdDActor extends Actor { } } + computeResumeBlessure(blessures = this.data.data.blessures) { + let nbLegeres = this.countBlessures(blessures.legeres.liste ); + let nbGraves = this.countBlessures(blessures.graves.liste ); + let nbCritiques = this.countBlessures(blessures.critiques.liste ); + + let resume = "Blessures:"; + if (nbCritiques > 0 || nbGraves > 0 || nbLegeres > 0) { + if (nbLegeres > 0) { + resume += " " + nbLegeres + " légères"; + } + if (nbGraves > 0) { + if (nbLegeres > 0) + resume += ","; + resume += " " + nbGraves + " graves"; + } + if (nbCritiques > 0) { + if (nbGraves > 0 || nbLegeres > 0) + resume += ","; + resume += " une CRITIQUE !"; + } + } + else { + resume += " aucune"; + } + return resume; + } + /* -------------------------------------------- */ computeEtatGeneral( ) { diff --git a/templates/actor-creature-sheet.html b/templates/actor-creature-sheet.html index 6ccde2d1..ba5215f8 100644 --- a/templates/actor-creature-sheet.html +++ b/templates/actor-creature-sheet.html @@ -7,9 +7,7 @@

-
Blessures légères : {{data.nbLegeres}}
-
Blessures graves : {{data.nbGraves}}
-
Blessure critique : {{data.nbCritiques}}
+ {{data.blessures.resume}}
diff --git a/templates/actor-humanoide-sheet.html b/templates/actor-humanoide-sheet.html index 691537b2..eefec3dc 100644 --- a/templates/actor-humanoide-sheet.html +++ b/templates/actor-humanoide-sheet.html @@ -7,9 +7,7 @@

-
Blessures légères : {{data.nbLegeres}}
-
Blessures graves : {{data.nbGraves}}
-
Blessure critique : {{data.nbCritiques}}
+ {{data.blessures.resume}}
diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 621b2a45..5e65759f 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -70,22 +70,7 @@ Malus de fatigue : {{data.fatigue.malus}} {{{data.fatigue.html}}} - - {{#if data.nbLegeres}} - Blessures: {{data.nbLegeres}} légères - {{#if data.nbGraves}}, {{data.nbGraves}} graves{{/if}} - {{#if data.nbCritiques}}, une CRITIQUE !{{/if}} - {{else}} - {{#if data.nbGraves}} - Blessures:{{data.nbGraves}} graves - {{#if data.nbCritiques}}et une CRITIQUE !{{data.nbCritiques}}{{/if}} - {{else}} - {{#if data.nbCritiques}}une CRITIQUE !{{data.nbCritiques}} - {{else}}Aucune blessure - {{/if}} - {{/if}} - {{/if}} - + {{data.blessures.resume}}