parent
bddad92f5c
commit
d3e48d6e5b
@ -1,10 +1,4 @@
|
||||
export class RdDDice {
|
||||
static async deRencontre() {
|
||||
let roll = this.show(new Roll("1d7").evaluate());
|
||||
// let roll = this.show(new Roll("1d8r8").evaluate());
|
||||
// roll.total = roll.total % 8;
|
||||
return roll;
|
||||
}
|
||||
|
||||
static async deDraconique() {
|
||||
let roll = new Roll("1d8x8").evaluate();
|
||||
|
@ -111,16 +111,15 @@ export class RdDTMRDialog extends Dialog {
|
||||
|
||||
let rolled = RdDResolutionTable.roll(carac, difficulte);
|
||||
let message = "<br><strong>Test : Rêve actuel / " + draconic.name + " / " + this.currentRencontre.name + "</strong>" + "<br>"
|
||||
+ "<br>Jet : " + carac + " / " + difficulte + " -> " + rolled.score + "%<br><strong>Résutat : </strong>" + rolled.roll;
|
||||
|
||||
+ RdDResolutionTable.explain(rolled);
|
||||
|
||||
if (rolled.isEchec) {
|
||||
TMRUtility.processRencontreEchec(this.actor, this.currentRencontre);
|
||||
TMRUtility.processRencontreEchec(this.actor, this.currentRencontre, rolled);
|
||||
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);;
|
||||
+ "<br>Vous quittez brutalement les Terres Médianes !" + message);
|
||||
this.close();
|
||||
} else {
|
||||
TMRUtility.processRencontreReussite(this.actor, this.currentRencontre);
|
||||
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);
|
||||
}
|
||||
console.log("-> matriser", this.currentRencontre);
|
||||
@ -142,7 +141,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
console.log("manageRencontre", deRencontre, rencontre);
|
||||
if (rencontre == undefined) {
|
||||
if (deRencontre.total == 7) {
|
||||
rencontre = TMRUtility.rencontreTMRRoll(coordTMR, cellDescr);
|
||||
rencontre = await TMRUtility.rencontreTMRRoll(coordTMR, cellDescr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
import { TMRUtility } from "./tmr-utility.js";
|
||||
import { RdDRollTables } from "./rdd-rolltables.js";
|
||||
import { RdDResolutionTable } from "./rdd-resolution-table.js";
|
||||
|
||||
const level_category = {
|
||||
"generale": "-4",
|
||||
|
@ -1,3 +1,5 @@
|
||||
import { RdDDice } from "./rdd-dice.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
const TMRMapping = {
|
||||
A1: { type: "cite", label: "Cité Vide"},
|
||||
@ -233,7 +235,7 @@ const rencontresTable = [
|
||||
{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,
|
||||
{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",
|
||||
lac: "98-00", marais: "98-00", gouffre: "98-00", necropole: "98-00", desolation: "98-00" } }
|
||||
]
|
||||
@ -264,32 +266,80 @@ export class TMRUtility {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static rencontreTMRRoll( coordTMR, cellDescr )
|
||||
static async rencontreTMRRoll( coordTMR, cellDescr )
|
||||
{
|
||||
let val = new Roll("d100").roll().total;
|
||||
//console.log("Rencontre !!!!", val, coordTMR, cellDescr);
|
||||
let rencontre = this.rencontreTMRTypeCase(cellDescr.type);
|
||||
if (rencontre){
|
||||
rencontre = duplicate(rencontre);
|
||||
rencontre.force = await this.evaluerForceRencontre(rencontre);
|
||||
rencontre.coord = coordTMR;
|
||||
}
|
||||
return rencontre;
|
||||
}
|
||||
|
||||
static rencontreTMRTypeCase(typeTMR, roll=undefined) {
|
||||
if (!roll)
|
||||
{
|
||||
roll = new Roll("d100").roll().total;
|
||||
}
|
||||
typeTMR = typeTMR.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
||||
for( let rencontre of rencontresTable) {
|
||||
let scoreDef = rencontre.data[cellDescr.type];
|
||||
let scoreDef = rencontre.data[typeTMR];
|
||||
let min = scoreDef.substr(0,2);
|
||||
let max = scoreDef.substr(3,2);
|
||||
//console.log(val, scoreDef, min, max);
|
||||
if ( val >= min && val <= max) {
|
||||
rencontre.force = new Roll(rencontre.data.force).roll().total;
|
||||
rencontre.coord = coordTMR
|
||||
if (max=="00") max = 100;
|
||||
if (roll >= min && roll <= max) {
|
||||
return rencontre;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/**
|
||||
* Retourne une recontre en fonction de la case et du tirage
|
||||
* @param {*} caseName
|
||||
* @param {*} roll
|
||||
*/
|
||||
static async getRencontre( caseName, roll ) {
|
||||
if (!roll) {
|
||||
roll = new Roll("1d100").roll().total;
|
||||
}
|
||||
if ( !caseName) {
|
||||
ChatMessage.create({ content: "Un nom de case doit être indiqué (ie /tmrr desert ou /tmrr cite)" });
|
||||
return false;
|
||||
}
|
||||
|
||||
let rencontre = this.rencontreTMRTypeCase(caseName, roll);
|
||||
if (rencontre){
|
||||
let force = await this.evaluerForceRencontre(rencontre);
|
||||
ChatMessage.create({ content: "Rencontre en " + caseName + "(jet : " + roll + "%)<br>Vous rencontrez un " + rencontre.name + " d'une force de " + force + " Points de Rêve" });
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getRandomLocationType( coordTMR ) {
|
||||
let descr = this.getTMRDescription( coordTMR );
|
||||
// TODO random get same type
|
||||
}
|
||||
|
||||
static async evaluerForceRencontre(rencontre) {
|
||||
if (this.isReveDeDragon(rencontre)) {
|
||||
let ddr = await RdDDice.deDraconique();
|
||||
return ddr + 7;
|
||||
}
|
||||
else {
|
||||
const roll = new Roll(rencontre.data.force).evaluate();
|
||||
return roll.total;
|
||||
}
|
||||
}
|
||||
|
||||
static isReveDeDragon(rencontre) {
|
||||
return rencontre.name.toLowerCase() == "Rêve de Dragon".toLowerCase();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async processRencontreReussite( actor, rencontre ) {
|
||||
static async processRencontreReussite( actor, rencontre, rolled ) {
|
||||
let msg = "Vous avez réussi votre maîtrise ! ";
|
||||
console.log("processRencontreReussite", actor, rencontre);
|
||||
if (rencontre.name == "Messagers des Rêves") {
|
||||
@ -321,13 +371,13 @@ export class TMRUtility {
|
||||
msg += "Ce Tourbillon Noir disparait !"
|
||||
|
||||
} else if (rencontre.name == "Rêve de Dragon") {
|
||||
msg += "Un Rêve de Dragon survient !"
|
||||
|
||||
msg += "Vous maîtrisez le Rêve de Dragon !"
|
||||
msg += actor.appliquerReveDeDragon(rolled, rencontre.force);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async processRencontreEchec( actor, rencontre ) {
|
||||
static async processRencontreEchec( actor, rencontre, rolled ) {
|
||||
let msg = "Vous avez échoué à votre maîtrise ! ";
|
||||
|
||||
if (rencontre.name == "Messagers des Rêves") {
|
||||
@ -342,7 +392,6 @@ export class TMRUtility {
|
||||
} 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);
|
||||
@ -361,7 +410,8 @@ export class TMRUtility {
|
||||
msg += "Votre Rêve est Brisé, vous quittez les Terres Médianes";
|
||||
|
||||
} else if (rencontre.name == "Rêve de Dragon") {
|
||||
|
||||
msg += "Le Rêve de Dragon tourne au cauchemar !"
|
||||
msg += actor.appliquerReveDeDragon(rolled, rencontre.force);
|
||||
}
|
||||
}
|
||||
|
||||
@ -377,36 +427,6 @@ export class TMRUtility {
|
||||
return result;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/**
|
||||
* Retourne une recontre en fonction de la case ou du tirage
|
||||
* @param {*} caseName
|
||||
* @param {*} roll
|
||||
*/
|
||||
static getRencontre( caseName, roll ) {
|
||||
if (!roll) {
|
||||
roll = new Roll("1d100").roll().total;
|
||||
}
|
||||
if ( !caseName) {
|
||||
ChatMessage.create({ content: "Un nom de case doit être indiqué (ie /tmrr desert ou /tmrr cite)" });
|
||||
return false;
|
||||
}
|
||||
caseName = caseName.toLowerCase();
|
||||
caseName = caseName.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
||||
//console.log("Case : ", caseName);
|
||||
for( let renc of rencontresTable) {
|
||||
let scoreDef = renc.data[caseName];
|
||||
let min = scoreDef.substr(0,2);
|
||||
let max = scoreDef.substr(3,2);
|
||||
if ( roll >= min && roll <= max) {
|
||||
let force = new Roll(renc.data.force).roll().total;
|
||||
ChatMessage.create({ content: "Rencontre en " + caseName + "(jet : " + roll + "%)<br>Vous rencontrez un " + renc.name + " d'une force de " + force + " Points de Rêve" });
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/**
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user