This commit is contained in:
2020-11-21 18:16:18 +01:00
parent f4a88fd29c
commit 391af4bd3c
6 changed files with 59 additions and 57 deletions

View File

@ -127,8 +127,11 @@ export class RdDTMRDialog extends Dialog {
await this.actor.updatePointsDeReve( -value );
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, value );
await this.actor.update({ "data.reve.tmrpos": tmrPos });
console.log("NEWPOS", tmrPos);
}
/* -------------------------------------------- */
@ -150,10 +153,10 @@ export class RdDTMRDialog extends Dialog {
this.nbFatigue += 1;
} else if ( this.rencontreState == 'tourbillonblanc' ) {
this.gererTourbillon(1);
await this.gererTourbillon(1);
} else if ( this.rencontreState == 'tourbillonnoir' ) {
this.gererTourbillon(2);
await this.gererTourbillon(2);
} else {
this.currentRencontre = undefined; // Cleanup, not used anymore

View File

@ -243,14 +243,14 @@ const rencontresTable = [
/* -------------------------------------------- */
const tmrMovePattern =
[ { name: 'top', x: 'zero', y: 'dec' },
{ name: 'topright', x: 'inc', y: 'dec' },
{ name: 'left', x: 'inc', y: 'alt' },
{ name: 'botright', x: 'inc', y: 'inc' },
{ name: 'bot', x: 'zero', y: 'inc' },
{ name: 'botleft', x: 'dec', y: 'inc' },
{ name: 'left', x: 'dec', y: 'alt' },
{ name: 'topleft', x: 'dec', y: 'dec' }
[ { name: 'top', x: 0, y: -1 },
{ name: 'topright', x: 1, y: -1 },
{ name: 'left', x: 1, y: 'alt' },
{ name: 'botright', x: 1, y: 1 },
{ name: 'bot', x: 0, y: 1 },
{ name: 'botleft', x: -1, y: 1 },
{ name: 'left', x: -1, y: 'alt' },
{ name: 'topleft', x: -1, y: -1 }
]
/* -------------------------------------------- */
@ -298,6 +298,26 @@ export class TMRUtility {
return tmrMovePattern[index];
}
/* -------------------------------------------- */
static deplaceTMRSelonPattern( pos, pattern, nTime ) {
for (let i=0; i <nTime; i++) {
let currentPosXY = TMRUtility.convertToCellCoord(pos);
currentPosXY.x = currentPosXY.x + pattern.x;
if (pattern.y == 'alt' ) { // Alternate version
pattern.y += (pattern.x % 2 == 0 ) ? -1 : 1;
} else {
currentPosXY.y = currentPosXY.y + pattern.y;
}
if ( this._checkTMRCoord(currentPosXY.x, currentPosXY.y) ) { // Sortie de carte ! Ré-insertion aléatoire
pos = TMRUtility.convertToTMRCoord(currentPosXY.x, currentPosXY.y);
} else {
pos = this.getTMRAleatoire();
}
console.log("Nouvelle case iteration !!!", i, pos);
}
return pos;
}
/* -------------------------------------------- */
static async rencontreTMRRoll( coordTMR, cellDescr )
{
@ -365,12 +385,6 @@ export class TMRUtility {
return false;
}
/* -------------------------------------------- */
static getRandomLocationType( coordTMR ) {
let descr = this.getTMRDescription( coordTMR );
// TODO random get same type
}
/* -------------------------------------------- */
static getLocationTypeList( coordTMR ) {
let descr = this.getTMRDescription( coordTMR );