#27 Gestion des rencontres

This commit is contained in:
sladecraven 2020-11-20 16:45:20 +01:00
parent 7ff428d1c2
commit 34acf9e00c
7 changed files with 44 additions and 26 deletions

View File

@ -768,7 +768,7 @@ export class RdDActor extends Actor {
async santeIncDec(name, inc ) { async santeIncDec(name, inc ) {
const sante = duplicate(this.data.data.sante); const sante = duplicate(this.data.data.sante);
let data = sante[name]; 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)); let newValue = Math.max(minValue, Math.min(data.value + inc, data.max));
if (name == "endurance" && this.data.type != 'entite' ) { if (name == "endurance" && this.data.type != 'entite' ) {
@ -789,7 +789,7 @@ export class RdDActor extends Actor {
} }
} }
data.value = newValue; 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 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()); 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 } ); await this.update( {"data.sante": sante } );
} }
/* -------------------------------------------- */
_computeFatigueMin() { _computeFatigueMin() {
return this.data.data.sante.endurance.max - this.data.data.sante.endurance.value; return this.data.data.sante.endurance.max - this.data.data.sante.endurance.value;
} }
/* -------------------------------------------- */
_computeEnduranceMax() { _computeEnduranceMax() {
let blessures = this.data.data.blessures; let blessures = this.data.data.blessures;
let diffVie = this.data.data.sante.vie.max - this.data.data.sante.vie.value; let diffVie = this.data.data.sante.vie.max - this.data.data.sante.vie.value;

View File

@ -25,7 +25,7 @@ export class RdDRollDialog extends Dialog {
// Common conf // Common conf
let dialogConf = { content: html, title: "Test", buttons: myButtons, default: "rollButton" } 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 // Select proper roll dialog template and stuff
if (mode == "competence") { if (mode == "competence") {
@ -39,7 +39,7 @@ export class RdDRollDialog extends Dialog {
dialogOptions.height = 350 dialogOptions.height = 350
} else if (mode == "sort") { } else if (mode == "sort") {
dialogConf.title = "Lancer un sort" dialogConf.title = "Lancer un sort"
dialogConf.height = 470 dialogConf.height = 490
} }
super(dialogConf, dialogOptions) super(dialogConf, dialogOptions)
@ -58,6 +58,7 @@ export class RdDRollDialog extends Dialog {
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
this.bringToTop(); // Ensure top level
// Get the rollData stuff // Get the rollData stuff
var rollData = this.rollData; var rollData = this.rollData;

View File

@ -201,7 +201,8 @@ export class RdDTMRDialog extends Dialog {
rencontre = await TMRUtility.rencontreTMRRoll(coordTMR, cellDescr); 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) { // Manages it
if (rencontre.rencontre) rencontre = rencontre.rencontre; // Manage stored rencontres if (rencontre.rencontre) rencontre = rencontre.rencontre; // Manage stored rencontres
@ -232,21 +233,20 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
updateValuesDisplay() { updateValuesDisplay() {
let ptsreve = document.getElementById("pointsreve-value"); let ptsreve = document.getElementById("tmr-pointsreve-value");
ptsreve.innerHTML = this.actor.data.data.reve.reve.value; ptsreve.innerHTML = this.actor.data.data.reve.reve.value;
let tmrpos = document.getElementById("tmr-pos"); let tmrpos = document.getElementById("tmr-pos");
let tmr = TMRUtility.getTMRDescription(this.actor.data.data.reve.tmrpos.coord); 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 + ")"; 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; 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; refoulement.innerHTML = this.actor.data.data.reve.refoulement.value;
let fatigueItem = document.getElementById("fatigue-table"); let fatigueItem = document.getElementById("tmr-fatigue-table");
fatigueItem.innerHTML = "<table class='table-fatigue'>" + RdDUtility.makeHTMLfatigueMatrix(this.actor.data.data.sante.fatigue.value, this.actor.data.data.sante.endurance.max).html() + "</table>"; fatigueItem.innerHTML = "<table class='table-fatigue'>" + RdDUtility.makeHTMLfatigueMatrix(this.actor.data.data.sante.fatigue.value, this.actor.data.data.sante.endurance.max).html() + "</table>";
} }

View File

@ -265,6 +265,20 @@ export class TMRUtility {
return TMRMapping[coordTMR]; 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 ) static async rencontreTMRRoll( coordTMR, cellDescr )
{ {
@ -275,10 +289,12 @@ export class TMRUtility {
rencontre.force = this.evaluerForceRencontre(rencontre); rencontre.force = this.evaluerForceRencontre(rencontre);
rencontre.coord = coordTMR; rencontre.coord = coordTMR;
} }
if ( this.forceRencontre ) {
// Forced // Forced
//rencontre = rencontresTable[0]; rencontre = rencontresTable[this.forceRencontre.id];
//rencontre.force = 2; rencontre.force = this.forceRencontre.force;
//rencontre.coord = coordTMR; rencontre.coord = coordTMR;
}
return rencontre; return rencontre;
} }

View File

@ -340,7 +340,7 @@
.rdddialog { .rdddialog {
width: 600px; width: 600px;
height: 430px; height: 430px;
z-index: 100; z-index: 99999;
} }
.table-resolution-carac { .table-resolution-carac {

View File

@ -1,10 +1,9 @@
<form class="dialog-roll-sort"> <form class="dialog-roll-sort">
<h2 class="compdialog" id="sort-dialog"></h2> <h2 class="compdialog" id="sort-dialog"></h2>
<div class="form-group"> <div class="form-group">
<label for="categorie">Rêve : {{selectedCarac.value}} <label for="categorie">Rêve : {{selectedCarac.value}}</label>
</div> <label for="categorie">TMR : {{coord}} - {{coordLabel}}</label>
<div class="form-group">
<label for="categorie">TMR : {{coord}} - {{coordLabel}}
</div> </div>
<div class="form-group"> <div class="form-group">

View File

@ -12,20 +12,20 @@
<label>Carac. Rêve : </label><label>{{caracReve}}</label> <label>Carac. Rêve : </label><label>{{caracReve}}</label>
</div> </div>
<div class="flex-group-center"> <div class="flex-group-center">
Rêve Actuel : <span id="pointsreve-value">0</span> <label>Rêve Actuel : </label><span id="tmr-pointsreve-value">0</span>
</div> </div>
<div class="flex-group-center"> <div class="flex-group-center">
Coordonnées : <span id="tmr-pos">0</span> <label>Coordonnées : </label><span id="tmr-pos">0</span>
</div> </div>
<div class="flex-group-center"> <div class="flex-group-center">
Etat général : <span id="etatgeneral-value">0</span> <label>Etat général : </label><span id="tmr-etatgeneral-value">0</span>
</div> </div>
<div class="flex-group-center"> <div class="flex-group-center">
Refoulement : <span id="refoulement-value">0</span> <label>Refoulement : </label><span id="tmr-refoulement-value">0</span>
</div> </div>
<div class="flex-group-center flex-actions-bar"> <div class="flex-group-center flex-actions-bar">
Fatigue Fatigue
<span id="fatigue-table">{{{fatigue.html}}}</span> <span id="tmr-fatigue-table">{{{fatigue.html}}}</span>
</div> </div>
</td> </td>
</tr> </tr>