diff --git a/module/actor-sheet.js b/module/actor-sheet.js
index 7010f44f..a1fb2b80 100644
--- a/module/actor-sheet.js
+++ b/module/actor-sheet.js
@@ -102,6 +102,9 @@ export class RdDActorSheet extends ActorSheet {
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 );
+
+ // Mise à jour de l'encombrement total
+ this.actor.computeEncombrementTotal();
// low is normal, this the base used to compute the grid.
data.data.fatigueHTML = "
" + RdDUtility.makeHTMLfatigueMatrix( data.data.sante.fatigue.value, data.data.sante.endurance.max ).html() + "
";
@@ -121,10 +124,9 @@ export class RdDActorSheet extends ActorSheet {
data.data.tetes = this._checkNull(data.itemsByType['tete']);
data.data.objets = data.data.materiel.concat(data.data.armes).concat(data.data.armures).concat(data.data.munitions).concat(data.data.livres).concat(data.data.potions).concat(data.data.herbes).concat(data.data.ingredients);
data.data.competenceByCategory = data.competenceByCategory;
+ data.data.encombrementTotal = this.actor.encombrementTotal;
data.data.isGM = game.user.isGM;
data.bonusmalusTable = CONFIG.RDD.bonusmalus;
-
- this.actor.computeEncombrementTotal();
return data;
}
diff --git a/module/actor.js b/module/actor.js
index 1bc518b0..685ba338 100644
--- a/module/actor.js
+++ b/module/actor.js
@@ -66,6 +66,9 @@ export class RdDActor extends Actor {
const data = actorData.data;
const flags = actorData.flags;
+ // Dynamic computing fields
+ this.encombrementTotal = 0;
+
// Make separate methods for each Actor type (character, npc, etc.) to keep
// things organized.
if (actorData.type === 'personnage') this._prepareCharacterData(actorData);
@@ -80,6 +83,7 @@ export class RdDActor extends Actor {
_prepareCharacterData(actorData) {
// Initialize empty items
RdDUtility.computeCarac(actorData.data);
+ this.computeEncombrementTotal();
this.computeEtatGeneral();
}
@@ -367,6 +371,19 @@ export class RdDActor extends Actor {
await this.update( {"data.compteurs": compteurs } );
}
+ /* -------------------------------------------- */
+ detectSurEncombrement( ) {
+ let diffEnc = Number(this.encombrementTotal) - Number(this.data.data.attributs.encombrement.value);
+ console.log("Sur enc", this.encombrementTotal, diffEnc);
+ if ( diffEnc > 0 ) { // Sur-encombrement
+ let malus = Math.round( diffEnc);
+ malus = (malus == 0) ? 1 : malus; // Always 1 at least
+ console.log("Sur enc malus", malus);
+ return malus;
+ }
+ return 0;
+ }
+
/* -------------------------------------------- */
computeEncombrementTotal( ) {
let totalEnc = 0;
@@ -375,7 +392,8 @@ export class RdDActor extends Actor {
totalEnc += Number(item.data.encombrement);
}
}
- console.log("Enc total : ", totalEnc);
+ this.encombrementTotal = totalEnc;
+ this.detectSurEncombrement();
}
/* -------------------------------------------- */
@@ -386,6 +404,7 @@ export class RdDActor extends Actor {
state = state - (data.sante.vie.max - data.sante.vie.value);
if (data.sante.fatigue) // Creatures n'ont pas de fatigue
state = state + RdDUtility.currentFatigueMalus(data.sante.fatigue.value, data.sante.endurance.max);
+ state = state - this.detectSurEncombrement();
data.compteurs.etat.value = state;
}
diff --git a/system.json b/system.json
index 4837a2c2..2f1359d1 100644
--- a/system.json
+++ b/system.json
@@ -2,7 +2,7 @@
"name": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon",
"description": "Rêve de Dragon RPG for FoundryVTT",
- "version": "0.9.30",
+ "version": "0.9.32",
"minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.6",
"templateVersion": 41,
diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html
index 1aa7c889..de13d622 100644
--- a/templates/actor-sheet.html
+++ b/templates/actor-sheet.html
@@ -421,6 +421,7 @@
{{!-- Equipment Tab --}}
+
Encombrement total/max : {{data.encombrementTotal}} / {{data.attributs.encombrement.value}}
{{#each data.armes_seules as |item id|}}
-