From 6f22c4ab18dfa6b6fb677e2469165833c536be64 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Fri, 18 Dec 2020 23:57:28 +0100 Subject: [PATCH] =?UTF-8?q?Volont=C3=A9=20ajust=C3=A9=20par=20moral?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/actor.js | 5 +++++ module/rdd-resolution-table.js | 3 +++ module/rdd-roll.js | 38 ++++++++++++++++++-------------- templates/dialog-competence.html | 1 + templates/dialog-roll-carac.html | 1 + 5 files changed, 31 insertions(+), 17 deletions(-) diff --git a/module/actor.js b/module/actor.js index 88b2e4ef..356a0049 100644 --- a/module/actor.js +++ b/module/actor.js @@ -109,6 +109,11 @@ export class RdDActor extends Actor { return this.data.type == 'creature' || this.data.type == 'entite'; } + /* -------------------------------------------- */ + isPersonnage() { + return this.data.type == 'personnage'; + } + /* -------------------------------------------- */ getReveActuel() { return this.data.data.reve.reve.value; diff --git a/module/rdd-resolution-table.js b/module/rdd-resolution-table.js index 67439ad5..b65ad195 100644 --- a/module/rdd-resolution-table.js +++ b/module/rdd-resolution-table.js @@ -92,6 +92,9 @@ export class RdDResolutionTable { let message = "
Difficultés libre: " + rollData.diffLibre + " / conditions: " + Misc.toSignedString(rollData.diffConditions) + " / état: " + rollData.etat; message += RdDResolutionTable.explain(rollData.rolled) + if (rollData.selectedCarac == rollData.carac.volonte) { + message += " / moral: " + rollData.moral; + } return message; } diff --git a/module/rdd-roll.js b/module/rdd-roll.js index 6070a707..3a22fc1f 100644 --- a/module/rdd-roll.js +++ b/module/rdd-roll.js @@ -33,6 +33,7 @@ export class RdDRoll extends Dialog { ajustementsConditions: CONFIG.RDD.ajustementsConditions, difficultesLibres: CONFIG.RDD.difficultesLibres, etat: actor.data.data.compteurs.etat.value, + moral: actor.isPersonnage() ? actor.data.data.compteurs.moral.value : 0, carac: actor.data.data.carac, finalLevel: 0, diffConditions: rollData.arme ? RdDBonus.bonusAttaque(rollData.surpriseDefenseur) :0, @@ -40,9 +41,9 @@ export class RdDRoll extends Dialog { editLibre: true, editConditions: true, forceValue: actor.getForceValue(), - malusArmureValue: (actor.type == 'personnage ' && actor.data.data.attributs && actor.data.data.attributs.malusarmure) ? actor.data.data.attributs.malusarmure.value : 0, - surencMalusFlag: actor.type == 'personnage ' ? (actor.data.data.compteurs.surenc.value < 0) : false, - surencMalusValue: actor.type == 'personnage ' ? actor.data.data.compteurs.surenc.value : 0, + malusArmureValue: (actor.isPersonnage() && actor.data.data.attributs && actor.data.data.attributs.malusarmure) ? actor.data.data.attributs.malusarmure.value : 0, + surencMalusFlag: actor.isPersonnage() ? (actor.data.data.compteurs.surenc.value < 0) : false, + surencMalusValue: actor.isPersonnage() ? actor.data.data.compteurs.surenc.value : 0, surencMalusApply: false, isNatation: rollData.competence ? rollData.competence.name.toLowerCase().includes("natation") : false, useEncForNatation: false, @@ -103,10 +104,11 @@ export class RdDRoll extends Dialog { var rollData = this.rollData; var actor = this.actor; + var dialog = this; function updateRollResult(rollData) { let caracValue = parseInt(rollData.selectedCarac.value) - let rollLevel = RdDRoll._computeFinalLevel(rollData); + let rollLevel = dialog._computeFinalLevel(rollData); rollData.dmg = rollData.attackerRoll ? rollData.attackerRoll.dmg : RdDBonus.dmg(rollData, actor.getBonusDegat()); rollData.finalLevel = rollLevel; rollData.caracValue = caracValue; @@ -116,7 +118,8 @@ export class RdDRoll extends Dialog { dmgText = '(' + dmgText + ')'; } - HtmlUtility._showControlWhen(".etat-general", !RdDRoll._isIgnoreEtatGeneral(rollData)); + HtmlUtility._showControlWhen(".diffMoral", rollData.selectedCarac == actor.data.data.carac.volonte); + HtmlUtility._showControlWhen(".etat-general", !dialog._isIgnoreEtatGeneral(rollData)); // Sort management if (rollData.selectedSort) { @@ -128,7 +131,7 @@ export class RdDRoll extends Dialog { // Mise à jour valeurs $("#roll-param").text(rollData.selectedCarac.value + " / " + Misc.toSignedString(rollData.finalLevel)); - $("#compdialogTitle").text(RdDRoll._getTitle(rollData)); + $("#compdialogTitle").text(dialog._getTitle(rollData)); $('#coupsNonMortels').prop('checked', rollData.coupsNonMortels); $("#dmg-arme-actor").text(dmgText); $("#defenseur-surprise").text(RdDBonus.description(rollData.surpriseDefenseur)); @@ -213,28 +216,29 @@ export class RdDRoll extends Dialog { }); } - static _isIgnoreEtatGeneral(rollData) { + _isIgnoreEtatGeneral(rollData) { return rollData.selectedCarac.ignoreEtatGeneral; } /* -------------------------------------------- */ - static _computeFinalLevel(rollData) { - const etat = RdDRoll._isIgnoreEtatGeneral(rollData) ? 0 : Misc.toInt(rollData.etat); + _computeFinalLevel(rollData) { + const etat = this._isIgnoreEtatGeneral(rollData) ? 0 : Misc.toInt(rollData.etat); const diffConditions = Misc.toInt(rollData.diffConditions); const malusEnc = (rollData.surencMalusApply) ? rollData.surencMalusValue : 0; const bonusTactique = RdDBonus.bonusAttaque(rollData.tactique); const malusEncNatation = (rollData.useEncForNatation) ? -rollData.encValueForNatation : 0; const ajustementChance = rollData.selectedCarac.label.toLowerCase().includes('chance') ? rollData.ajustementAstrologique : 0; // Gestion malus armure - const malusArmureValue = RdDRoll._computeMalusArmure(rollData); + const malusArmureValue = this._computeMalusArmure(rollData); - const diffLibre = RdDRoll._computeDiffLibre(rollData); - const diffCompetence = RdDRoll._computeDiffCompetence(rollData); + const diffLibre = this._computeDiffLibre(rollData); + const diffCompetence = this._computeDiffCompetence(rollData); + const diffMoral = rollData.selectedCarac == this.actor.data.data.carac.volonte ? rollData.moral : 0; - return etat + diffCompetence + diffLibre + diffConditions + malusEnc + malusEncNatation + malusArmureValue + ajustementChance + bonusTactique; + return etat + diffCompetence + diffLibre + diffMoral + diffConditions + malusEnc + malusEncNatation + malusArmureValue + ajustementChance + bonusTactique; } - static _computeDiffCompetence(rollData) { + _computeDiffCompetence(rollData) { if (rollData.competence) { return Misc.toInt(rollData.competence.data.niveau); } @@ -244,7 +248,7 @@ export class RdDRoll extends Dialog { return 0; } - static _computeDiffLibre(rollData) { + _computeDiffLibre(rollData) { let diffLibre = Misc.toInt(rollData.diffLibre); if (rollData.draconicList && rollData.selectedSort) { return RdDItemSort.getDifficulte(rollData.selectedSort, diffLibre); @@ -252,7 +256,7 @@ export class RdDRoll extends Dialog { return diffLibre; } - static _computeMalusArmure(rollData) { + _computeMalusArmure(rollData) { let malusArmureValue = 0; if (rollData.malusArmureValue != 0 && (rollData.selectedCarac.label == "Agilité" || rollData.selectedCarac.label == "Dérobée")) { $("#addon-message").text("Malus armure appliqué : " + rollData.malusArmureValue); @@ -264,7 +268,7 @@ export class RdDRoll extends Dialog { } /* -------------------------------------------- */ - static _getTitle(rollData) { + _getTitle(rollData) { if (rollData.competence) { // If a weapon is there, add it in the title let armeTitle = (rollData.arme) ? " (" + rollData.arme.name + ") " : ""; diff --git a/templates/dialog-competence.html b/templates/dialog-competence.html index 6cfb1a2d..4f869ae0 100644 --- a/templates/dialog-competence.html +++ b/templates/dialog-competence.html @@ -33,6 +33,7 @@ {{/each}} {{/select}} + {{#if arme}}
diff --git a/templates/dialog-roll-carac.html b/templates/dialog-roll-carac.html index 2f8182fe..bfaac5c0 100644 --- a/templates/dialog-roll-carac.html +++ b/templates/dialog-roll-carac.html @@ -17,6 +17,7 @@ {{/each}} {{/select}} +
{{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html"}}