From aa1c93ce22afc6cc838a5cb9839b8c7029b9a526 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sat, 6 Feb 2021 02:29:58 +0100 Subject: [PATCH] =?UTF-8?q?Preparation=20ma=C3=AEtrise=20fleuve?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/actor.js | 3 +- module/rdd-roll.js | 53 +++++++++++++++++-------------- module/rdd-tmr-dialog.js | 3 ++ module/rolldata-ajustements.js | 4 +-- templates/chat-resultat-sort.html | 8 +++-- templates/dialog-roll-sort.html | 2 +- 6 files changed, 43 insertions(+), 30 deletions(-) diff --git a/module/actor.js b/module/actor.js index af1cc5ba..e466049d 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1731,8 +1731,7 @@ export class RdDActor extends Actor { sortList: sortList, competence: this.getBestDraconic(), selectedSort: sortList[0], - coord: coord, - coordLabel: TMRUtility.getTMR(coord).label, + tmr: TMRUtility.getTMR(coord), diffLibre: sortList[0].data.difficulte, // Per default at startup coutreve: Array(20).fill().map((item, index) => 1 + index) } diff --git a/module/rdd-roll.js b/module/rdd-roll.js index 4c81ad17..bbde3323 100644 --- a/module/rdd-roll.js +++ b/module/rdd-roll.js @@ -46,15 +46,16 @@ export class RdDRoll extends Dialog { surencMalusFlag: actor.isPersonnage() ? (actor.data.data.compteurs.surenc.value < 0) : false, surencMalusValue: actor.getSurenc(), useMalusSurenc: false, - use: { libre:true, conditions: true, surenc: false, encTotal: false, }, + 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) { + if (rollData.forceCarac) { rollData.carac = rollData.forceCarac; } RollDataAjustements.calcul(rollData, actor); @@ -82,7 +83,12 @@ export class RdDRoll extends Dialog { close: close }; for (let action of actions) { - conf.buttons[action.name] = { label: action.label, callback: html => this.onAction(action, html) }; + conf.buttons[action.name] = { + label: action.label, callback: html => { + this.rollData.canClose = true; + this.onAction(action, html) + } + }; } super(conf, options); @@ -91,6 +97,14 @@ export class RdDRoll extends Dialog { this.rollData = rollData; } + close() { + if (this.rollData.canClose) { + return super.close(); + } + ui.notifications.info("Vous devez faire ce jet de dés!"); + } + + /* -------------------------------------------- */ async onAction(action, html) { await RdDResolutionTable.rollData(this.rollData); @@ -111,7 +125,7 @@ export class RdDRoll extends Dialog { this.bringToTop(); var dialog = this; - + function onLoad() { let rollData = dialog.rollData; // Update html, according to data @@ -121,7 +135,7 @@ export class RdDRoll extends Dialog { $("#carac").val(rollData.competence.data.defaut_carac); } if (rollData.selectedSort) { - $("#draconic").val( rollData.selectedSort.data.listIndex ); // Uniquement a la selection du sort, pour permettre de changer + $("#draconic").val(rollData.selectedSort.data.listIndex); // Uniquement a la selection du sort, pour permettre de changer } RdDItemSort.setCoutReveReel(rollData.selectedSort); $("#diffLibre").val(Misc.toInt(rollData.diffLibre)); @@ -154,9 +168,9 @@ export class RdDRoll extends Dialog { html.find('#sort').change((event) => { let sortKey = Misc.toInt(event.currentTarget.value); this.rollData.selectedSort = this.rollData.sortList[sortKey]; // Update the selectedCarac - this.rollData.bonus = RdDItemSort.getCaseBonus(this.rollData.selectedSort, this.rollData.coord); + this.rollData.bonus = RdDItemSort.getCaseBonus(this.rollData.selectedSort, this.rollData.tmr.coord); RdDItemSort.setCoutReveReel(this.rollData.selectedSort); - $("#draconic").val( this.rollData.selectedSort.data.listIndex ); // Uniquement a la selection du sort, pour permettre de changer + $("#draconic").val(this.rollData.selectedSort.data.listIndex); // Uniquement a la selection du sort, pour permettre de changer this.updateRollResult(); }); html.find('#ptreve-variable').change((event) => { @@ -208,29 +222,22 @@ export class RdDRoll extends Dialog { dmgText = '(' + dmgText + ')'; } if (rollData.selectedSort) { - rollData.bonus = RdDItemSort.getCaseBonus(rollData.selectedSort, rollData.coord); - } - - RollDataAjustements.calcul(rollData, this.actor); - rollData.finalLevel = this._computeFinalLevel(rollData); - - HtmlUtility._showControlWhen($(".diffMoral"), rollData.ajustements.moralTotal.used); - HtmlUtility._showControlWhen($("#etat-general"), !RdDCarac.isIgnoreEtatGeneral(rollData.selectedCarac, rollData.competence)); - HtmlUtility._showControlWhen($("#ajust-astrologique"), RdDResolutionTable.isAjustementAstrologique(rollData)); - - // Sort management - if (rollData.selectedSort) { - rollData.bonus = RdDItemSort.getCaseBonus(rollData.selectedSort, rollData.coord); - //console.log("Toggle show/hide", rollData.selectedSort); + rollData.bonus = RdDItemSort.getCaseBonus(rollData.selectedSort, rollData.tmr.coord); HtmlUtility._showControlWhen($("#div-sort-difficulte"), RdDItemSort.isDifficulteVariable(rollData.selectedSort)) HtmlUtility._showControlWhen($("#div-sort-ptreve"), RdDItemSort.isCoutVariable(rollData.selectedSort)) } + RollDataAjustements.calcul(rollData, this.actor); + rollData.finalLevel = this._computeFinalLevel(rollData); + + HtmlUtility._showControlWhen($(".diffMoral"), rollData.ajustements.moralTotal.used); + HtmlUtility._showControlWhen($("#etat-general"), !RdDCarac.isIgnoreEtatGeneral(rollData.selectedCarac, rollData.competence)); + HtmlUtility._showControlWhen($("#ajust-astrologique"), RdDResolutionTable.isAjustementAstrologique(rollData)); + // Mise à jour valeurs $("#compdialogTitle").text(this._getTitle(rollData)); $('#coupsNonMortels').prop('checked', rollData.coupsNonMortels); $("#dmg-arme-actor").text(dmgText); -// $("#defenseur-surprise").text(RdDBonus.description(rollData.ajustements.attaqueDefenseurSurpris.descr)); $('.table-ajustement').remove(); $(".table-resolution").remove(); $(".table-proba-reussite").remove(); @@ -241,7 +248,7 @@ export class RdDRoll extends Dialog { /* -------------------------------------------- */ - async buildAjustements(rollData){ + async buildAjustements(rollData) { const html = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/dialog-roll-ajustements.html`, rollData); return html; } diff --git a/module/rdd-tmr-dialog.js b/module/rdd-tmr-dialog.js index ac36b550..1018ee18 100644 --- a/module/rdd-tmr-dialog.js +++ b/module/rdd-tmr-dialog.js @@ -292,6 +292,9 @@ export class RdDTMRDialog extends Dialog { let dialog = new RdDTMRRencontreDialog("", this, this.currentRencontre, postRencontre); dialog.render(true); } + else { + postRencontre(); + } } /* -------------------------------------------- */ diff --git a/module/rolldata-ajustements.js b/module/rolldata-ajustements.js index 67dd2c78..ecc58c77 100644 --- a/module/rolldata-ajustements.js +++ b/module/rolldata-ajustements.js @@ -116,8 +116,8 @@ export const referenceAjustements = { getDescr: (rollData, actor) => rollData.selectedSort && rollData.coord ? `Bonus de case: ${RdDItemSort.getCaseBonus(rollData.selectedSort, rollData.coord)}%` : '' }, rencontreTMR: { - isVisible: (rollData, actor) => rollData.tmr && rollData.rencontre.name, - isUsed: (rollData, actor) => rollData.tmr && rollData.rencontre.name, + isVisible: (rollData, actor) => rollData.tmr && rollData.rencontre?.name, + isUsed: (rollData, actor) => rollData.tmr && rollData.rencontre?.name, getLabel: (rollData, actor) => rollData.rencontre?.name, getValue: (rollData, actor) => - (rollData.rencontre?.force ?? 0) } diff --git a/templates/chat-resultat-sort.html b/templates/chat-resultat-sort.html index c9ed4073..b17920a9 100644 --- a/templates/chat-resultat-sort.html +++ b/templates/chat-resultat-sort.html @@ -4,7 +4,7 @@ le {{#if selectedSort.data.isrituel}}rituel{{else}}sort{{/if}} {{selectedSort.name}} -
Pour {{selectedSort.data.ptreve_reel}} point{{~#if (gt selectedSort.data.ptreve_reel 1)}}s{{/if}} de rêve en {{coordLabel}} ({{coord}}). +
Pour {{selectedSort.data.ptreve_reel}} point{{~#if (gt selectedSort.data.ptreve_reel 1)}}s{{/if}} de rêve en {{tmr.label}} ({{tmr.coord}}). {{#if show.reveInsuffisant}} Pas assez de rêve! {{/if}} @@ -22,4 +22,8 @@ {{else}}{{depenseReve}} points de rêve ont été dépensés {{~/if}}. -
\ No newline at end of file +
+
+ + {{{selectedSort.data.description}}} + diff --git a/templates/dialog-roll-sort.html b/templates/dialog-roll-sort.html index 3879df15..c32366ef 100644 --- a/templates/dialog-roll-sort.html +++ b/templates/dialog-roll-sort.html @@ -1,7 +1,7 @@
- +