#27 Gestion des rencontres

This commit is contained in:
2020-11-21 08:27:28 +01:00
parent 42a5078bba
commit 2d1509aadd
4 changed files with 52 additions and 27 deletions

View File

@ -123,23 +123,44 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */
/** Gère les rencontres avec du post-processing graphique (passeur, messagers, tourbillons, ...) */
rencontrePostProcess( rencontreData) {
async rencontrePostProcess( rencontreData) {
if (!rencontreData) return; // Sanity check
this.rencontreState = rencontreData.state; // garder la trace de l'état en cours
if ( this.rencontreState == 'passeur') {
console.log("Processing passeur");
let locList
if ( this.rencontreState == 'passeur' || this.rencontreState == 'messager' ) {
// Récupère la liste des cases à portées
let locList = TMRUtility.getTMRArea(this.actor.data.data.reve.tmrpos.coord, this.currentRencontre.force, tmrConstants );
this.colorierZoneRencontre( locList );
} else if ( this.rencontreState == 'messager') {
console.log("Processing messager");
// Récupère la liste des cases à portées
let locList = TMRUtility.getTMRArea(this.actor.data.data.reve.tmrpos.coord, this.currentRencontre.force, tmrConstants );
this.colorierZoneRencontre( locList );
locList = TMRUtility.getTMRArea(this.actor.data.data.reve.tmrpos.coord, this.currentRencontre.force, tmrConstants );
} else if ( this.rencontreState == 'changeur' ) {
// Liste des cases de même type
locList = TMRUtility.getLocationTypeList( this.actor.data.data.reve.tmrpos.coord );
} else if ( this.rencontreState == 'reflet' ) {
this.nbFatigue += 1;
} else {
this.currentRencontre = undefined; // Cleanup, not used anymore
}
if ( locList )
this.colorierZoneRencontre( locList );
}
/* -------------------------------------------- */
checkQuitterTMR() {
if ( this.actor.data.data.reve.reve.value == 0) {
ChateMessage.create( { content: "Vos Points de Rêve sont à 0 : vous quittez les Terres médianes !"} );
this.close();
}
if ( this.nbFatigue == this.actor.data.data.sante.fatigue.max ) {
ChateMessage.create({ content: "Vous vous écroulez de fatigue : vous quittez les Terres médianes !"});
this.close();
}
if ( this.actor.data.data.sante.vie.value == 0 ) {
ChateMessage.create({ content: "Vous n'avez plus de Points de Vie : vous quittez les Terres médianes !"});
this.close();
}
}
/* -------------------------------------------- */
@ -150,9 +171,9 @@ export class RdDTMRDialog extends Dialog {
const draconic = this.actor.getBestDraconic();
const carac = this.actor.getReveActuel();
// TODO: ajouter l'état général?
const etatGeneral = this.actor.data.data.compteurs.etat.value
const difficulte = draconic.data.niveau - this.currentRencontre.force;
console.log("Maitriser", carac, draconic.data.niveau, this.currentRencontre.force);
const etatGeneral = this.actor.data.data.compteurs.etat.value;
const difficulte = draconic.data.niveau - this.currentRencontre.force + etatGeneral;
console.log("Maitriser", carac, draconic.data.niveau, this.currentRencontre.force, etatGeneral);
let rolled = RdDResolutionTable.roll(carac, difficulte);
let message = "<br><strong>Test : Rêve actuel / " + draconic.name + " / " + this.currentRencontre.name + "</strong>" + "<br>"
@ -172,10 +193,14 @@ export class RdDTMRDialog extends Dialog {
this._tellToUser("Vous avez <strong>réussi</strong> à maîtriser un " + this.currentRencontre.name + " de force " + this.currentRencontre.force + message);
}
this.rencontrePostProcess( rencontreData );
await this.rencontrePostProcess( rencontreData );
console.log("-> matriser", this.currentRencontre);
this.updateValuesDisplay();
this.checkQuitterTMR();
if ( this.rencontreState == 'reflet')
this.maitriser();
}
/* -------------------------------------------- */
@ -247,6 +272,7 @@ export class RdDTMRDialog extends Dialog {
refoulement.innerHTML = this.actor.data.data.reve.refoulement.value;
let fatigueItem = document.getElementById("tmr-fatigue-table");
console.log("Refresh : ", this.actor.data.data.sante.fatigue.value);
fatigueItem.innerHTML = "<table class='table-fatigue'>" + RdDUtility.makeHTMLfatigueMatrix(this.actor.data.data.sante.fatigue.value, this.actor.data.data.sante.endurance.max).html() + "</table>";
}
@ -338,13 +364,13 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */
processClickPostRencontre( coord ) {
let deplacementType = "erreur";
if (this.rencontreState == 'passeur' || this.rencontreState == 'messager') {
if (this.rencontreState == 'passeur' || this.rencontreState == 'messager' || this.rencontreState == 'changeur') {
console.log("Searching", this.currentRencontre.locList, coord);
let isInArea = this.currentRencontre.locList.find(locCoord => locCoord == coord );
if ( isInArea ) { // OK !
deplacementType = (this.rencontreState == 'messager') ? 'messager' : 'saut';
}
}
}
return deplacementType;
}
@ -401,6 +427,8 @@ export class RdDTMRDialog extends Dialog {
ui.notifications.error("Vous ne pouvez vous déplacer que sur des cases adjacentes à votre position ou valides dans le cas d'une rencontre");
console.log("STATUS :", myself.rencontreState, myself.currentRencontre);
}
this.checkQuitterTMR(); // Vérifier l'état des compteurs reve/fatigue/vie
}
/* -------------------------------------------- */