#10 Debut gestion encombrement

This commit is contained in:
sladecraven 2020-11-11 11:43:13 +01:00
parent ee3e568cd8
commit 70abeb2c87
4 changed files with 76 additions and 16 deletions

View File

@ -105,21 +105,27 @@ export class RdDActorSheet extends ActorSheet {
// low is normal, this the base used to compute the grid. // 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.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']); data.data.materiel = this._checkNull(data.itemsByType['objet']);
data.data.armes = this._checkNull(data.itemsByType['arme']); data.data.conteneur = this._checkNull(data.itemsByType['conteneur']);
data.data.armures = this._checkNull(data.itemsByType['armure']); data.data.armes = this._checkNull(data.itemsByType['arme']);
data.data.livres = this._checkNull(data.itemsByType['livre']); data.data.armures = this._checkNull(data.itemsByType['armure']);
data.data.potions = this._checkNull(data.itemsByType['potions']); data.data.livres = this._checkNull(data.itemsByType['livre']);
data.data.herbes = this._checkNull(data.itemsByType['herbes']); data.data.potions = this._checkNull(data.itemsByType['potions']);
data.data.sorts = this._checkNull(data.itemsByType['sort']); data.data.ingredients = this._checkNull(data.itemsByType['ingredient']);
data.data.queues = this._checkNull(data.itemsByType['queue']); data.data.munitions = this._checkNull(data.itemsByType['munition']);
data.data.souffles = this._checkNull(data.itemsByType['souffle']); data.data.herbes = this._checkNull(data.itemsByType['herbes']);
data.data.ombres = this._checkNull(data.itemsByType['ombre']); data.data.sorts = this._checkNull(data.itemsByType['sort']);
data.data.tetes = this._checkNull(data.itemsByType['tete']); data.data.queues = this._checkNull(data.itemsByType['queue']);
data.data.souffles = this._checkNull(data.itemsByType['souffle']);
data.data.ombres = this._checkNull(data.itemsByType['ombre']);
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.competenceByCategory = data.competenceByCategory;
data.data.isGM = game.user.isGM; data.data.isGM = game.user.isGM;
data.bonusmalusTable = CONFIG.RDD.bonusmalus; data.bonusmalusTable = CONFIG.RDD.bonusmalus;
this.actor.computeEncombrementTotal();
return data; return data;
} }
@ -130,6 +136,12 @@ export class RdDActorSheet extends ActorSheet {
new RdDEncaisser(html, this.actor ).render(true); new RdDEncaisser(html, this.actor ).render(true);
} }
/* -------------------------------------------- */
async _onDrop(event) {
super._onDrop(event)
this.actor.computeEncombrementTotal();
}
/* -------------------------------------------- */ /* -------------------------------------------- */
/** @override */ /** @override */
activateListeners(html) { activateListeners(html) {

View File

@ -367,6 +367,17 @@ export class RdDActor extends Actor {
await this.update( {"data.compteurs": compteurs } ); await this.update( {"data.compteurs": compteurs } );
} }
/* -------------------------------------------- */
computeEncombrementTotal( ) {
let totalEnc = 0;
for (const item of this.data.items) {
if ( item.data && item.data.encombrement ) { // Enc value filtering
totalEnc += Number(item.data.encombrement);
}
}
console.log("Enc total : ", totalEnc);
}
/* -------------------------------------------- */ /* -------------------------------------------- */
computeEtatGeneral( ) computeEtatGeneral( )
{ {
@ -780,12 +791,10 @@ export class RdDActor extends Actor {
{ {
let item = this.getOwnedItem(itemID); let item = this.getOwnedItem(itemID);
if ( item && item.data.data ) { if ( item && item.data.data ) {
console.log(item);
//let update = duplicate(item);
let update = {_id: item._id, "data.equipe": !item.data.data.equipe }; let update = {_id: item._id, "data.equipe": !item.data.data.equipe };
//update.data.equipe = !update.data.equipe;
//console.log(update); //console.log(update);
await this.updateEmbeddedEntity("OwnedItem", update); await this.updateEmbeddedEntity("OwnedItem", update);
this.computeEncombrementTotal(); // Mise à jour encombrement
} }
} }

View File

@ -2,7 +2,7 @@
"name": "foundryvtt-reve-de-dragon", "name": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon", "title": "Rêve de Dragon",
"description": "Rêve de Dragon RPG for FoundryVTT", "description": "Rêve de Dragon RPG for FoundryVTT",
"version": "0.9.29", "version": "0.9.30",
"minimumCoreVersion": "0.7.5", "minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.6", "compatibleCoreVersion": "0.7.6",
"templateVersion": 41, "templateVersion": 41,

View File

@ -447,7 +447,46 @@
</li> </li>
{{/each}} {{/each}}
</ol> </ol>
</div> <ol class="item-list">
{{#each data.conteneur as |item id|}}
<li class="item flexrow" data-item-id="{{item._id}}">
<img class="sheet-competence-img" src="{{item.img}}" title="{{item.name}}"/>
<h4 class="item-name">{{item.name}}</h4>
<div class="item-controls">
<a class="item-control item-equip" title="Equiper">{{#if item.data.equipe}}<i class="fas fa-circle"></i>{{else}}<i class="fas fa-genderless"></i>{{/if}}</a>
<a class="item-control item-edit" title="Editer"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
</ol>
<ol class="item-list">
{{#each data.materiel as |item id|}}
<li class="item flexrow" data-item-id="{{item._id}}">
<img class="sheet-competence-img" src="{{item.img}}" title="{{item.name}}"/>
<h4 class="item-name">{{item.name}}</h4>
<div class="item-controls">
<a class="item-control item-equip" title="Equiper">{{#if item.data.equipe}}<i class="fas fa-circle"></i>{{else}}<i class="fas fa-genderless"></i>{{/if}}</a>
<a class="item-control item-edit" title="Editer"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
</ol>
<ol class="item-list">
{{#each data.livres as |item id|}}
<li class="item flexrow" data-item-id="{{item._id}}">
<img class="sheet-competence-img" src="{{item.img}}" title="{{item.name}}"/>
<h4 class="item-name">{{item.name}}</h4>
<div class="item-controls">
<a class="item-control item-equip" title="Equiper">{{#if item.data.equipe}}<i class="fas fa-circle"></i>{{else}}<i class="fas fa-genderless"></i>{{/if}}</a>
<a class="item-control item-edit" title="Editer"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
</ol>
</div>
{{!-- Biography Tab --}} {{!-- Biography Tab --}}
<div class="tab biography" data-group="primary" data-tab="description"> <div class="tab biography" data-group="primary" data-tab="description">