diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 57c52b6e..10d48c6d 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -100,7 +100,7 @@ export class RdDActorSheet extends ActorSheet { // Gestion du lock/unlock des zones éditables (carac+compétences) data.data.editCaracComp = this.options.editCaracComp; - data.data.lockUnlockText = (this.options.editCaracComp) ? "Bloquer" : "Debloquer"; + data.data.lockUnlockText = (this.options.editCaracComp) ? "Bloquer" : "Débloquer"; // low is normal, this the base used to compute the grid. data.data.fatigue = { @@ -160,6 +160,12 @@ export class RdDActorSheet extends ActorSheet { activateListeners(html) { super.activateListeners(html); + if (game.user.isGM) { + $(".gm-only").show(); + } else { + $(".gm-only").hide(); + } + // Everything below here is only needed if the sheet is editable if (!this.options.editable) return; @@ -176,11 +182,16 @@ export class RdDActorSheet extends ActorSheet { this.confirmerSuppression( li ); }); - // Update Inventory Item - html.find('.encaisser-direct').click(ev => { + html.find('#encaisser-direct').click(ev => { this.displayDialogEncaisser() }); + html.find('#remise-a-neuf').click(ev => { + if (game.user.isGM) { + this.actor.remiseANeuf(); + } + }); + // Blessure control html.find('.blessure-control').click(ev => { const li = $(ev.currentTarget).parents(".item"); @@ -234,24 +245,24 @@ export class RdDActorSheet extends ActorSheet { this.actor.rollArme( armeName, competenceName); }); // Display TMR, normal - html.find('.visu-tmr a').click((event) => { + html.find('#visu-tmr').click((event) => { this.actor.displayTMR( "visu"); }); // Display TMR, normal - html.find('.monte-tmr a').click((event) => { + html.find('#monte-tmr').click((event) => { this.actor.displayTMR( "normal" ); }); // Display TMR, fast - html.find('.monte-tmr-rapide a').click((event) => { + html.find('#monte-tmr-rapide').click((event) => { this.actor.displayTMR( "rapide" ); }); - html.find('.dormir-une-heure').click((event) => { + html.find('#dormir-une-heure').click((event) => { this.actor.dormir(1); }); - html.find('.dormir-chateau-dormant').click((event) => { + html.find('#dormir-chateau-dormant').click((event) => { this.actor.dormirChateauDormant(); }); diff --git a/module/actor.js b/module/actor.js index 97677147..e7361db0 100644 --- a/module/actor.js +++ b/module/actor.js @@ -391,10 +391,14 @@ export class RdDActor extends Actor { } mergeObject(retrograde, { "active": true, "premiers_soins": 0, "soins_complets": 0, "jours": 0, "localisation": blessure.localisation }); } - mergeObject(blessure, { "active": false, "premiers_soins": 0, "soins_complets": 0, "jours": 0, "localisation": "" }); + this._supprimerBlessure(blessure); return true; } + _supprimerBlessure(blessure) { + mergeObject(blessure, { "active": false, "premiers_soins": 0, "soins_complets": 0, "jours": 0, "localisation": "" }); + } + async _recupererVie(message) { let blessures = [].concat(this.data.data.blessures.legeres.liste).concat(this.data.data.blessures.graves.liste).concat(this.data.data.blessures.critiques.liste); let nbBlessures = blessures.filter(b => b.active); @@ -430,6 +434,28 @@ export class RdDActor extends Actor { return rolled; } + + async remiseANeuf() { + let message = { + whisper: ChatUtility.getWhisperRecipientsAndGMs( this.name ), + content : "Remise à neuf de " + this.name + }; + const blessures = duplicate(this.data.data.blessures); + for (let listeBlessures of [blessures.legeres.liste, blessures.graves.liste, blessures.critiques.liste]) { + for (let blessure of listeBlessures) { + this._supprimerBlessure(blessure); + } + } + await this.update( {"data.blessures": blessures } ); + await this.santeIncDec("vie", this.data.data.sante.vie.max - this.data.data.sante.vie.value); + await this.santeIncDec("endurance", this.data.data.sante.endurance.max - this.data.data.sante.endurance.value); + let fatigue = duplicate(this.data.data.sante.fatigue) + fatigue.value = 0; + await this.update( {"data.sante.fatigue": fatigue } ); + ChatMessage.create( message ); + } + + /* -------------------------------------------- */ async dormir(heures=1) { let message = { diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index ad89353f..94b36b4a 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -58,13 +58,14 @@