diff --git a/module/actor-entite-sheet.js b/module/actor-entite-sheet.js index 789a2bb9..ea5a1e23 100644 --- a/module/actor-entite-sheet.js +++ b/module/actor-entite-sheet.js @@ -1,11 +1,9 @@ - /** * Extend the basic ActorSheet with some very simple modifications * @extends {ActorSheet} */ import { HtmlUtility } from "./html-utility.js"; -import { RdDUtility } from "./rdd-utility.js"; /* -------------------------------------------- */ export class RdDActorEntiteSheet extends ActorSheet { @@ -55,7 +53,7 @@ export class RdDActorEntiteSheet 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 @@ -119,7 +117,6 @@ export class RdDActorEntiteSheet extends ActorSheet { this.actor.remiseANeuf(); } }); - } diff --git a/module/actor-humanoide-sheet.js b/module/actor-humanoide-sheet.js index aee867bd..3a9c9679 100644 --- a/module/actor-humanoide-sheet.js +++ b/module/actor-humanoide-sheet.js @@ -1,12 +1,12 @@ - /** * Extend the basic ActorSheet with some very simple modifications * @extends {ActorSheet} - */ + */ +import { HtmlUtility } from "./html-utility.js"; import { RdDUtility } from "./rdd-utility.js"; -/* -------------------------------------------- */ +/* -------------------------------------------- */ export class RdDActorHumanoideSheet extends ActorSheet { /** @override */ @@ -64,7 +64,9 @@ export class RdDActorHumanoideSheet 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,6 +149,16 @@ export class RdDActorHumanoideSheet 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 2d758c19..2c8d182c 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -130,7 +130,7 @@ export class RdDActorSheet extends ActorSheet { return data; } - + /* -------------------------------------------- */ async _onDrop(event) { await RdDUtility.processItemDropEvent(this, event); diff --git a/module/actor.js b/module/actor.js index e2a7dfda..7e19bb73 100644 --- a/module/actor.js +++ b/module/actor.js @@ -309,7 +309,11 @@ export class RdDActor extends Actor { whisper: ChatUtility.getWhisperRecipientsAndGMs( this.name ), content : "Remise à neuf de " + this.name }; - if (!this.isEntiteCauchemar()) { + if (this.isEntiteCauchemar()) { + await this.santeIncDec("endurance", this.data.data.sante.endurance.max - this.data.data.sante.endurance.value); + } + else { + 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]) { @@ -319,12 +323,10 @@ export class RdDActor extends Actor { } await this.update( {"data.blessures": blessures } ); } - await this.update({ "data.compteurs.ethylisme.value": 0 }); + await this.update({ "data.compteurs.ethylisme.value": 1 }); 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.isEntiteCauchemar()) { + 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; @@ -1760,6 +1762,13 @@ export class RdDActor extends Actor { new RdDEncaisser(html, this ).render(true); } + /* -------------------------------------------- */ + 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-roll.js b/module/rdd-roll.js index 27fbd436..a05deb7e 100644 --- a/module/rdd-roll.js +++ b/module/rdd-roll.js @@ -108,11 +108,9 @@ export class RdDRoll extends Dialog { var dialog = this; function updateRollResult(rollData) { - let caracValue = parseInt(rollData.selectedCarac.value) - let rollLevel = dialog._computeFinalLevel(rollData); rollData.dmg = rollData.attackerRoll ? rollData.attackerRoll.dmg : RdDBonus.dmg(rollData, actor.getBonusDegat()); - rollData.finalLevel = rollLevel; - rollData.caracValue = caracValue; + rollData.finalLevel = dialog._computeFinalLevel(rollData); + rollData.caracValue = parseInt(rollData.selectedCarac.value); rollData.coupsNonMortels = (rollData.attackerRoll ? rollData.attackerRoll.dmg.mortalite : rollData.dmg.mortalite) == 'non-mortel'; let dmgText = Misc.toSignedString(rollData.dmg.total); if (rollData.coupsNonMortels) { @@ -120,7 +118,9 @@ export class RdDRoll extends Dialog { } HtmlUtility._showControlWhen($(".diffMoral"), rollData.selectedCarac == actor.data.data.carac.volonte); - HtmlUtility._showControlWhen($(".etat-general"), !dialog._isIgnoreEtatGeneral(rollData)); + + HtmlUtility._showControlWhen($("#etat-general"), !dialog._isIgnoreEtatGeneral(rollData)); + HtmlUtility._showControlWhen($("#ajust-astrologique"), dialog._isAjustementAstrologique(rollData)); // Sort management if (rollData.selectedSort) { @@ -137,9 +137,9 @@ export class RdDRoll extends Dialog { $("#dmg-arme-actor").text(dmgText); $("#defenseur-surprise").text(RdDBonus.description(rollData.surpriseDefenseur)); $(".table-resolution").remove(); - $("#resolutionTable").append(RdDResolutionTable.buildHTMLTableExtract(caracValue, rollLevel)); + $("#resolutionTable").append(RdDResolutionTable.buildHTMLTableExtract(rollData.caracValue, rollData.finalLevel)); $(".span-valeur").remove(); - $("#resolutionValeurs").append(RdDResolutionTable.buildHTMLResults(caracValue, rollLevel)); + $("#resolutionValeurs").append(RdDResolutionTable.buildHTMLResults(rollData.caracValue, rollData.finalLevel)); } // Setup everything onload @@ -228,7 +228,7 @@ export class RdDRoll extends Dialog { const malusEnc = (rollData.surencMalusApply) ? rollData.surencMalusValue : 0; const bonusTactique = RdDBonus.bonusAttaque(rollData.tactique); const malusEncTotal = (rollData.useMalusEncTotal) ? -rollData.encTotal : 0; - const ajustementChance = rollData.selectedCarac.label.toLowerCase().includes('chance') ? rollData.ajustementAstrologique : 0; + const ajustementChance = this._isAjustementAstrologique(rollData) ? rollData.ajustementAstrologique : 0; // Gestion malus armure const malusArmureValue = this._computeMalusArmure(rollData); @@ -239,6 +239,16 @@ export class RdDRoll extends Dialog { return etat + diffCompetence + diffLibre + diffMoral + diffConditions + malusEnc + malusEncTotal + malusArmureValue + ajustementChance + bonusTactique; } + _isAjustementAstrologique(rollData) { + if (rollData.selectedCarac.label.toLowerCase().includes('chance')) { + return true; + } + if (rollData.selectedSort && rollData.selectedSort.data.isrituel) { + return true; + } + return false; + } + _computeDiffCompetence(rollData) { if (rollData.competence) { return Misc.toInt(rollData.competence.data.niveau); diff --git a/templates/actor-humanoide-sheet.html b/templates/actor-humanoide-sheet.html index 137f9936..40e946cc 100644 --- a/templates/actor-humanoide-sheet.html +++ b/templates/actor-humanoide-sheet.html @@ -4,7 +4,15 @@
-

+
+

+
+
+
+ Encaisser des dommages + Remise à neuf +
+
{{data.blessures.resume}} diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 50a17741..9a4f230e 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -109,9 +109,14 @@ {{/if}} {{#if carac.derivee}} +
{{/if}}
- -     + + + +
{{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html"}} diff --git a/templates/dialog-roll-carac.html b/templates/dialog-roll-carac.html index bfaac5c0..c7955bfb 100644 --- a/templates/dialog-roll-carac.html +++ b/templates/dialog-roll-carac.html @@ -20,11 +20,11 @@
{{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html"}} -
- -
-     + + + +
diff --git a/templates/dialog-roll-sort.html b/templates/dialog-roll-sort.html index 947e00b1..6a4061a7 100644 --- a/templates/dialog-roll-sort.html +++ b/templates/dialog-roll-sort.html @@ -1,8 +1,6 @@
-

-
- +
@@ -59,11 +57,11 @@
-
- -
-     + + + +