#1 gestion encombrement et malus associé

This commit is contained in:
sladecraven 2020-11-11 14:42:11 +01:00
parent 70abeb2c87
commit 021948bf6e
4 changed files with 26 additions and 4 deletions

View File

@ -103,6 +103,9 @@ export class RdDActorSheet extends ActorSheet {
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 = "<table class='table-fatigue'>" + RdDUtility.makeHTMLfatigueMatrix( data.data.sante.fatigue.value, data.data.sante.endurance.max ).html() + "</table>";
data.data.materiel = this._checkNull(data.itemsByType['objet']);
@ -121,11 +124,10 @@ 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;
}

View File

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

View File

@ -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,

View File

@ -421,6 +421,7 @@
{{!-- Equipment Tab --}}
<div class="tab items" data-group="primary" data-tab="items">
<span cass=item-name>Encombrement total/max : {{data.encombrementTotal}} / {{data.attributs.encombrement.value}}</span>
<ol class="item-list">
{{#each data.armes_seules as |item id|}}
<li class="item flexrow" data-item-id="{{item._id}}">