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 b7929202..e2a7dfda 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"; /** @@ -210,7 +210,7 @@ export class RdDActor extends Actor { console.log("dormirChateauDormant", blessures) await this._recupererBlessures(message, "legere", blessures.legeres.liste.filter(b => b.active), []); await this._recupererBlessures(message, "grave", blessures.graves.liste.filter(b => b.active), blessures.legeres.liste); - await this._recupererBlessures(message,"legere", blessures.critiques.liste.filter(b => b.active), blessures.graves.liste); + await this._recupererBlessures(message, "critique", blessures.critiques.liste.filter(b => b.active), blessures.graves.liste); await this.update( {"data.blessures": blessures } ); await this._recupererVie(message); await this.transformerStress(message); @@ -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 ); } @@ -1572,7 +1576,7 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async ajouteNombreAstral( data ) { // Gestion expérience (si existante) - this.appliquerExperience( request.rolled, "vue", "astrologie"); + this.appliquerExperience( data.rolled, "vue", "astrologie"); // Ajout du nombre astral const item = {name: "Nombre Astral", type: "nombreastral", data: @@ -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/module/rdd-combat.js b/module/rdd-combat.js index 57a56a64..a22a350f 100644 --- a/module/rdd-combat.js +++ b/module/rdd-combat.js @@ -205,6 +205,7 @@ export class RdDCombat { return rollData; } + /* -------------------------------------------- */ _modifieRollDataCreature(rollData, competence) { competence = duplicate(competence); competence.data.defaut_carac = "carac_creature"; @@ -283,6 +284,7 @@ export class RdDCombat { RdDCombat._sendRollMessage(this.attacker, this.defender, this.defenderTokenId, "msg_defense", message, rollData); } + /* -------------------------------------------- */ _buildMessageDefense(rollData) { let message = "" + this.defender.name + " doit se défendre :"; @@ -303,6 +305,7 @@ export class RdDCombat { return message; } + /* -------------------------------------------- */ _buildMessageEncaisser(rollData) { return "
Encaisser à " + Misc.toSignedString(rollData.dmg.total) + " !"; } @@ -521,6 +524,7 @@ export class RdDCombat { dialog.render(true); } + /* -------------------------------------------- */ _prepareEsquive(attackerRoll, competence) { let rollData = { forceValue: this.defender.getForceValue(), 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 --}}