#27 Gestion des rencontres
This commit is contained in:
parent
90799b09c6
commit
a59db9a22d
@ -945,6 +945,7 @@ export class RdDActor extends Actor {
|
||||
selectedDraconic: this.getBestDraconic(),
|
||||
selectedSort: sortList[0],
|
||||
coord: coord,
|
||||
coordLabel: TMRUtility.getTMRDescription( coord).label,
|
||||
finalLevel: 0,
|
||||
diffConditions: 0,
|
||||
diffLibre: sortList[0].data.difficulte, // Per default at startup
|
||||
|
@ -25,8 +25,8 @@ 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 }
|
||||
|
||||
let dialogOptions = { classes: ["rdddialog"], width: 600, height: 400, 'z-index': 30 }
|
||||
|
||||
// Select proper roll dialog template and stuff
|
||||
if (mode == "competence") {
|
||||
dialogConf.title = "Test de compétence"
|
||||
|
@ -46,7 +46,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
this.rencontresExistantes = duplicate(this.actor.data.data.reve.rencontre.list);
|
||||
this.sortReserves = duplicate(this.actor.data.data.reve.reserve.list);
|
||||
this.allTokens = [];
|
||||
this.rencontreState = "aucune";
|
||||
this.rencontreState = 'aucune';
|
||||
this.pixiApp = new PIXI.Application({ width: 720, height: 860 });
|
||||
}
|
||||
|
||||
@ -101,10 +101,11 @@ export class RdDTMRDialog extends Dialog {
|
||||
this.updatePreviousRencontres();
|
||||
console.log("-> refouler", this.currentRencontre)
|
||||
this.updateValuesDisplay();
|
||||
this.nettoyerRencontre();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
colorierZone( locList) {
|
||||
colorierZoneRencontre( locList) {
|
||||
this.currentRencontre.graphics = []; // Keep track of rectangles to delete it
|
||||
this.currentRencontre.locList = duplicate(locList); // And track of allowed location
|
||||
for (let loc of locList) {
|
||||
@ -125,16 +126,17 @@ export class RdDTMRDialog extends Dialog {
|
||||
rencontrePostProcess( rencontreData) {
|
||||
if (!rencontreData) return; // Sanity check
|
||||
this.rencontreState = rencontreData.state; // garder la trace de l'état en cours
|
||||
if ( this.rencontreState == "passeur") {
|
||||
|
||||
if ( this.rencontreState == 'passeur') {
|
||||
console.log("Processing passeur");
|
||||
// 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.colorierZone( locList );
|
||||
} else if ( this.rencontreState == "messager") {
|
||||
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.colorierZone( locList );
|
||||
this.colorierZoneRencontre( locList );
|
||||
} else {
|
||||
this.currentRencontre = undefined; // Cleanup, not used anymore
|
||||
}
|
||||
@ -161,7 +163,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
rencontreData = await TMRUtility.processRencontreEchec(this.actor, this.currentRencontre, rolled, this);
|
||||
message += rencontreData.message;
|
||||
this._tellToUser("Vous avez <strong>échoué</strong> à maîtriser un " + this.currentRencontre.name + " de force " + this.currentRencontre.force
|
||||
+ "<br>Vous quittez brutalement les Terres Médianes !" + message);
|
||||
+ message);
|
||||
if (this.currentRencontre.data.quitterTMR) // Selon les rencontres, quitter TMR ou pas
|
||||
this.close();
|
||||
} else {
|
||||
@ -199,7 +201,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
rencontre = await TMRUtility.rencontreTMRRoll(coordTMR, cellDescr);
|
||||
}
|
||||
}
|
||||
rencontre = await TMRUtility.rencontreTMRRoll(coordTMR, cellDescr);
|
||||
//rencontre = await TMRUtility.rencontreTMRRoll(coordTMR, cellDescr);
|
||||
|
||||
if (rencontre) { // Manages it
|
||||
if (rencontre.rencontre) rencontre = rencontre.rencontre; // Manage stored rencontres
|
||||
@ -321,17 +323,29 @@ export class RdDTMRDialog extends Dialog {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
nettoyerRencontre( ) {
|
||||
if ( !this.currentRencontre) return; // Sanity check
|
||||
if ( this.currentRencontre.graphics) {
|
||||
for (let drawRect of this.currentRencontre.graphics) { // Suppression des dessins des zones possibles
|
||||
this.pixiApp.stage.removeChild( drawRect );
|
||||
}
|
||||
}
|
||||
this.currentRencontre = undefined; // Nettoyage de la structure
|
||||
this.rencontreState = 'aucune'; // Et de l'état
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
processClickPostRencontre( coord ) {
|
||||
let deplacementType = "erreur";
|
||||
if (this.rencontreState == "passeur" || this.rencontreState == "messager") {
|
||||
if (this.rencontreState == 'passeur' || this.rencontreState == 'messager') {
|
||||
console.log("Searching", this.currentRencontre.locList, coord);
|
||||
let isInArea = this.currentRencontre.locList.find(locCoord => locCoord == coord );
|
||||
if ( isInArea ) { // OK !
|
||||
deplacementType = "saut";
|
||||
|
||||
}
|
||||
|
||||
deplacementType = (this.rencontreState == 'messager') ? 'messager' : 'saut';
|
||||
}
|
||||
}
|
||||
return deplacementType;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -347,19 +361,21 @@ export class RdDTMRDialog extends Dialog {
|
||||
let celly = eventCoord.celly;
|
||||
console.log("deplacerDemiReve >>>>", cellx, celly);
|
||||
let currentPos = TMRUtility.convertToCellCoord(myself.actor.data.data.reve.tmrpos.coord);
|
||||
let coordTMR = TMRUtility.convertToTMRCoord(cellx, celly);
|
||||
|
||||
// Validation de la case de destination (gestion du cas des rencontres qui peuvent téléporter)
|
||||
let deplacementType = "erreur";
|
||||
if ( this.rencontreState == "aucune") { // Pas de recontre en post-processing, donc deplacement normal
|
||||
if ( !RdDTMRDialog._horsDePortee(currentPos, cellx, celly)) {
|
||||
deplacementType = "normal";
|
||||
let deplacementType = 'erreur';
|
||||
if ( myself.rencontreState == 'aucune') { // Pas de recontre en post-processing, donc deplacement normal
|
||||
if ( !RdDTMRDialog._horsDePortee(currentPos, cellx, celly) ) {
|
||||
deplacementType = 'normal';
|
||||
}
|
||||
} else {
|
||||
deplacementType = this.processClickPostRencontre( currentPos );
|
||||
deplacementType = myself.processClickPostRencontre( coordTMR );
|
||||
}
|
||||
// Si le deplacement est valide
|
||||
if ( deplacementType == "normal" || deplacementType == "saut") {
|
||||
let coordTMR = TMRUtility.convertToTMRCoord(cellx, celly);
|
||||
if ( deplacementType == 'normal' || deplacementType == 'saut') {
|
||||
if ( myself.currentRencontre != 'normal' )
|
||||
myself.nettoyerRencontre();
|
||||
let cellDescr = TMRUtility.getTMRDescription(coordTMR);
|
||||
|
||||
console.log("deplacerDemiReve: TMR column is", coordTMR, cellx, celly, cellDescr, this);
|
||||
@ -371,13 +387,19 @@ export class RdDTMRDialog extends Dialog {
|
||||
myself.nbFatigue += 1;
|
||||
myself.updateValuesDisplay();
|
||||
|
||||
if ( deplacementType == "normal") { // Pas de rencontres après un saut de type passeur/changeur/...
|
||||
if ( deplacementType == 'normal') { // Pas de rencontres après un saut de type passeur/changeur/...
|
||||
myself.manageRencontre(coordTMR, cellDescr);
|
||||
}
|
||||
myself.manageCaseHumide(cellDescr);
|
||||
await myself.declencheSortEnReserve(coordTMR);
|
||||
|
||||
} else if (deplacementType == 'messager') { // Dans ce cas, ouverture du lancement de sort sur la case visée
|
||||
myself.actor.rollUnSort( coordTMR );
|
||||
myself.nettoyerRencontre();
|
||||
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -276,9 +276,9 @@ export class TMRUtility {
|
||||
rencontre.coord = coordTMR;
|
||||
}
|
||||
// Forced
|
||||
rencontre = rencontresTable[0];
|
||||
rencontre.force = 1;
|
||||
rencontre.coord = coordTMR;
|
||||
//rencontre = rencontresTable[0];
|
||||
//rencontre.force = 2;
|
||||
//rencontre.coord = coordTMR;
|
||||
|
||||
return rencontre;
|
||||
}
|
||||
|
@ -340,6 +340,7 @@
|
||||
.rdddialog {
|
||||
width: 600px;
|
||||
height: 430px;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.table-resolution-carac {
|
||||
|
@ -3,6 +3,9 @@
|
||||
<div class="form-group">
|
||||
<label for="categorie">Rêve : {{selectedCarac.value}}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="categorie">TMR : {{coord}} - {{coordLabel}}
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="categorie">Draconic </label>
|
||||
|
Loading…
Reference in New Issue
Block a user