#27 - Gestion du Changeur de Rêve

This commit is contained in:
sladecraven 2020-11-18 18:11:01 +01:00
parent a5adacc5b9
commit 8ec2a43cf3
3 changed files with 51 additions and 33 deletions

View File

@ -116,10 +116,11 @@ export class RdDTMRDialog extends Dialog {
+ RdDResolutionTable.explain(rolled);
if (rolled.isEchec) {
message += await TMRUtility.processRencontreEchec(this.actor, this.currentRencontre, rolled);
message += await TMRUtility.processRencontreEchec(this.actor, this.currentRencontre, rolled, this);
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);
this.close();
if (this.currentRencontre.data.quitterTMR) // Selon les rencontres, quitter TMR ou pas
this.close();
} else {
message += await TMRUtility.processRencontreReussite(this.actor, this.currentRencontre, rolled);
this._tellToUser("Vous avez <strong>réussi</strong> à maîtriser un " + this.currentRencontre.name + " de force " + this.currentRencontre.force + message);
@ -141,13 +142,15 @@ export class RdDTMRDialog extends Dialog {
this.currentRencontre = undefined;
let rencontre = this.rencontresExistantes.find(prev => prev.coord == coordTMR);
if (rencontre == undefined) {
let deRencontre = new Roll("d7").roll();
if (deRencontre.total == 7) {
let myRoll = new Roll("d7").roll();
if (myRoll.total == 7) {
rencontre = await TMRUtility.rencontreTMRRoll(coordTMR, cellDescr);
}
}
//rencontre = await TMRUtility.rencontreTMRRoll(coordTMR, cellDescr); To test
if (rencontre) { // Manages it
if (rencontre.rencontre) rencontre = rencontre.rencontre; // Manage stored rencontres
console.log("manageRencontre", rencontre)
this.currentRencontre = duplicate(rencontre);
@ -304,8 +307,12 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */
async forceDemiRevePosition( coordTMR ) {
await actor.updateCoordTMR(coordTMR);
await this.actor.updateCoordTMR(coordTMR);
this._updateDemiReve(this);
let cellDescr = TMRUtility.getTMRDescription(coordTMR);
this.manageRencontre(coordTMR, cellDescr);
this.manageCaseHumide(cellDescr);
await this.declencheSortEnReserve(coordTMR);
}
/* -------------------------------------------- */

View File

@ -56,7 +56,7 @@ const TMRMapping = {
J4: { type: "collines", label: "Collines dEncre"},
K4: { type: "pont", label: "Pont de Fah"},
L4: { type: "sanctuaire", label: "Sanctuaire Mauve"},
M4: { type: "gouffre ", label: "Gouffre Grisant"},
M4: { type: "gouffre", label: "Gouffre Grisant"},
A5: { type: "plaines", label: "Plaines de Trilkh"},
B5: { type: "collines", label: "Collines de Tanegy"},
@ -208,35 +208,35 @@ const TMRMapping = {
}
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",
{name:"Messagers des Rêves", data: { force: "2d4", ignorer: true, derober: true, refoulement: 1, quitterTMR: true,
cite: "01-25", sanctuaire: "01-25", plaines: "01-20", pont: "01-20", collines: "01-15", foret: "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",
{name:"Passeur des Rêves", data: { force: "2d4", ignorer: true, derober: true, refoulement: 1, quitterTMR: true,
cite: "26-50", sanctuaire: "26-50", plaines: "21-40", pont: "21-40", collines: "16-30", foret: "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",
{name:"Fleur des Rêves", data: { force: "1d6", ignorer: true, derober: true, refoulement: 1, quitterTMR: true,
cite: "51-65", sanctuaire: "51-65", plaines: "41-55", pont: "41-55", collines: "31-42", foret: "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",
{name:"Mangeur de Rêve", data: { force: "1d6", ignorer: false, derober: true, refoulement: 1, quitterTMR: true,
cite: "66-70", sanctuaire: "66-70", plaines: "56-60", pont: "56-60", collines: "43-54", foret: "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",
{name:"Changeur de Rêve", data: { force: "2d6", ignorer: false, derober: true, refoulement: 1, quitterTMR: false,
cite: "71-80", sanctuaire: "71-80", plaines: "61-75", pont: "61-75", collines: "55-69", foret: "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",
{name:"Briseur de Rêve", data: { force: "2d6", ignorer: false, derober: true, refoulement: 1, quitterTMR: true,
cite: "81-85", sanctuaire: "81-85", plaines: "76-82", pont: "76-82", collines: "70-82", foret: "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",
{name:"Reflet d'ancien Rêve", data: { force: "2d6", ignorer: false, derober: true, refoulement: 1,quitterTMR: true,
cite: "86-90", sanctuaire: "86-90", plaines: "83-88", pont: "83-88", collines: "83-88", foret: "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",
{name:"Tourbillon blanc", data: { force: "2d6", ignorer: false, derober: true, refoulement: 1, quitterTMR: true,
cite: "91-94", sanctuaire: "91-94", plaines: "89-93", pont: "89-93", collines: "89-93", foret: "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",
{name:"Tourbillon noir", data: { force: "2d8", ignorer: false, derober: true, refoulement: 1, quitterTMR: true,
cite: "95-97", sanctuaire: "95-97", plaines: "94-97", pont: "94-97", collines: "94-97", foret: "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: "1ddr + 7", 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",
{name:"Rêve de Dragon", data: { force: "1ddr + 7", ignorer: false, derober: true, refoulement: 2, quitterTMR: true,
cite: "98-00", sanctuaire: "98-00", plaines: "98-00", pont: "98-00", collines: "98-00", foret: "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" } }
]
@ -275,6 +275,11 @@ export class TMRUtility {
rencontre.force = this.evaluerForceRencontre(rencontre);
rencontre.coord = coordTMR;
}
// Forced
//rencontre = rencontresTable[4];
//rencontre.force = 11;
//rencontre.coord = coordTMR;
return rencontre;
}
@ -287,6 +292,7 @@ export class TMRUtility {
}
typeTMR = typeTMR.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "");
for( let rencontre of rencontresTable) {
console.log("TMR !!!", typeTMR, roll);
let scoreDef = rencontre.data[typeTMR];
let min = scoreDef.substr(0,2);
let max = scoreDef.substr(3,2);
@ -374,12 +380,13 @@ export class TMRUtility {
msg += "Ce Mangeur des Rêves disparait !"
} else if (rencontre.name == "Changeur de Rêve") {
msg += "Ce Changeur des Rêves vous propose de vous déplacer sur une autre case de même type."
msg += "Ce Changeur des Rêves vous propose de vous déplacer sur une autre case de même type.<ol>"
let locList = this.getLocationTypeList( actor.data.data.reve.tmrpos.coord );
for ( let coord of locList) {
let caseTMR = TMRMapping[coord];
msg += "<li class='tmr-passeur-coord'><a data-actor-id='"+actor.data._id+"' data-tmr-coord='"+coord+"'>"+coord+" - " +caseTMR.label+"</a></li>";
}
msg += "</ol>"
} else if (rencontre.name == "Briseur de Rêve") {
msg += "Ce Briseur des Rêves disparait !"
@ -402,7 +409,7 @@ export class TMRUtility {
}
/* -------------------------------------------- */
static async processRencontreEchec( actor, rencontre, rolled ) {
static async processRencontreEchec( actor, rencontre, rolled, tmrDialog ) {
let msg = "<br>";
if (rencontre.name == "Messagers des Rêves") {
@ -419,9 +426,13 @@ export class TMRUtility {
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 " + coordTMR + " - " + coordTMR.label;
msg += "Ce Changeur des Rêves vous déplace sur un autre case du même type.<br>"
let locList = this.getLocationTypeList( actor.data.data.reve.tmrpos.coord );
let index = new Roll("1d"+locList.length + " - 1").roll().total;
let newCoord = locList[index];
tmrDialog.forceDemiRevePosition(newCoord);
let cellDescr = TMRUtility.getTMRDescription(newCoord);
msg += "Vous avez été téléporté en " + newCoord + " - " + cellDescr.label;
} else if (rencontre.name == "Briseur de Rêve") {
msg += "Votre Rêve est Brisé, vous quittez les Terres Médianes";

View File

@ -2,7 +2,7 @@
"name": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon",
"description": "Rêve de Dragon RPG for FoundryVTT",
"version": "0.9.61",
"version": "0.9.62",
"minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.6",
"templateVersion": 47,