forked from public/foundryvtt-reve-de-dragon
#27 Gestion des rencontres
This commit is contained in:
@ -240,23 +240,9 @@ const rencontresTable = [
|
||||
lac: "98-00", marais: "98-00", gouffre: "98-00", necropole: "98-00", desolation: "98-00" } }
|
||||
]
|
||||
|
||||
/* -------------------------------------------- */
|
||||
const tmrConstants = {
|
||||
col1_y: 30,
|
||||
col2_y: 55,
|
||||
cellw: 55,
|
||||
cellh: 55,
|
||||
gridx: 28,
|
||||
gridy: 28
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class TMRUtility {
|
||||
|
||||
static getTMRConstants() {
|
||||
return tmrConstants;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static convertToTMRCoord( x, y )
|
||||
{
|
||||
@ -290,9 +276,9 @@ export class TMRUtility {
|
||||
rencontre.coord = coordTMR;
|
||||
}
|
||||
// Forced
|
||||
//rencontre = rencontresTable[4];
|
||||
//rencontre.force = 11;
|
||||
//rencontre.coord = coordTMR;
|
||||
rencontre = rencontresTable[0];
|
||||
rencontre.force = 1;
|
||||
rencontre.coord = coordTMR;
|
||||
|
||||
return rencontre;
|
||||
}
|
||||
@ -379,13 +365,17 @@ export class TMRUtility {
|
||||
/* -------------------------------------------- */
|
||||
static async processRencontreReussite( actor, rencontre, rolled ) {
|
||||
let msg = "<br>";
|
||||
let state = "aucune";
|
||||
|
||||
console.log("processRencontreReussite", actor, rencontre);
|
||||
if (rencontre.name == "Messagers des Rêves") {
|
||||
msg += "Le Messager des Rêves vous permet de lancer votre sort à XX cases !";
|
||||
state = "messager";
|
||||
|
||||
} else if (rencontre.name == "Passeur des Rêves") {
|
||||
msg += "Le Passeur des Rêves vous téléporte sur une case à XX !";
|
||||
|
||||
msg += "Le Passeur des Rêves vous permet de vous téléporter à " + rencontre.force + " cases !";
|
||||
state = "passeur";
|
||||
|
||||
} else if (rencontre.name == "Fleur des Rêves") {
|
||||
await actor.updatePointsDeReve( rencontre.force );
|
||||
msg += "La Fleur des rêves s'évanouit en vous fournissant " + rencontre.force + " Points de Rêve";
|
||||
@ -419,13 +409,14 @@ export class TMRUtility {
|
||||
msg += "Vous maîtrisez le Rêve de Dragon !"
|
||||
msg += actor.appliquerReveDeDragon(rolled, rencontre.force);
|
||||
}
|
||||
return msg;
|
||||
return { msg: msg, state: state };
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async processRencontreEchec( actor, rencontre, rolled, tmrDialog ) {
|
||||
let msg = "<br>";
|
||||
|
||||
let state = "aucune";
|
||||
|
||||
if (rencontre.name == "Messagers des Rêves") {
|
||||
msg += "Le Messager des Rêves s'éloigne de vous !";
|
||||
|
||||
@ -453,18 +444,21 @@ export class TMRUtility {
|
||||
|
||||
} else if (rencontre.name == "Reflet d'ancien Rêve") {
|
||||
msg += "Votre Rêve est Brisé, vous quittez les Terres Médianes";
|
||||
|
||||
state = "reflet"
|
||||
|
||||
} else if (rencontre.name == "Tourbillon blanc") {
|
||||
msg += "Votre Rêve est Brisé, vous quittez les Terres Médianes";
|
||||
|
||||
state = "tourbillonblanc";
|
||||
|
||||
} else if (rencontre.name == "Tourbillon noir") {
|
||||
msg += "Votre Rêve est Brisé, vous quittez les Terres Médianes";
|
||||
state = "tourbillonnoir";
|
||||
|
||||
} else if (rencontre.name == "Rêve de Dragon") {
|
||||
msg += "Le Rêve de Dragon tourne au cauchemar !"
|
||||
msg += actor.appliquerReveDeDragon(rolled, rencontre.force);
|
||||
}
|
||||
return msg;
|
||||
return { msg: msg, state: state };
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -502,7 +496,7 @@ export class TMRUtility {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static computeRealPictureCoordinates( coordXY ) {
|
||||
static computeRealPictureCoordinates( coordXY, tmrConstants ) {
|
||||
let decallagePairImpair = (coordXY.x % 2 == 0) ? tmrConstants.col1_y : tmrConstants.col2_y;
|
||||
return {
|
||||
x: tmrConstants.gridx + (coordXY.x * tmrConstants.cellw),
|
||||
@ -514,15 +508,15 @@ export class TMRUtility {
|
||||
/** Returns a list of case inside a given distance
|
||||
*
|
||||
*/
|
||||
static getTMRArea( coord, distance ) {
|
||||
static getTMRArea( coord, distance, tmrConstants ) {
|
||||
let pos = this.convertToCellCoord( coord );
|
||||
let posPic = this.computeRealPictureCoordinates( pos );
|
||||
let posPic = this.computeRealPictureCoordinates( pos, tmrConstants );
|
||||
let caseList = [];
|
||||
for (let x=pos.x-distance; x<=pos.x+distance; x++ ) { // Loop thru lines
|
||||
for (let y=pos.y-distance; y<=pos.y+distance; y++ ) { // Loop thru lines
|
||||
//console.log("Parsing position", x, y);
|
||||
if ( this._checkTMRCoord(x, y) ) { // Coordinate is valie
|
||||
let posPicNow = this.computeRealPictureCoordinates( {x: x, y: y} );
|
||||
let posPicNow = this.computeRealPictureCoordinates( {x: x, y: y}, tmrConstants );
|
||||
let dist = Math.sqrt(Math.pow(posPicNow.x - posPic.x,2) + Math.pow(posPicNow.y - posPic.y, 2)) / tmrConstants.cellw;
|
||||
if ( dist < distance+0.5) {
|
||||
caseList.push( this.convertToTMRCoord(x, y) ); // Inside the area
|
||||
|
Reference in New Issue
Block a user