Gestion de la mise en reserve

This commit is contained in:
sladecraven 2020-07-26 17:26:17 +02:00
parent 0fecc3a202
commit dc57b46db5
3 changed files with 34 additions and 34 deletions

View File

@ -210,19 +210,23 @@ export class RdDActor extends Actor {
if (myReve.value < 0) myReve.value = 0; if (myReve.value < 0) myReve.value = 0;
await this.update( {"data.reve.reve": myReve } ); await this.update( {"data.reve.reve": myReve } );
specialStr += "<br>Réussite du sort pour " + costReve + " Points de Rêve"; specialStr += "<br>Réussite du sort pour " + costReve + " Points de Rêve";
if ( !rollData.isSortReserve)
this.currentTMR.close(); // Close TMR !
} else { } else {
if ( rollData.pointsDeTache == -4) { // Echec total ! if ( rollData.pointsDeTache == -4) { // Echec total !
costReve *= 2; costReve *= 2;
myReve.value = myReve.value - costReve; // Todo 0 pts de reve !!!! myReve.value = myReve.value - costReve; // Todo 0 pts de reve !!!!
if (myReve.value < 0) myReve.value = 0; if (myReve.value < 0) myReve.value = 0;
await this.update( {"data.reve.reve": myReve } ); await this.update( {"data.reve.reve": myReve } );
specialStr += "<br><strong>Echec TOTAL</strong> du sort !, pour " + costReve + " Points de Rêve"; specialStr += "<br><strong>Echec TOTAL</strong> du sort : " + costReve + " Points de Rêve";
} else { } else {
specialStr += "<br>Echec du sort !"; specialStr += "<br>Echec du sort !";
} }
this.currentTMR.close(); // Close TMR !
} }
if (myReve.value == 0) { // 0 points de reve 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 !" } ); 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 { } else {
lvl = (rollData.competence) ? rollData.competence.name : rollData.bmValue; lvl = (rollData.competence) ? rollData.competence.name : rollData.bmValue;
@ -464,20 +468,19 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async rollUnSort( coord ) { async rollUnSort( coord ) {
console.log("Lancer de sort !!!!!");
let draconicList = this.getDraconicList(); let draconicList = this.getDraconicList();
let sortList = this.getSortList(); let sortList = this.getSortList();
let rollData = { let rollData = {
"selectedCarac": this.data.data.carac.reve, selectedCarac: this.data.data.carac.reve,
"etat": this.data.data.compteurs.etat.value, etat: this.data.data.compteurs.etat.value,
"draconicList": draconicList, draconicList: draconicList,
"sortList": sortList, sortList: sortList,
"selectedDraconic": draconicList[0], selectedDraconic: draconicList[0],
"selectedSort": sortList[0], selectedSort: sortList[0],
"coord": coord, coord: coord,
"finalLevel": 0, finalLevel: 0,
"bmValue": 0 bmValue: 0
} }
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-sort.html', rollData); let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-sort.html', rollData);
new RdDRollDialog("sort", html, rollData, this ).render(true); new RdDRollDialog("sort", html, rollData, this ).render(true);
@ -537,7 +540,8 @@ export class RdDActor extends Actor {
isRapide: isRapide isRapide: isRapide
} }
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-tmr.html', data ); 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);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -7,18 +7,20 @@ export class RdDRollDialog extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
constructor(mode, html, rollData, actor) { 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 // Common conf
let dialogConf = { let dialogConf = {
content: html, content: html,
buttons: buttons: myButtons,
{
rollButton:
{
label: "Lancer",
callback: html => this.performRoll(html)
}
},
default: "rollButton" default: "rollButton"
} }
let dialogOptions = { classes: [ "rdddialog"] } let dialogOptions = { classes: [ "rdddialog"] }
@ -39,7 +41,7 @@ export class RdDRollDialog extends Dialog {
} else if (mode == "sort") { } else if (mode == "sort") {
dialogConf.title = "Lancer un sort", dialogConf.title = "Lancer un sort",
dialogOptions.width = 600; dialogOptions.width = 600;
dialogOptions.height = 360; dialogOptions.height = 380;
} }
super(dialogConf, dialogOptions); 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 ); this.actor.performRoll( this.rollData );
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);

View File

@ -299,11 +299,6 @@ export class RdDTMRDialog extends Dialog {
} }
} }
/* -------------------------------------------- */
lancerSort() {
this.actor.rollUnSort(this.actor.data.data.reve.tmrpos.coord);
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async activateListeners(html) { async activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
@ -314,7 +309,7 @@ export class RdDTMRDialog extends Dialog {
// Roll Sort // Roll Sort
html.find('#lancer-sort').click((event) => { html.find('#lancer-sort').click((event) => {
this.lancerSort(); this.actor.rollUnSort(this.actor.data.data.reve.tmrpos.coord);
}); });
// load the texture we need // load the texture we need
@ -352,6 +347,5 @@ export class RdDTMRDialog extends Dialog {
let cellDescr = TMRUtility.getTMRDescription(this.actor.data.data.reve.tmrpos.coord); let cellDescr = TMRUtility.getTMRDescription(this.actor.data.data.reve.tmrpos.coord);
this.manageRencontre( this.actor.data.data.reve.tmrpos.coord,cellDescr ); this.manageRencontre( this.actor.data.data.reve.tmrpos.coord,cellDescr );
this.manageCaseHumide( cellDescr ); this.manageCaseHumide( cellDescr );
} }
} }