renommage countBlessures

This commit is contained in:
Vincent Vandemeulebrouck 2020-11-25 00:50:20 +01:00
parent 6ccc5b8d1b
commit f77a0bf20b
4 changed files with 13 additions and 17 deletions

View File

@ -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"];

View File

@ -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 );

View File

@ -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();

View File

@ -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));