diff --git a/module/actor-creature-sheet.js b/module/actor-creature-sheet.js index f6f91d02..f4a31783 100644 --- a/module/actor-creature-sheet.js +++ b/module/actor-creature-sheet.js @@ -42,9 +42,9 @@ export class RdDActorCreatureSheet extends ActorSheet { data.data.caracSum = sum; data.data.carac.taille.isTaille = true; // To avoid button link; - data.data.nbLegeres = this.actor.GetNumberBlessures(data.data.blessures.legeres.liste ); - data.data.nbGraves = this.actor.GetNumberBlessures(data.data.blessures.graves.liste ); - data.data.nbCritiques = this.actor.GetNumberBlessures(data.data.blessures.critiques.liste ); + 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.competencecreature = data.itemsByType["competencecreature"]; diff --git a/module/actor-humanoide-sheet.js b/module/actor-humanoide-sheet.js index f41fd603..a889877e 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.GetNumberBlessures(data.data.blessures.legeres.liste ); - data.data.nbGraves = this.actor.GetNumberBlessures(data.data.blessures.graves.liste ); - data.data.nbCritiques = this.actor.GetNumberBlessures(data.data.blessures.critiques.liste ); + 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.competencecreature = data.itemsByType["competencecreature"]; RdDUtility.filterItemsPerTypeForSheet(data ); diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 2bffabb6..ee4d3d94 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -85,9 +85,9 @@ export class RdDActorSheet extends ActorSheet { } data.data.carac.taille.isTaille = true; // To avoid button link; - data.data.nbLegeres = this.actor.GetNumberBlessures(data.data.blessures.legeres.liste ); - data.data.nbGraves = this.actor.GetNumberBlessures(data.data.blessures.graves.liste ); - data.data.nbCritiques = this.actor.GetNumberBlessures(data.data.blessures.critiques.liste ); + 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 ); // Mise à jour de l'encombrement total this.actor.computeEncombrementTotal(); diff --git a/module/actor.js b/module/actor.js index bbff45af..f34d0e96 100644 --- a/module/actor.js +++ b/module/actor.js @@ -762,13 +762,9 @@ export class RdDActor extends Actor { } /* -------------------------------------------- */ - GetNumberBlessures( blessuresListe ) + countBlessures( blessuresListe ) { - let nbB = 0; - for ( let b of blessuresListe) { - nbB += ( b.active) ? 1 : 0; - } - return nbB; + return blessuresListe.filter(b => b.active).length } /* -------------------------------------------- */ @@ -817,8 +813,8 @@ export class RdDActor extends Actor { let blessures = this.data.data.blessures; let diffVie = this.data.data.sante.vie.max - this.data.data.sante.vie.value; let maxEndVie = this.data.data.sante.endurance.max - (diffVie * 2); - let nbGraves = this.GetNumberBlessures(blessures.graves.liste); - let nbCritiques = this.GetNumberBlessures(blessures.critiques.liste); + let nbGraves = this.countBlessures(blessures.graves.liste); + let nbCritiques = this.countBlessures(blessures.critiques.liste); let maxEndGraves = Math.floor(this.data.data.sante.endurance.max / (2 * nbGraves)); let maxEndCritiques = nbCritiques > 0 ? 1 : this.data.data.sante.endurance.max; return Math.max(0, Math.min(maxEndVie, maxEndGraves, maxEndCritiques));