foundryvtt-reve-de-dragon/module/tmr-utility.js

154 lines
9.2 KiB
JavaScript
Raw Normal View History

2020-07-17 22:04:35 +02:00
/* -------------------------------------------- */
const TMRMapping = { A1: { type: "cite", label: "Cité VIDE"}, B1: { type:"plaines", label: "Plaines d'ASSORH"}, C1: { type:"necropole", label: "Nécropole de KROAK"}, D1: { type: "fleuve", label: "Fleuve de l'Oubli"}, E1: { type: "monts", label: "Monts de KANAI"},
F1: { type: "cite", label: "Cité GLAUQUE"}, G1: { type: "desolation", label: "Désolation de JAMAIS"}, H1: {type: "lac", label: "Lac d'ANTI-CALME"}, I1: { type: "plaines", label: "Plaines GRISES"}, J1: { type: "monts", label: "Monts FAINEANTS"},
K1: { type: "cite", label: "Cité d'ONKAUS"}, L1: { type: "fleuve", label: "Fleuve de l'Oubli"}, M1: { type: "cite", label: "Cité JALOUSE"},
A2: { type: "desert", label: "Désert de MIEUX"}, B2: { type:"collines", label: "Collines de DAWELL"}, C2: { type:"monts", label: "Monts GLIGNANTS"}, D2: { type: "cite", label: "Cité de FROST"}, E2: { type: "plaines", label: "Plaines de FIASK"},
F2: { type: "lac", label: "Lac de MISERE"}, G2: { type: "marais", label: "Marais NUISANTS"}, H2: {type: "collines", label: "Collines de PARTA"}, I2: { type: "foret", label: "Forêt FADE"}, J2: { type: "desert", label: "Désert de POLY"},
K2: { type: "foret", label: "Forêt TAMEE"}, L2: { type: "fleuve", label: "Fleuve de l'Oubli"}, M2: { type: "necropole", label: "Nécropole de LOGOS"}
}
const rencontresTable = [
{name:"Messagers des Rêves", data: { force: "2d4", ignorer: true, derober: true, refoulement: 1,
cite: "01-25", sanctuaire: "01-25", plaines: "01-20", pont: "01-20", collines: "01-15", forêt: "01-15", monts: "01-10", desert: "01-10", fleuve: "01-05",
lac: "01-05", marais: "01-02", gouffre: "01-02", necropole: "00-00", desolation: "00-00" } },
{name:"Passeur des Rêves", data: { force: "2d4", ignorer: true, derober: true, refoulement: 1,
cite: "26-50", sanctuaire: "26-50", plaines: "21-40", pont: "21-40", collines: "16-30", forêt: "16-30", monts: "11-20", desert: "11-20", fleuve: "06-10",
lac: "06-10", marais: "03-04", gouffre: "03-04", necropole: "00-00", desolation: "00-00" } },
{name:"Fleur des Rêves", data: { force: "1d6", ignorer: true, derober: true, refoulement: 1,
cite: "51-65", sanctuaire: "51-65", plaines: "41-55", pont: "41-55", collines: "31-42", forêt: "31-42", monts: "21-26", desert: "21-26", fleuve: "11-13",
lac: "11-13", marais: "05-05", gouffre: "05-05", necropole: "00-00", desolation: "00-00" } },
{name:"Mangeur de Rêve", data: { force: "1d6", ignorer: false, derober: true, refoulement: 1,
cite: "66-70", sanctuaire: "66-70", plaines: "56-60", pont: "56-60", collines: "43-54", forêt: "43-54", monts: "27-44", desert: "27-44", fleuve: "14-37",
lac: "14-37", marais: "06-29", gouffre: "06-29", necropole: "01-20", desolation: "01-20" } },
{name:"Changeur de Rêve", data: { force: "2d6", ignorer: false, derober: true, refoulement: 1,
cite: "71-80", sanctuaire: "71-80", plaines: "61-75", pont: "61-75", collines: "55-69", forêt: "55-69", monts: "45-59", desert: "45-59", fleuve: "38-49",
lac: "38-49", marais: "30-39", gouffre: "30-39", necropole: "21-30", desolation: "21-30" } },
{name:"Briseur de Rêve", data: { force: "2d6", ignorer: false, derober: true, refoulement: 1,
cite: "81-85", sanctuaire: "81-85", plaines: "76-82", pont: "76-82", collines: "70-82", forêt: "70-82", monts: "60-75", desert: "60-75", fleuve: "50-65",
lac: "50-65", marais: "40-60", gouffre: "40-60", necropole: "31-50", desolation: "31-50" } },
{name:"Reflet d'ancien Rêve", data: { force: "2d6", ignorer: false, derober: true, refoulement: 1,
cite: "86-90", sanctuaire: "86-90", plaines: "83-88", pont: "83-88", collines: "83-88", forêt: "83-88", monts: "76-85", desert: "76-85", fleuve: "66-79",
lac: "66-79", marais: "61-75", gouffre: "61-75", necropole: "51-65", desolation: "51-65" } },
{name:"Tourbillon blanc", data: { force: "2d6", ignorer: false, derober: true, refoulement: 1,
cite: "91-94", sanctuaire: "91-94", plaines: "89-93", pont: "89-93", collines: "89-93", forêt: "89-93", monts: "86-92", desert: "86-92", fleuve: "80-89",
lac: "80-89", marais: "76-86", gouffre: "76-86", necropole: "66-80", desolation: "66-80" } },
{name:"Tourbillon noir", data: { force: "2d8", ignorer: false, derober: true, refoulement: 1,
cite: "95-97", sanctuaire: "95-97", plaines: "94-97", pont: "94-97", collines: "94-97", forêt: "94-97", monts: "93-97", desert: "93-97", fleuve: "90-97",
lac: "90-97", marais: "87-97", gouffre: "90-97", necropole: "81-97", desolation: "81-97" } },
{name:"Rêve de Dragon", data: { force: "1d7", ignorer: false, derober: true, refoulement: 2,
cite: "98-00", sanctuaire: "98-00", plaines: "98-00", pont: "98-00", collines: "98-00", forêt: "98-00", monts: "98-00", desert: "98-00", fleuve: "98-00",
lac: "98-00", marais: "98-00", gouffre: "98-00", necropole: "98-00", desolation: "98-00" } }
]
/* -------------------------------------------- */
export class TMRUtility {
/* -------------------------------------------- */
static convertToTMRCoord( x, y )
{
y = y + 1
let letterX = String.fromCharCode(65+x);
return letterX+y
}
/* -------------------------------------------- */
static convertToCellCoord( coordTMR )
{
let x = coordTMR.charCodeAt(0) - 65;
let y = coordTMR.substr(1) - 1;
return {x: x, y: y}
}
/* -------------------------------------------- */
static getTMRDescription( coordTMR)
{
return TMRMapping[coordTMR];
}
/* -------------------------------------------- */
static rencontreTMRRoll( coordTMR, cellDescr )
{
let myroll = new Roll("d100");
myroll.roll();
let val = myroll.total;
//console.log("Rencontre !!!!", val, coordTMR, cellDescr);
for( let renc of rencontresTable) {
let scoreDef = renc.data[cellDescr.type];
let min = scoreDef.substr(0,2);
let max = scoreDef.substr(3,2);
//console.log(val, scoreDef, min, max);
if ( val >= min && val <= max) {
return renc;
}
}
}
/* -------------------------------------------- */
static getRandomLocationType( coordTMR ) {
let descr = this.getTMRDescription( coordTMR );
// TODO random get same type
}
/* -------------------------------------------- */
static processRencontreReussite( actor, rencontre ) {
}
/* -------------------------------------------- */
static async processRencontreEchec( actor, rencontre ) {
let msg = "Vous avez échoué à votre maîtrise ! ";
if (rencontre.name == "Messagers des Rêves") {
msg += "Le Messager des Rêves s'éloigne de vous !";
} else if (rencontre.name == "Passeur des Rêves") {
msg += "Le Passeur des Rêves s'éloigne de vous !";
} else if (rencontre.name == "Fleur des Rêves") {
msg += "La Fleur des rêves s'éloigne de vous et se perd dans les Terres Médianes";
} else if (rencontre.name == "Mangeur de Rêve") {
await actor.updatePointsDeReve( -rencontre.force );
msg += "Ce Mangeur des Rêves croque votre Rêve ! Vous perdez " + rencontre.force + " points de rêve actuels, votre nouveau total est de " + actor.data.data.reve.reve.value;
} else if (rencontre.name == "Changeur de Rêve") {
let coordTMR = actor.data.data.reve.tmrpos.coord;
let newcoordTMR = this.getRandomLocationType(coordTMR);
msg += "Vous avez été téléporté en "; // TODO
} else if (rencontre.name == "Briseur de Rêve") {
msg += "Votre Rêve est Brisé, vous quittez les Terres Médianes";
} else if (rencontre.name == "Reflet d'ancien Rêve") {
msg += "Votre Rêve est Brisé, vous quittez les Terres Médianes";
} else if (rencontre.name == "Tourbillon blanc") {
msg += "Votre Rêve est Brisé, vous quittez les Terres Médianes";
} else if (rencontre.name == "Tourbillon noir") {
msg += "Votre Rêve est Brisé, vous quittez les Terres Médianes";
} else if (rencontre.name == "Rêve de Dragon") {
}
}
/* -------------------------------------------- */
static getSouffle( ) {
}
/* -------------------------------------------- */
static getQueue( ) {
}
/* -------------------------------------------- */
static getTete( ) {
}
/* -------------------------------------------- */
static getOmbre( ) {
}
}