From 98de1a692256d1d0618e4b1a50480355f5b08291 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Tue, 16 Mar 2021 21:49:21 +0100 Subject: [PATCH] Moral sur les oeuvres MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Simplification de l'appel au moral pour les oeuvres Ajout de la possibilité d'utiliser le moral sur les oeuvres Affichage du moral/appel selon la caractéristique --- module/actor-sheet.js | 6 +- module/rdd-roll.js | 66 ++++++++----------- module/rolldata-ajustements.js | 4 +- styles/simple.css | 2 +- templates/actor-sheet.html | 7 +- templates/dialog-competence.html | 33 +++++----- templates/dialog-roll-alchimie.html | 14 ++-- templates/dialog-roll-carac.html | 41 ++++++------ templates/dialog-roll-chant.html | 14 ++-- templates/dialog-roll-danse.html | 74 +++++++++++---------- templates/dialog-roll-jeu.html | 78 ++++++++++++----------- templates/dialog-roll-musique.html | 12 ++-- templates/dialog-roll-oeuvre.html | 12 ++-- templates/dialog-roll-recettecuisine.html | 14 ++-- 14 files changed, 199 insertions(+), 178 deletions(-) diff --git a/module/actor-sheet.js b/module/actor-sheet.js index e42c3ce8..b4abf4f4 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -489,15 +489,15 @@ export class RdDActorSheet extends ActorSheet { this.actor.transformerStress(); this.render(true); }); - html.find('#moral-malheureux').click((event) => { + html.find('.moral-malheureux').click((event) => { this.actor.jetDeMoral('malheureuse'); this.render(true); }); - html.find('#moral-neutre').click((event) => { + html.find('.moral-neutre').click((event) => { this.actor.jetDeMoral('neutre'); this.render(true); }); - html.find('#moral-heureux').click((event) => { + html.find('.moral-heureux').click((event) => { this.actor.jetDeMoral('heureuse'); this.render(true); }); diff --git a/module/rdd-roll.js b/module/rdd-roll.js index fb25994d..be625be5 100644 --- a/module/rdd-roll.js +++ b/module/rdd-roll.js @@ -18,7 +18,7 @@ export class RdDRoll extends Dialog { /* -------------------------------------------- */ static async create(actor, rollData, dialogConfig, ...actions) { - if (actor.isRollWindowsOpened() ) { + if (actor.isRollWindowsOpened()) { ui.notifications.warn("Vous avez déja une fenêtre de Test ouverte, il faut la fermer avant d'en ouvrir une autre.") return; } @@ -49,20 +49,21 @@ export class RdDRoll extends Dialog { diffConditions: 0, diffLibre: rollData.competence?.data.default_diffLibre ?? 0, malusArmureValue: actor.getMalusArmure(), - surencMalusFlag: actor.isPersonnage() ? (actor.data.data.compteurs.surenc.value < 0) : false, + surencMalusFlag: actor.isPersonnage() ? (actor.data.data.compteurs.surenc.value < 0) : false, surencMalusValue: actor.getSurenc(), useMalusSurenc: false, - appelAuMoralPossible : false, /* Est-ce que l'appel au moral est possible ? Variable utisé pour l'affichage ou non de la ligne concernant le moral */ - appelAuMoralDemander :false, /* Est-ce que le joueur demande d'utiliser le moral ? Utile si le joueur change plusieurs fois de carac associée. */ - perteMoralEchec : false, /* Pour l'affichage dans le chat */ - use: { libre: true, conditions: true, surenc: false, encTotal: false, appelAuMoral : false /* Le jet se fait ou non en utilisant l'appel au moral */}, + useMoral: false, /* Est-ce que le joueur demande d'utiliser le moral ? Utile si le joueur change plusieurs fois de carac associée. */ + perteMoralEchec: false, /* Pour l'affichage dans le chat */ + use: { libre: true, conditions: true, surenc: false, encTotal: false }, isMalusEncombrementTotal: RdDItemCompetence.isMalusEncombrementTotal(rollData.competence), useMalusEncTotal: false, encTotal: actor.getEncTotal(), ajustementAstrologique: actor.ajustementAstrologique(), surprise: actor.getSurprise(false), canClose: true - } + }; + + mergeObject(rollData, defaultRollData, { recursive: true, overwrite: false }); if (rollData.forceCarac) { rollData.carac = rollData.forceCarac; @@ -120,7 +121,7 @@ export class RdDRoll extends Dialog { await RdDResolutionTable.rollData(this.rollData); console.log("RdDRoll -=>", this.rollData, this.rollData.rolled); this.actor.setRollWindowsOpened(false); - + if (action.callbacks) for (let callback of action.callbacks) { if (callback.condition == undefined || callback.condition(this.rollData)) { @@ -206,27 +207,22 @@ export class RdDRoll extends Dialog { this.rollData.useMalusEncTotal = event.currentTarget.checked; this.updateRollResult(); }); - html.find('#iconeSmile').change((event) => { - console.log("iconeSmile"); - console.log(html.find('.iconeSmile')); + html.find('.imgAppelAuMoral').click((event) => { /* l'appel au moral, qui donne un bonus de +1 */ + this.rollData.useMoral = !this.rollData.useMoral; + if (this.rollData.useMoral) { + if (this.rollData.moral > 0) { + html.find('.imgAppelAuMoral')[0].src = "/systems/foundryvtt-reve-de-dragon/icons/moral-heureux.svg"; + html.find('.tooltipAppelAuMoralText')[0].innerHTML = "Appel au moral"; + } else { + html.find('.imgAppelAuMoral')[0].src = "/systems/foundryvtt-reve-de-dragon/icons/moral-malheureux.svg"; + html.find('.tooltipAppelAuMoralText')[0].innerHTML = "Appel à l'énergie du désespoir"; + } + } else { + html.find('.imgAppelAuMoral')[0].src = "/systems/foundryvtt-reve-de-dragon/icons/moral-neutre.svg"; + html.find('.tooltipAppelAuMoralText')[0].innerHTML = "Sans appel au moral"; + } this.updateRollResult(); - }); - html.find('#iconeSmile').click((event) => { /* l'appel au moral, qui donne un bonus de +1 */ - this.rollData.appelAuMoralDemander = ! this.rollData.appelAuMoralDemander; - if ( this.rollData.appelAuMoralDemander ) { - if ( this.rollData.moral > 0 ) { - html.find('#iconeSmile')[0].src = "/systems/foundryvtt-reve-de-dragon/icons/moral-heureux.svg"; - html.find('#tooltipAppelAuMoralText')[0].innerHTML = "Appel au moral"; - } else { - html.find('#iconeSmile')[0].src = "/systems/foundryvtt-reve-de-dragon/icons/moral-malheureux.svg"; - html.find('#tooltipAppelAuMoralText')[0].innerHTML = "Appel à l'énergie du désespoir"; - } - } else { - html.find('#iconeSmile')[0].src = "/systems/foundryvtt-reve-de-dragon/icons/moral-neutre.svg"; - html.find('#tooltipAppelAuMoralText')[0].innerHTML = "Sans appel au moral"; - } - this.updateRollResult(); - }); + }); // Section Méditation html.find('.conditionMeditation').change((event) => { let condition = event.currentTarget.attributes['id'].value; @@ -238,10 +234,11 @@ export class RdDRoll extends Dialog { /* -------------------------------------------- */ async updateRollResult() { let rollData = this.rollData; - + rollData.dmg = rollData.attackerRoll?.dmg ?? RdDBonus.dmg(rollData, this.actor.getBonusDegat()); rollData.caracValue = parseInt(rollData.selectedCarac.value); rollData.coupsNonMortels = (rollData.attackerRoll?.dmg.mortalite ?? rollData.dmg.mortalite) == 'non-mortel'; + rollData.use.appelAuMoral = this.actor.isPersonnage() && RdDCarac.isActionPhysique(rollData.selectedCarac); let dmgText = Misc.toSignedString(rollData.dmg.total); if (rollData.coupsNonMortels) { @@ -252,21 +249,12 @@ export class RdDRoll extends Dialog { HtmlUtility._showControlWhen($("#div-sort-difficulte"), RdDItemSort.isDifficulteVariable(rollData.selectedSort)) HtmlUtility._showControlWhen($("#div-sort-ptreve"), RdDItemSort.isCoutVariable(rollData.selectedSort)) } - - if ( ! RdDCarac.isActionPhysique(rollData.selectedCarac || ! actor.isPersonnage() ) ) { - rollData.appelAuMoralPossible = false; - rollData.use.appelAuMoral = false; - } else { - rollData.appelAuMoralPossible = true; - rollData.use.appelAuMoral = rollData.appelAuMoralDemander; - - } RollDataAjustements.calcul(rollData, this.actor); rollData.finalLevel = this._computeFinalLevel(rollData); HtmlUtility._showControlWhen($(".diffMoral"), rollData.ajustements.moralTotal.used); - HtmlUtility._showControlWhen($("#divAppelAuMoral"), rollData.appelAuMoralPossible ); + HtmlUtility._showControlWhen($(".divAppelAuMoral"), rollData.use.appelAuMoral); HtmlUtility._showControlWhen($("#etat-general"), !RdDCarac.isIgnoreEtatGeneral(rollData.selectedCarac, rollData.competence)); HtmlUtility._showControlWhen($("#ajust-astrologique"), RdDResolutionTable.isAjustementAstrologique(rollData)); diff --git a/module/rolldata-ajustements.js b/module/rolldata-ajustements.js index 049b0972..1d4eb657 100644 --- a/module/rolldata-ajustements.js +++ b/module/rolldata-ajustements.js @@ -73,8 +73,8 @@ export const referenceAjustements = { getValue: (rollData, actor) => actor.getSurenc() }, moral: { - isVisible: (rollData, actor) => RdDCarac.isActionPhysique(rollData.selectedCarac), - isUsed: (rollData, actor) => rollData.use?.appelAuMoral, + isVisible: (rollData, actor) => actor.isPersonnage() && RdDCarac.isActionPhysique(rollData.selectedCarac) && rollData.useMoral, + isUsed: (rollData, actor) => rollData.useMoral, getLabel: (rollData, actor) => 'Appel au moral', getValue: (rollData, actor) => 1 }, diff --git a/styles/simple.css b/styles/simple.css index c3f6f71e..8f14b3aa 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -825,7 +825,7 @@ ul, li { display: none !important; } -.iconeSmile { +.imgAppelAuMoral { height: 20px; width: 20px; border:none; diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 80f64dea..e96e8512 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -1,4 +1,3 @@ -{{log "handlebar actor-sheet" this}}
{{!-- Sheet Header --}} @@ -198,9 +197,9 @@ {{else if (eq compteur.label 'Ethylisme')}} Jet d'Ethylisme {{else if (eq compteur.label 'Moral')}} - Jet de moral situation malheureuse - Jet de moral situation neutre - Jet de moral situation heureuse + Jet de moral situation malheureuse + Jet de moral situation neutre + Jet de moral situation heureuse {{else}} {{/if}} diff --git a/templates/dialog-competence.html b/templates/dialog-competence.html index a099493b..a2d55743 100644 --- a/templates/dialog-competence.html +++ b/templates/dialog-competence.html @@ -1,7 +1,7 @@

- + - -
-
- - - Sans appel au moral -
-
+ + +
+ + Sans appel au moral +
{{#if attackerRoll}} - + {{else}} - + {{/if}} - + -
{{#if arme}}
{{#if attackerRoll}} {{#if attackerRoll.tactique}} - + {{/if}} - + {{else}} - + {{/if}} {{#if ajustements.attaqueDefenseurSurpris.used}} - + {{/if}}
{{/if}} diff --git a/templates/dialog-roll-alchimie.html b/templates/dialog-roll-alchimie.html index 87323064..5062e3ea 100644 --- a/templates/dialog-roll-alchimie.html +++ b/templates/dialog-roll-alchimie.html @@ -1,14 +1,18 @@
    -
  • -
  • -
  • +
  • +
  • +
+
+ + Sans appel au moral +
- + - + +

+
+ + - - + + - -
-{{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html"}} -
-
-
-
-
-
+ + +
+ + Sans appel au moral +
+
+ {{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html"}} +
+
+
+
+
+
+ \ No newline at end of file diff --git a/templates/dialog-roll-chant.html b/templates/dialog-roll-chant.html index 6fa436b5..cff88cd8 100644 --- a/templates/dialog-roll-chant.html +++ b/templates/dialog-roll-chant.html @@ -1,13 +1,17 @@
    -
  • -
  • +
  • +
-
+
+ + Sans appel au moral +
+
- + - + - {{#select carac}} - {{#each carac as |caracitem key|}} - - {{/each}} - {{/select}} - +
+ + +
+ + Sans appel au moral +
+
-
- - {{#select diffConditions}} {{#each ajustementsConditions as |key|}} {{/each}} {{/select}} - - - -
+ + + +
-
-
-
-
-
-
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/templates/dialog-roll-jeu.html b/templates/dialog-roll-jeu.html index 0ccf3b77..c8336994 100644 --- a/templates/dialog-roll-jeu.html +++ b/templates/dialog-roll-jeu.html @@ -1,46 +1,52 @@
-
-
    -
  • -
  • -
  • -
  • -
-
-
- - - - + {{#select carac}} + {{#each carac as |caracitem key|}} + + {{/each}} + {{/select}} + +
+ + Sans appel au moral +
+
+
+ + - - -
+ + + + -
-
-
-
-
-
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/templates/dialog-roll-musique.html b/templates/dialog-roll-musique.html index faa65989..c54c5552 100644 --- a/templates/dialog-roll-musique.html +++ b/templates/dialog-roll-musique.html @@ -1,13 +1,17 @@
    -
  • -
  • +
  • +
+
+ + Sans appel au moral +
- + - + {{#select diffConditions}} {{#each ajustementsConditions as |key|}} @@ -15,7 +19,7 @@ {{/each}} {{/select}} - + {{#select diffConditions}} {{#each ajustementsConditions as |key|}} @@ -17,7 +21,7 @@ {{/each}} {{/select}} - +