From 34acf9e00c6d5a90f9c56cbb469fd5656fed3970 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Fri, 20 Nov 2020 16:45:20 +0100 Subject: [PATCH] #27 Gestion des rencontres --- module/actor.js | 8 +++++--- module/rdd-roll-dialog.js | 7 ++++--- module/rdd-tmr-dialog.js | 12 ++++++------ module/tmr-utility.js | 24 ++++++++++++++++++++---- styles/simple.css | 2 +- templates/dialog-roll-sort.html | 7 +++---- templates/dialog-tmr.html | 10 +++++----- 7 files changed, 44 insertions(+), 26 deletions(-) diff --git a/module/actor.js b/module/actor.js index b70d02ba..7997bbed 100644 --- a/module/actor.js +++ b/module/actor.js @@ -768,7 +768,7 @@ export class RdDActor extends Actor { async santeIncDec(name, inc ) { const sante = duplicate(this.data.data.sante); let data = sante[name]; - let minValue = name == "vie" ? - this.data.data.attributs.sconst : 0; + let minValue = name == "vie" ? Number(-this.data.data.attributs.sconst.value) : 0; let newValue = Math.max(minValue, Math.min(data.value + inc, data.max)); if (name == "endurance" && this.data.type != 'entite' ) { @@ -789,7 +789,7 @@ export class RdDActor extends Actor { } } data.value = newValue; - //console.log(name, inc, data.value); + //console.log(name, inc, data.value, newValue, minValue, data.max); if ( sante.fatigue) { // If endurance lost, then the same amount of fatigue cannot be recovered sante.fatigue.value = Math.max(sante.fatigue.value, this._computeFatigueMin()); } @@ -798,10 +798,12 @@ export class RdDActor extends Actor { await this.update( {"data.sante": sante } ); } + /* -------------------------------------------- */ _computeFatigueMin() { return this.data.data.sante.endurance.max - this.data.data.sante.endurance.value; } - + + /* -------------------------------------------- */ _computeEnduranceMax() { let blessures = this.data.data.blessures; let diffVie = this.data.data.sante.vie.max - this.data.data.sante.vie.value; diff --git a/module/rdd-roll-dialog.js b/module/rdd-roll-dialog.js index e699ccf4..6e09abb7 100644 --- a/module/rdd-roll-dialog.js +++ b/module/rdd-roll-dialog.js @@ -25,7 +25,7 @@ export class RdDRollDialog extends Dialog { // Common conf let dialogConf = { content: html, title: "Test", buttons: myButtons, default: "rollButton" } - let dialogOptions = { classes: ["rdddialog"], width: 600, height: 400, 'z-index': 30 } + let dialogOptions = { classes: ["rdddialog"], width: 600, height: 400, 'z-index': 99999 } // Select proper roll dialog template and stuff if (mode == "competence") { @@ -39,7 +39,7 @@ export class RdDRollDialog extends Dialog { dialogOptions.height = 350 } else if (mode == "sort") { dialogConf.title = "Lancer un sort" - dialogConf.height = 470 + dialogConf.height = 490 } super(dialogConf, dialogOptions) @@ -57,7 +57,8 @@ export class RdDRollDialog extends Dialog { /* -------------------------------------------- */ activateListeners(html) { super.activateListeners(html); - + + this.bringToTop(); // Ensure top level // Get the rollData stuff var rollData = this.rollData; diff --git a/module/rdd-tmr-dialog.js b/module/rdd-tmr-dialog.js index 04b5252d..3c6069cc 100644 --- a/module/rdd-tmr-dialog.js +++ b/module/rdd-tmr-dialog.js @@ -201,7 +201,8 @@ export class RdDTMRDialog extends Dialog { rencontre = await TMRUtility.rencontreTMRRoll(coordTMR, cellDescr); } } - //rencontre = await TMRUtility.rencontreTMRRoll(coordTMR, cellDescr); + if ( TMRUtility.isForceRencontre() ) + rencontre = await TMRUtility.rencontreTMRRoll(coordTMR, cellDescr); if (rencontre) { // Manages it if (rencontre.rencontre) rencontre = rencontre.rencontre; // Manage stored rencontres @@ -232,21 +233,20 @@ export class RdDTMRDialog extends Dialog { /* -------------------------------------------- */ updateValuesDisplay() { - let ptsreve = document.getElementById("pointsreve-value"); + let ptsreve = document.getElementById("tmr-pointsreve-value"); ptsreve.innerHTML = this.actor.data.data.reve.reve.value; let tmrpos = document.getElementById("tmr-pos"); let tmr = TMRUtility.getTMRDescription(this.actor.data.data.reve.tmrpos.coord); - //console.log("updateValuesDisplay", this.actor.data.data.reve.tmrpos, tmr); tmrpos.innerHTML = this.actor.data.data.reve.tmrpos.coord + " (" + tmr.label + ")"; - let etat = document.getElementById("etatgeneral-value"); + let etat = document.getElementById("tmr-etatgeneral-value"); etat.innerHTML = this.actor.data.data.compteurs.etat.value; - let refoulement = document.getElementById("refoulement-value"); + let refoulement = document.getElementById("tmr-refoulement-value"); refoulement.innerHTML = this.actor.data.data.reve.refoulement.value; - let fatigueItem = document.getElementById("fatigue-table"); + let fatigueItem = document.getElementById("tmr-fatigue-table"); fatigueItem.innerHTML = "" + RdDUtility.makeHTMLfatigueMatrix(this.actor.data.data.sante.fatigue.value, this.actor.data.data.sante.endurance.max).html() + "
"; } diff --git a/module/tmr-utility.js b/module/tmr-utility.js index 40299194..4ac959b7 100644 --- a/module/tmr-utility.js +++ b/module/tmr-utility.js @@ -265,6 +265,20 @@ export class TMRUtility { return TMRMapping[coordTMR]; } + /* -------------------------------------------- */ + /** Some debug functions */ + static setForceRencontre( id, force ) { + this.forceRencontre = { id: id, force: force} + } + /* -------------------------------------------- */ + static clearForceRencontre( id, force ) { + this.forceRencontre = undefined + } + /* -------------------------------------------- */ + static isForceRencontre() { + return this.forceRencontre + } + /* -------------------------------------------- */ static async rencontreTMRRoll( coordTMR, cellDescr ) { @@ -275,10 +289,12 @@ export class TMRUtility { rencontre.force = this.evaluerForceRencontre(rencontre); rencontre.coord = coordTMR; } - // Forced - //rencontre = rencontresTable[0]; - //rencontre.force = 2; - //rencontre.coord = coordTMR; + if ( this.forceRencontre ) { + // Forced + rencontre = rencontresTable[this.forceRencontre.id]; + rencontre.force = this.forceRencontre.force; + rencontre.coord = coordTMR; + } return rencontre; } diff --git a/styles/simple.css b/styles/simple.css index f731ffc0..b55b3974 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -340,7 +340,7 @@ .rdddialog { width: 600px; height: 430px; - z-index: 100; + z-index: 99999; } .table-resolution-carac { diff --git a/templates/dialog-roll-sort.html b/templates/dialog-roll-sort.html index 30c6df83..79090d55 100644 --- a/templates/dialog-roll-sort.html +++ b/templates/dialog-roll-sort.html @@ -1,10 +1,9 @@

+
-
-
-
diff --git a/templates/dialog-tmr.html b/templates/dialog-tmr.html index aa0336ba..2c9e09ee 100644 --- a/templates/dialog-tmr.html +++ b/templates/dialog-tmr.html @@ -12,20 +12,20 @@
- Rêve Actuel : 0 + 0
- Coordonnées : 0 + 0
- Etat général : 0 + 0
- Refoulement : 0 + 0
Fatigue - {{{fatigue.html}}} + {{{fatigue.html}}}