#80 Gestion de la queue Mauvaise Rencontre en Perspective

This commit is contained in:
2020-12-30 15:18:58 +01:00
parent 5c423d1245
commit aea1bca24a
3 changed files with 77 additions and 21 deletions

View File

@ -100,9 +100,9 @@ export class RdDTMRDialog extends Dialog {
}
/* -------------------------------------------- */
async refouler(data) {
this._tellToGM(this.actor.name + " a refoulé une rencontre.");
this._tellToGM(this.actor.name + " a refoulé : " + this.currentRencontre.name );
await this.actor.deleteTMRRencontreAtPosition(); // Remove the stored rencontre if necessary
let result = await this.actor.ajouterRefoulement(1);
let result = await this.actor.ajouterRefoulement( this.currentRencontre.data.refoulement );
this.updatePreviousRencontres();
console.log("-> refouler", this.currentRencontre)
this.updateValuesDisplay();
@ -139,6 +139,20 @@ export class RdDTMRDialog extends Dialog {
console.log("NEWPOS", tmrPos);
}
/* -------------------------------------------- */
async gererTourbillonRouge( ) {
this.nbFatigue += 4; // 4 cases -> 4 pts de fatigue
await this.actor.reveActuelIncDec( -2 ); // -2 pts de Reve a chaque itération
if ( !this.currentRencontre.tourbillonDirection ) {
this.currentRencontre.tourbillonDirection = TMRUtility.getDirectionPattern();
}
let tmrPos = this.actor.data.data.reve.tmrpos;
tmrPos.coord = TMRUtility.deplaceTMRSelonPattern( tmrPos.coord, this.currentRencontre.tourbillonDirection, 4 ); // Depl. 4 cases.
await this.actor.update({ "data.reve.tmrpos": tmrPos });
await this.actor.santeIncDec( "vie", -1); // Et -1 PV
console.log("TOURBILLON ROUGE", tmrPos);
}
/* -------------------------------------------- */
/** Gère les rencontres avec du post-processing graphique (passeur, messagers, tourbillons, ...) */
async rencontrePostProcess( rencontreData) {
@ -149,6 +163,17 @@ export class RdDTMRDialog extends Dialog {
if ( this.rencontreState == 'passeur' || this.rencontreState == 'messager' ) {
// Récupère la liste des cases à portées
locList = TMRUtility.getTMRArea(this.actor.data.data.reve.tmrpos.coord, this.currentRencontre.force, tmrConstants );
} else if ( this.rencontreState == 'passeurfou' ) { // Cas spécial du passeur fou
let sortReserve = this.actor.data.data.reve.reserve[0];
let tmrPos
if ( sortReserve ) {
tmrPos = sortReserve.coord; // Passeur fou positionne sur la case d'un ort en réserve (TODO : Choisir le plus loin)
} else {
let direction = TMRUtility.getDirectionPattern(); // Déplacement aléatoire de la force du Passeur Fou
tmrPos = TMRUtility.deplaceTMRSelonPattern(this.actor.data.data.reve.tmrpos.coord, direction, this.currentRencontre.force );
}
await this.actor.update({ "data.reve.tmrpos": tmrPos });
} else if ( this.rencontreState == 'changeur' ) {
// Liste des cases de même type
@ -163,6 +188,9 @@ export class RdDTMRDialog extends Dialog {
} else if ( this.rencontreState == 'tourbillonnoir' ) {
await this.gererTourbillon(2);
} else if ( this.rencontreState == 'tourbillonrouge' ) {
await this.gererTourbillonRouge();
} else {
this.currentRencontre = undefined; // Cleanup, not used anymore
}
@ -194,7 +222,6 @@ 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 + etatGeneral;
console.log("Maitriser", carac, draconic.data.niveau, this.currentRencontre.force, etatGeneral);
@ -252,30 +279,20 @@ export class RdDTMRDialog extends Dialog {
this.currentRencontre = duplicate(rencontre);
let dialog = new RdDTMRRencontreDialog("", this, this.currentRencontre);
/*
let dialog = new Dialog({
title: "Rencontre en TMR!",
content: "Vous recontrez un " + rencontre.name + " de force " + rencontre.force + "<br>",
buttons: {
derober: { icon: '<i class="fas fa-check"></i>', label: "Se dérober", callback: () => this.derober() },
refouler: { icon: '<i class="fas fa-check"></i>', label: "Refouler", callback: () => this.refouler() },
maitiser: { icon: '<i class="fas fa-check"></i>', label: "Maîtriser", callback: () => this.maitriser() }
},
default: "derober"
});*/
dialog.render(true);
}
}
/* -------------------------------------------- */
async _jetDeRencontre(coordTMR, cellDescr) {
let rencontre = this.rencontresExistantes.find(prev => prev.coord == coordTMR);
if (rencontre == undefined) {
let myRoll = new Roll("1d7").roll();
if (myRoll.total == 7) {
rencontre = await TMRUtility.rencontreTMRRoll(coordTMR, cellDescr);
}
else {
let isSpecial = this.actor.isRencontreSpeciale();
rencontre = await TMRUtility.rencontreTMRRoll(coordTMR, cellDescr, isSpecial );
} else {
this._tellToUser(myRoll.total + ": Pas de rencontre en " + cellDescr.label + " (" + coordTMR + ")");
}
}