Appliquer encTotal à l'acrobatie #75

This commit is contained in:
2020-12-20 21:54:09 +01:00
parent 8091b5a2e1
commit fe4fd0ce93
13 changed files with 40 additions and 34 deletions

View File

@ -77,7 +77,7 @@ export class RdDActor extends Actor {
const actorData = this.data;
// Dynamic computing fields
this.encombrementTotal = 0;
this.encTotal = 0;
/*
// Auto-resize token
@ -158,7 +158,9 @@ export class RdDActor extends Actor {
return duplicate(list[0]);
}
getEncombrementTotal() {
return this.encTotal ? Math.floor(this.encTotal) : 0
}
/* -------------------------------------------- */
async deleteSortReserve(coordTMR) {
let reserve = duplicate(this.data.data.reve.reserve);
@ -618,7 +620,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
detectSurEncombrement( ) {
let diffEnc = Number(this.encombrementTotal) - Number(this.data.data.attributs.encombrement.value);
let diffEnc = Number(this.encTotal) - Number(this.data.data.attributs.encombrement.value);
if ( diffEnc > 0 ) { // Sur-encombrement
let malus = Math.round( diffEnc);
malus = (malus == 0) ? 1 : malus; // Always 1 at least
@ -630,7 +632,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
async computeEncombrementTotalEtMalusArmure( ) {
let totalEnc = 0;
let encTotal = 0;
let malusArmureData = duplicate(this.data.data.attributs.malusarmure);
let newMalusArmure = 0;
for (const item of this.data.items) {
@ -643,13 +645,13 @@ export class RdDActor extends Actor {
if (!item.data.quantite) item.data.quantite = 1; // Auto-fix
item.data.encTotal = Number(item.data.encombrement) * Number(item.data.quantite);
//console.log("Enc:", item.name, item.data.encombrement, item.data.quantite, item.data.encTotal);
totalEnc += item.data.encTotal;
encTotal += item.data.encTotal;
} else {
item.data.encTotal = 0; // Force default enc
}
}
// Mise à jour valeur totale et états
this.encombrementTotal = totalEnc;
this.encTotal = encTotal;
this.detectSurEncombrement();
// Mise à jour éventuelle du malus armure
if (newMalusArmure != malusArmureData.value) {