#1 gestion encombrement et malus associé
This commit is contained in:
parent
70abeb2c87
commit
021948bf6e
@ -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 = "<table class='table-fatigue'>" + RdDUtility.makeHTMLfatigueMatrix( data.data.sante.fatigue.value, data.data.sante.endurance.max ).html() + "</table>";
|
||||
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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}}">
|
||||
|
Loading…
Reference in New Issue
Block a user