diff --git a/module/actor.js b/module/actor.js index b0adbbdc..19c79bbb 100644 --- a/module/actor.js +++ b/module/actor.js @@ -210,19 +210,23 @@ export class RdDActor extends Actor { if (myReve.value < 0) myReve.value = 0; await this.update( {"data.reve.reve": myReve } ); specialStr += "
Réussite du sort pour " + costReve + " Points de Rêve"; + if ( !rollData.isSortReserve) + this.currentTMR.close(); // Close TMR ! } else { if ( rollData.pointsDeTache == -4) { // Echec total ! costReve *= 2; myReve.value = myReve.value - costReve; // Todo 0 pts de reve !!!! if (myReve.value < 0) myReve.value = 0; await this.update( {"data.reve.reve": myReve } ); - specialStr += "
Echec TOTAL du sort !, pour " + costReve + " Points de Rêve"; + specialStr += "
Echec TOTAL du sort : " + costReve + " Points de Rêve"; } else { specialStr += "
Echec du sort !"; } + this.currentTMR.close(); // Close TMR ! } if (myReve.value == 0) { // 0 points de reve ChatMessage.create( {title: "Zero Points de Reve !", content: this.name + " est réduit à 0 Points de Rêve, et tombe endormi !" } ); + this.currentTMR.close(); // Close TMR ! } } else { lvl = (rollData.competence) ? rollData.competence.name : rollData.bmValue; @@ -464,20 +468,19 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async rollUnSort( coord ) { - console.log("Lancer de sort !!!!!"); let draconicList = this.getDraconicList(); let sortList = this.getSortList(); let rollData = { - "selectedCarac": this.data.data.carac.reve, - "etat": this.data.data.compteurs.etat.value, - "draconicList": draconicList, - "sortList": sortList, - "selectedDraconic": draconicList[0], - "selectedSort": sortList[0], - "coord": coord, - "finalLevel": 0, - "bmValue": 0 + selectedCarac: this.data.data.carac.reve, + etat: this.data.data.compteurs.etat.value, + draconicList: draconicList, + sortList: sortList, + selectedDraconic: draconicList[0], + selectedSort: sortList[0], + coord: coord, + finalLevel: 0, + bmValue: 0 } let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-sort.html', rollData); new RdDRollDialog("sort", html, rollData, this ).render(true); @@ -537,7 +540,8 @@ export class RdDActor extends Actor { isRapide: isRapide } let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-tmr.html', data ); - new RdDTMRDialog(html, this, data ).render(true); + this.currentTMR = new RdDTMRDialog(html, this, data ); + this.currentTMR.render(true); } /* -------------------------------------------- */ diff --git a/module/rdd-roll-dialog.js b/module/rdd-roll-dialog.js index e886920b..0d18a7ea 100644 --- a/module/rdd-roll-dialog.js +++ b/module/rdd-roll-dialog.js @@ -7,20 +7,22 @@ export class RdDRollDialog extends Dialog { /* -------------------------------------------- */ constructor(mode, html, rollData, actor) { - + let myButtons = { rollButton: { + label: "Lancer", + callback: html => this.performRollSort(html, false) + } }; + if (mode == "sort") { + myButtons['reserveButton'] = { label: "Mettre en reserve", + callback: html => this.performRollSort(html, true) + } + } + // Common conf let dialogConf = { content: html, - buttons: - { - rollButton: - { - label: "Lancer", - callback: html => this.performRoll(html) - } - }, - default: "rollButton" - } + buttons: myButtons, + default: "rollButton" + } let dialogOptions = { classes: [ "rdddialog"] } // Select proper roll dialog template and stuff @@ -39,7 +41,7 @@ export class RdDRollDialog extends Dialog { } else if (mode == "sort") { dialogConf.title = "Lancer un sort", dialogOptions.width = 600; - dialogOptions.height = 360; + dialogOptions.height = 380; } super(dialogConf, dialogOptions); @@ -49,12 +51,12 @@ export class RdDRollDialog extends Dialog { } /* -------------------------------------------- */ - performRoll (html) { + performRollSort (html, isReserve=false) { + this.rollData.isSortReserve = isReserve; this.actor.performRoll( this.rollData ); } /* -------------------------------------------- */ - activateListeners(html) { super.activateListeners(html); diff --git a/module/rdd-tmr-dialog.js b/module/rdd-tmr-dialog.js index d3c22905..0c6195cd 100644 --- a/module/rdd-tmr-dialog.js +++ b/module/rdd-tmr-dialog.js @@ -298,11 +298,6 @@ export class RdDTMRDialog extends Dialog { } } - - /* -------------------------------------------- */ - lancerSort() { - this.actor.rollUnSort(this.actor.data.data.reve.tmrpos.coord); - } /* -------------------------------------------- */ async activateListeners(html) { @@ -314,7 +309,7 @@ export class RdDTMRDialog extends Dialog { // Roll Sort html.find('#lancer-sort').click((event) => { - this.lancerSort(); + this.actor.rollUnSort(this.actor.data.data.reve.tmrpos.coord); }); // load the texture we need @@ -351,7 +346,6 @@ export class RdDTMRDialog extends Dialog { this.updateValuesDisplay(); let cellDescr = TMRUtility.getTMRDescription(this.actor.data.data.reve.tmrpos.coord); this.manageRencontre( this.actor.data.data.reve.tmrpos.coord,cellDescr ); - this.manageCaseHumide( cellDescr ); - + this.manageCaseHumide( cellDescr ); } }