diff --git a/module/actor.js b/module/actor.js index f398355b..56df451a 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1595,7 +1595,7 @@ export class RdDActor extends Actor { } /* -------------------------------------------- */ - createCallbackAppelAuMoral() { + createCallbackAppelAuMoral() { /* Si l'appel au moral est utilisé, on l'affiche dans le chat et on diminue éventuellement le moral */ return { condition: r => r.use.appelAuMoral && game.settings.get("core", "rollMode") != 'selfroll', action: r => { console.log("createCallbackAppelAuMoral"); this.displayAppelAuMoral ; console.log(r.rolled.isEchec); this._appliquerAppelMoral(r, game.settings.get("core", "rollMode") != 'blindroll') } @@ -1675,23 +1675,10 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async _appliquerAppelMoral(rollData, display = true) { - console.log("_appliquerAppelMoral"); - console.log("_appliquerAppelMoral"); - console.log("_appliquerAppelMoral"); - console.log("_appliquerAppelMoral"); - console.log(rollData); - console.log(this.name); - console.log(this); if (!this.isPersonnage()) return; if (!rollData.rolled.isEchec) return; const waitUpdate = this.moralIncDec(-1); /* L'appel au moral a échoué. Le personnage perd un point de moral */ - console.log("_appliquerAppelMoral : moral diminuer"); - rollData.moralDiminuer = true; - rollData.moralActualiser = 7; - await waitUpdate; - rollData.moralActualiser = this.getMoralTotal(); - console.log("rollData.moralDiminuer: "+rollData.moralDiminuer); - console.log("rollData.moralActualiser: "+rollData.moralActualiser); + rollData.jetEchouerMoralDiminuer = true; } /* -------------------------------------------- */ diff --git a/module/rdd-roll.js b/module/rdd-roll.js index 8d51628f..0b51a02a 100644 --- a/module/rdd-roll.js +++ b/module/rdd-roll.js @@ -46,17 +46,17 @@ export class RdDRoll extends Dialog { surencMalusFlag: actor.isPersonnage() ? (actor.data.data.compteurs.surenc.value < 0) : false, surencMalusValue: actor.getSurenc(), useMalusSurenc: false, - appelAuMoralDemander :false, - use: { libre:true, conditions: true, surenc: false, encTotal: false, appelAuMoral : 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. */ + jetEchouerMoralDiminuer : 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 */}, isMalusEncombrementTotal: RdDItemCompetence.isMalusEncombrementTotal(rollData.competence), useMalusEncTotal: false, encTotal: actor.getEncTotal(), ajustementAstrologique: actor.ajustementAstrologique(), surprise: actor.getSurprise(false), } - console.log("defaultRollData.appelAuMoralFlag : "+defaultRollData.appelAuMoralFlag); mergeObject(rollData, defaultRollData, { recursive: true, overwrite: false }); - console.log("rollData.appelAuMoralFlag : "+rollData.appelAuMoralFlag); if ( rollData.forceCarac) { rollData.carac = rollData.forceCarac; } @@ -190,21 +190,25 @@ 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')); + this.updateRollResult(); + }); html.find('#useAppelAuMoralCheckbox').change((event) => { /* l'appel au moral, qui donne un bonus de +1 */ - - console.log("#useAppelAuMoralCheckbox"); - //console.log("surencMalusFlag : "+surencMalusFlag); - console.log("this.appelAuMoralFlag : "+this.appelAuMoralFlag); - console.log("this.rollData.moral : "+this.rollData.moral); - console.log("this.rollData.ajustements : "+this.rollData.ajustements); - console.log("this.rollData.ajustements.moral : "+this.rollData.ajustements.moral); - console.log("this.rollData.ajustements.moral.isVisible : "+this.rollData.ajustements.moral.isVisible); - console.log("event.currentTarget.checked : "+event.currentTarget.checked); - console.log("this.rollData.use.appelAuMoral : "+this.rollData.use.appelAuMoral); this.rollData.appelAuMoralDemander = event.currentTarget.checked - // this.rollData.use.appelAuMoral = event.currentTarget.checked - console.log("this.rollData.moral : "+this.rollData.moral); - console.log("this.rollData.use.appelAuMoral : "+this.rollData.use.appelAuMoral); + 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('#textSmile')[0].innerHTML = "Appel au moral"; + } else { + html.find('#iconeSmile')[0].src = "/systems/foundryvtt-reve-de-dragon/icons/moral-malheureux.svg"; + html.find('#textSmile')[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('#textSmile')[0].innerHTML = "Sans appel au moral"; + } this.updateRollResult(); }); // Section Méditation @@ -231,28 +235,21 @@ export class RdDRoll extends Dialog { rollData.bonus = RdDItemSort.getCaseBonus(rollData.selectedSort, rollData.coord); } - /* ! actor.isPersonnage() || */ - if ( ! RdDCarac.isActionPhysique(rollData.selectedCarac) ) { - rollData.use.appelAuMoral = false; + if ( ! RdDCarac.isActionPhysique(rollData.selectedCarac || ! actor.isPersonnage() ) ) { + rollData.appelAuMoralPossible = false; + rollData.use.appelAuMoral = false; } else { - rollData.use.appelAuMoral = rollData.appelAuMoralDemander; + rollData.appelAuMoralPossible = true; + rollData.use.appelAuMoral = rollData.appelAuMoralDemander; + } RollDataAjustements.calcul(rollData, this.actor); rollData.finalLevel = this._computeFinalLevel(rollData); - console.log("updateRollResult"); - console.log("rollData.ajustements.moralTotal.used: "+rollData.ajustements.moralTotal.used); - console.log("rollData.ajustements.moral.used: "+rollData.ajustements.moral.used); - console.log("rollData.use.appelAuMoral: "+rollData.use.appelAuMoral); - console.log("rollData.selectedCarac: "); - console.log(rollData.selectedCarac); - console.log("RdDCarac.isActionPhysique(rollData.selectedCarac): "+RdDCarac.isActionPhysique(rollData.selectedCarac)); - HtmlUtility._showControlWhen($(".diffMoral"), rollData.ajustements.moralTotal.used); - HtmlUtility._showControlWhen($(".diffAppelAuMoral"), RdDCarac.isActionPhysique(rollData.selectedCarac) ); - HtmlUtility._showControlWhen($(".diffAppelAuMoral-checker"), RdDCarac.isActionPhysique(rollData.selectedCarac) ); + HtmlUtility._showControlWhen($("#divAppelAuMoral"), rollData.appelAuMoralPossible ); HtmlUtility._showControlWhen($("#etat-general"), !RdDCarac.isIgnoreEtatGeneral(rollData.selectedCarac, rollData.competence)); HtmlUtility._showControlWhen($("#ajust-astrologique"), RdDResolutionTable.isAjustementAstrologique(rollData)); diff --git a/styles/simple.css b/styles/simple.css index d0f30f69..94ebf9e2 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -811,22 +811,26 @@ ul, li { left: 0px; text-align: center; } - - .diffAppelAuMoral { display: none !important; } -.diffAppelAuMoral-checker{ - display: inline-block; - background-image: url('../icons/moral-neutre.svg'); - width: 20px; +.diffAppelAuMoral-checker { height: 20px; + background-image: url('../icons/moral-neutre.svg'); background-size: cover; } .diffAppelAuMoral:checked + .diffAppelAuMoral-checker { background-image: url('../icons/moral-heureux.svg'); } - +.iconeSmile { + height: 20px; + width: 20px; + border:none; + outline: none; + background-size: cover; +} +.textSmile { +} /* ======================================== */ /* Fatigue CSS */ diff --git a/templates/chat-info-appel-au-moral.html b/templates/chat-info-appel-au-moral.html index 7b340d0f..6ceef396 100644 --- a/templates/chat-info-appel-au-moral.html +++ b/templates/chat-info-appel-au-moral.html @@ -1,4 +1,4 @@ {{#if use.appelAuMoral}}