diff --git a/module/actor-creature-sheet.js b/module/actor-creature-sheet.js index a299a949..9a9affaa 100644 --- a/module/actor-creature-sheet.js +++ b/module/actor-creature-sheet.js @@ -4,6 +4,7 @@ * @extends {ActorSheet} */ +import { HtmlUtility } from "./html-utility.js"; import { RdDUtility } from "./rdd-utility.js"; /* -------------------------------------------- */ @@ -64,7 +65,9 @@ export class RdDActorCreatureSheet extends ActorSheet { /** @override */ activateListeners(html) { super.activateListeners(html); - + + HtmlUtility._showControlWhen($(".gm-only"), game.user.isGM); + // Everything below here is only needed if the sheet is editable if (!this.options.editable) return; @@ -147,7 +150,17 @@ export class RdDActorCreatureSheet extends ActorSheet { this.actor.santeIncDec("endurance", -1); this.render(true); }); - } + + html.find('#encaisser-direct').click(ev => { + this.actor.encaisser(); + }); + + html.find('#remise-a-neuf').click(ev => { + if (game.user.isGM) { + this.actor.remiseANeuf(); + } + }); +} /* -------------------------------------------- */ diff --git a/module/actor-entite-sheet.js b/module/actor-entite-sheet.js index fb2dc46f..789a2bb9 100644 --- a/module/actor-entite-sheet.js +++ b/module/actor-entite-sheet.js @@ -4,6 +4,7 @@ * @extends {ActorSheet} */ +import { HtmlUtility } from "./html-utility.js"; import { RdDUtility } from "./rdd-utility.js"; /* -------------------------------------------- */ @@ -55,6 +56,8 @@ export class RdDActorEntiteSheet extends ActorSheet { activateListeners(html) { super.activateListeners(html); + HtmlUtility._showControlWhen($(".gm-only"), game.user.isGM); + // Everything below here is only needed if the sheet is editable if (!this.options.editable) return; @@ -106,6 +109,17 @@ export class RdDActorEntiteSheet extends ActorSheet { this.actor.santeIncDec("endurance", -1); this.render(true); }); + + html.find('#encaisser-direct').click(ev => { + this.actor.encaisser(); + }); + + html.find('#remise-a-neuf').click(ev => { + if (game.user.isGM) { + this.actor.remiseANeuf(); + } + }); + } diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 088d4037..2d758c19 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -4,7 +4,6 @@ */ import { RdDUtility } from "./rdd-utility.js"; -import { RdDEncaisser } from "./rdd-roll-encaisser.js"; import { HtmlUtility } from "./html-utility.js"; /* -------------------------------------------- */ @@ -132,13 +131,6 @@ export class RdDActorSheet extends ActorSheet { return data; } - /* -------------------------------------------- */ - async displayDialogEncaisser( ) { - let data = { ajustementsEncaissement: RdDUtility.getAjustementsEncaissement() }; - let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-encaisser.html', data ); - new RdDEncaisser(html, this.actor ).render(true); - } - /* -------------------------------------------- */ async _onDrop(event) { await RdDUtility.processItemDropEvent(this, event); @@ -253,7 +245,7 @@ export class RdDActorSheet extends ActorSheet { }); html.find('#encaisser-direct').click(ev => { - this.displayDialogEncaisser() + this.actor.encaisser(); }); html.find('#remise-a-neuf').click(ev => { diff --git a/module/actor.js b/module/actor.js index 8bce2611..5e8f5436 100644 --- a/module/actor.js +++ b/module/actor.js @@ -11,7 +11,7 @@ import { RdDRollTables } from "./rdd-rolltables.js"; import { ChatUtility } from "./chat-utility.js"; import { RdDItemSort } from "./item-sort.js"; import { Grammar } from "./grammar.js"; -import { RdDItemArme } from "./item-arme.js"; +import { RdDEncaisser } from "./rdd-roll-encaisser.js"; import { RdDCombat } from "./rdd-combat.js"; /** @@ -309,23 +309,27 @@ export class RdDActor extends Actor { whisper: ChatUtility.getWhisperRecipientsAndGMs( this.name ), content : "Remise à neuf de " + this.name }; - if (this.data.data.blessures){ - 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); + if (!this.isEntiteCauchemar()) { + if (this.data.data.blessures){ + 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.update( {"data.blessures": blessures } ); + await this.update({ "data.compteurs.ethylisme.value": 0 }); + await this.update({ "data.compteurs.ethylisme.nb_doses": 0 }); + await this.santeIncDec("vie", this.data.data.sante.vie.max - this.data.data.sante.vie.value); } - await this.update({ "data.compteurs.ethylisme.value": 0 }); - await this.update({ "data.compteurs.ethylisme.nb_doses": 0 }); - 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); - if (this.data.data.sante.fatigue){ - let fatigue = duplicate(this.data.data.sante.fatigue) - fatigue.value = 0; - await this.update( {"data.sante.fatigue": fatigue } ); + if (!this.isEntiteCauchemar()) { + if (this.data.data.sante.fatigue){ + let fatigue = duplicate(this.data.data.sante.fatigue) + fatigue.value = 0; + await this.update( {"data.sante.fatigue": fatigue } ); + } } ChatMessage.create( message ); } @@ -1749,6 +1753,13 @@ export class RdDActor extends Actor { return protection; } + /* -------------------------------------------- */ + async encaisser( ) { + let data = { ajustementsEncaissement: RdDUtility.getAjustementsEncaissement() }; + let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-encaisser.html', data ); + new RdDEncaisser(html, this ).render(true); + } + /* -------------------------------------------- */ async encaisserDommages( attackerRoll, attacker = undefined ) { if (attacker && !await attacker.accorder(this, 'avant-encaissement')) { diff --git a/templates/actor-creature-sheet.html b/templates/actor-creature-sheet.html index 8423dc8e..d1e16dae 100644 --- a/templates/actor-creature-sheet.html +++ b/templates/actor-creature-sheet.html @@ -4,7 +4,15 @@
-

+
+

+
+
+
+ Encaisser des dommages + Remise à neuf +
+
{{data.blessures.resume}} diff --git a/templates/actor-entite-sheet.html b/templates/actor-entite-sheet.html index 9113dd18..39ddea84 100644 --- a/templates/actor-entite-sheet.html +++ b/templates/actor-entite-sheet.html @@ -4,9 +4,17 @@
-

+
+

+
+
+
+ Encaisser des dommages + Remise à neuf +
+
-
+
{{!-- Sheet Tab Navigation --}}