diff --git a/module/actor-sheet.js b/module/actor-sheet.js
index ad4c413e..59a151f3 100644
--- a/module/actor-sheet.js
+++ b/module/actor-sheet.js
@@ -12,8 +12,8 @@ export class RdDActorSheet extends ActorSheet {
return mergeObject(super.defaultOptions, {
classes: ["rdd", "sheet", "actor"],
template: "systems/foundryvtt-reve-de-dragon/templates/actor-sheet.html",
- width: 600,
- height: 600,
+ width: 640,
+ height: 720,
tabs: [{navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description"}],
dragDrop: [{dragSelector: ".item-list .item", dropSelector: null}]
});
@@ -80,9 +80,9 @@ export class RdDActorSheet extends ActorSheet {
}
data.data.carac.taille.isTaille = true; // To avoid button link;
- data.data.nbLegeres = RdDUtility.computeNbBlessures(data.data.blessures, "legeres" );
- data.data.nbGraves = RdDUtility.computeNbBlessures(data.data.blessures, "graves" );
- data.data.nbCritiques = RdDUtility.computeNbBlessures(data.data.blessures, "critiques" );
+ 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 );
// 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() + "
";
@@ -98,8 +98,6 @@ export class RdDActorSheet extends ActorSheet {
data.data.ombres = this._checkNull(data.itemsByType['ombre']);
data.data.tetes = this._checkNull(data.itemsByType['tete']);
data.data.competenceByCategory = data.competenceByCategory;
- //data.data.armes = data.itemsByType.arme;
- //console.log(">>>>> data update");
return data;
}
@@ -127,12 +125,27 @@ export class RdDActorSheet extends ActorSheet {
li.slideUp(200, () => this.render(false));
});
- // Equip Inventory Item
- html.find('.blessure-legere-control').click(ev => {
- let index = event.currentTarget.attributes['data-blessure-index'].value;
- let active = event.currentTarget.attributes['data-blessure-active'].value;
- this.actor.manageBlessureLegere(index, active);
- this.render(true);
+ // Blessure control
+ html.find('.blessure-control').click(ev => {
+ const li = $(ev.currentTarget).parents(".item");
+ let btype = li.data("blessure-type");
+ let index = li.data('blessure-index');
+ let active = $(ev.currentTarget).data('blessure-active');
+ //console.log(btype, index, active);
+ this.actor.manageBlessureFromSheet(btype, index, active).then( this.render(true) );
+ });
+
+ // Blessure data
+ html.find('.blessures-soins').change(ev => {
+ const li = $(ev.currentTarget).parents(".item");
+ let btype = li.data('blessure-type');
+ let index = li.data('blessure-index');
+ let psoins = li.find('input[name=premiers_soins]').val();
+ let pcomplets = li.find('input[name=soins_complets]').val();
+ let jours = li.find('input[name=jours]').val();
+ let loc = li.find('input[name=localisation]').val();
+ //console.log(btype, index, psoins, pcomplets, jours, loc);
+ this.actor.setDataBlessureFromSheet(btype, index, psoins, pcomplets, jours, loc).then( this.render(true) );
});
// Equip Inventory Item
@@ -172,7 +185,7 @@ export class RdDActorSheet extends ActorSheet {
// Display info about queue
html.find('.queuesouffle-label a').click((event) => {
- let myID = event.currentTarget.attributes['data-id'].value;
+ let myID = event.currentTarget.attributes['data-item-id'].value;
const item = this.actor.getOwnedItem(myID);
item.sheet.render(true);
});
diff --git a/module/actor.js b/module/actor.js
index 1e65bb8b..e05f934d 100644
--- a/module/actor.js
+++ b/module/actor.js
@@ -388,7 +388,16 @@ export class RdDActor extends Actor {
// TODO : Output to chat
}
}
-
+
+ /* -------------------------------------------- */
+ GetNumberBlessures( blessuresListe )
+ {
+ let nbB = 0;
+ for ( let b of blessuresListe) {
+ nbB += ( b.active) ? 1 : 0;
+ }
+ return nbB;
+ }
/* -------------------------------------------- */
async santeIncDec(name, inc ) {
const sante = duplicate(this.data.data.sante);
@@ -412,10 +421,12 @@ export class RdDActor extends Actor {
}
if ( data.value < 0 ) data.value = 0; // Security
- let blessures = this.data.data.blessures;
- let maxEnd = Math.floor( data.max / blessures.graves.nombre);
+ let blessures = this.data.data.blessures;
+ let nbGraves = this.GetNumberBlessures(blessures.graves.liste);
+ let nbCritiques = this.GetNumberBlessures(blessures.critiques.liste);
+ let maxEnd = Math.floor( data.max / nbGraves);
if (data.value > maxEnd ) data.value = maxEnd;
- if ( blessures.critiques.nombre > 0 && data.value > 1) data.value = 1;
+ if ( nbCritiques > 0 && data.value > 1) data.value = 1;
if (lastValue - data.value > 1) this.testSiSonne(sante, data); // Peut-être sonné si 2 points d'endurance perdus d'un coup
}
@@ -429,14 +440,31 @@ export class RdDActor extends Actor {
await this.update( {"data.sante": sante } );
}
/* -------------------------------------------- */
- async manageBlessureLegere( index ) {
- let legeres = duplicate(this.data.data.blessures.legeres);
- let blessure = legeres.liste[index];
+ async manageBlessureFromSheet( bType, index, active ) {
+ let bList = duplicate(this.data.data.blessures);
+ let blessure = bList[bType+"s"].liste[index];
blessure.active = !blessure.active;
- console.log("Blessure update", index, blessure );
- await this.update( { "data.blessures.legeres": legeres } );
+ if ( !blessure.active ) {
+ blessure.premiers_soins = 0;
+ blessure.soins_complets = 0;
+ blessure.jours = 0;
+ blessure.localisation = "";
+ }
+ //console.log("Blessure update", bType, index, blessure, bList );
+ await this.update( { 'data.blessures': bList } );
}
-
+
+ /* -------------------------------------------- */
+ async setDataBlessureFromSheet( bType, index, psoins, pcomplets, jours, loc) {
+ let bList = duplicate(this.data.data.blessures);
+ let blessure = bList[bType+"s"].liste[index];
+ blessure.premiers_soins = psoins;
+ blessure.soins_complets = pcomplets;
+ blessure.jours = jours;
+ blessure.localisation = loc;
+ await this.update( { 'data.blessures': bList } );
+ }
+
/* -------------------------------------------- */
manageBlessures( blessuresData )
{
diff --git a/module/rdd-utility.js b/module/rdd-utility.js
index 4bb87c5f..3499f5d5 100644
--- a/module/rdd-utility.js
+++ b/module/rdd-utility.js
@@ -365,18 +365,6 @@ export class RdDUtility {
return result;
}
- /* -------------------------------------------- */
- static computeNbBlessures( blessures, name)
- {
- let bless = blessures[name];
- console.log(blessures, name, bless);
- let nbBlessures = 0;
- for (let k=0; k
-
+
@@ -118,7 +118,7 @@
{{/each}}
-
{{/each}}
-
-
+
+
+
+ {{#each data.competenceByCategory.specialisee as |comp key|}}
+ -
+
+ {{comp.name}}
+
+
+
+
+ {{/each}}
+
+
-
-
@@ -270,31 +271,40 @@
{{!-- blessures Tab --}}
-
Blessures Légeres :
-
+
Blessures Légeres :
+
-
Blessures Graves :
-
+
Blessures Graves :
+
-
Blessure Critique :
-
+
Blessure Critique :
+
@@ -362,32 +372,44 @@