Foundry: Roll#evaluate sera async
This commit is contained in:
parent
d1ac4b3d59
commit
f87efee2fe
133
module/actor.js
133
module/actor.js
@ -651,8 +651,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
}
|
||||
else {
|
||||
const roll = new Roll("1dr").evaluate();
|
||||
let deRecuperation = roll.total;
|
||||
let deRecuperation = await RdDDice.rollTotal("1dr");
|
||||
console.log("recuperationReve", deRecuperation);
|
||||
if (deRecuperation >= 7) {
|
||||
// Rêve de Dragon !
|
||||
@ -744,7 +743,7 @@ export class RdDActor extends Actor {
|
||||
// TODO: un dialogue pour demander le type de tête?
|
||||
rollData.tete = true;
|
||||
}
|
||||
rollData.poesie = Poetique.getExtrait();
|
||||
rollData.poesie = await Poetique.getExtrait();
|
||||
|
||||
ChatMessage.create({
|
||||
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
|
||||
@ -1191,7 +1190,7 @@ export class RdDActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
async ajouterRefoulement(value = 1) {
|
||||
let refoulement = Misc.templateData(this).reve.refoulement.value + value;
|
||||
let total = new Roll("1d20").evaluate({ async: false }).total;
|
||||
let total = await RdDDice.rollTotal("1d20");
|
||||
if (total <= refoulement) {
|
||||
refoulement = 0;
|
||||
await this.ajouterSouffle({ chat: true });
|
||||
@ -1273,7 +1272,7 @@ export class RdDActor extends Actor {
|
||||
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name)
|
||||
});
|
||||
const innaccessible = this.buildTMRInnaccessible();
|
||||
let tmr = TMRUtility.getTMRAleatoire(tmr => !innaccessible.includes(tmr.coord));
|
||||
let tmr = await TMRUtility.getTMRAleatoire(tmr => !innaccessible.includes(tmr.coord));
|
||||
this.updateCoordTMR(tmr.coord);
|
||||
this.cacheTMR();
|
||||
return tmr;
|
||||
@ -1402,25 +1401,6 @@ export class RdDActor extends Actor {
|
||||
return RdDCarac.calculSConst(Misc.templateData(this).carac.constitution.value);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async testSiSonne(sante, endurance) {
|
||||
const roll = new Roll("1d20").evaluate();
|
||||
roll.showDice = true;
|
||||
RdDDice.show(roll);
|
||||
let result = {
|
||||
roll: roll,
|
||||
sonne: roll.total > endurance || roll.total == 20 // 20 is always a failure
|
||||
}
|
||||
if (roll.total == 1) {
|
||||
await this.ajoutXpConstitution(1); // +1 XP !
|
||||
ChatMessage.create({ content: `${this.name} a obenu 1 sur son Jet d'Endurance et a gagné 1 point d'Expérience en Constitution. Ce point d'XP a été ajouté automatiquement).` });
|
||||
}
|
||||
if (result.sonne) {
|
||||
await this.setSonne();
|
||||
sante.sonne.value = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
async ajoutXpConstitution(xp) {
|
||||
await this.update({ "data.carac.constitution.xp": Misc.toInt(Misc.templateData(this).carac.constitution.xp) + xp });
|
||||
@ -1435,48 +1415,71 @@ export class RdDActor extends Actor {
|
||||
return this.countBlessures(Misc.templateData(this).blessures[name].liste);
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async testSiSonne(sante, endurance) {
|
||||
const result = await this._jetEndurance(endurance);
|
||||
if (result.roll.total == 1) {
|
||||
ChatMessage.create({ content: await this._gainXpConstitutionJetEndurance() });
|
||||
}
|
||||
sante.sonne.value ||= result.sonne;
|
||||
return result;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async jetEndurance() {
|
||||
let myRoll = new Roll("1d20").roll();
|
||||
myRoll.showDice = true;
|
||||
await RdDDice.show(myRoll);
|
||||
|
||||
const actorData = Misc.data(this);
|
||||
let msgText = "Jet d'Endurance : " + myRoll.total + " / " + actorData.data.sante.endurance.value + "<br>";
|
||||
if (myRoll.total == 1 || (myRoll.total != 20 && myRoll.total <= actorData.data.sante.endurance.value)) {
|
||||
msgText += `${this.name} a réussi son Jet d'Endurance !`;
|
||||
if (myRoll.total == 1) {
|
||||
await this.ajoutXpConstitution();
|
||||
msgText += `et gagne 1 Point d'Experience en Constitution`;
|
||||
}
|
||||
} else {
|
||||
await this.setSonne();
|
||||
msgText += `${this.name} a échoué son Jet d'Endurance et devient Sonné`;
|
||||
}
|
||||
const endurance = actorData.data.sante.endurance.value;
|
||||
|
||||
const result = await this._jetEndurance(actorData.data.sante.endurance.value)
|
||||
const message = {
|
||||
content: msgText,
|
||||
content: "Jet d'Endurance : " + result.roll.total + " / " + endurance + "<br>",
|
||||
whisper: ChatMessage.getWhisperRecipients(game.user.name)
|
||||
};
|
||||
if (result.sonne) {
|
||||
message.content += `${this.name} a échoué son Jet d'Endurance et devient Sonné`;
|
||||
}
|
||||
else if (result.roll.total == 1) {
|
||||
message.content += await this._gainXpConstitutionJetEndurance();
|
||||
}
|
||||
else {
|
||||
message.content += `${this.name} a réussi son Jet d'Endurance !`;
|
||||
}
|
||||
|
||||
ChatMessage.create(message);
|
||||
}
|
||||
|
||||
async _gainXpConstitutionJetEndurance() {
|
||||
await this.ajoutXpConstitution(1); // +1 XP !
|
||||
return `${this.name} a obtenu 1 sur son Jet d'Endurance et a gagné 1 point d'Expérience en Constitution. Ce point d'XP a été ajouté automatiquement.`;
|
||||
}
|
||||
|
||||
async _jetEndurance(endurance) {
|
||||
const roll = await RdDDice.roll("1d20", { showDice: true });
|
||||
let result = {
|
||||
roll: roll,
|
||||
sonne: roll.total > endurance || roll.total == 20 // 20 is always a failure
|
||||
}
|
||||
if (result.sonne) {
|
||||
await this.setSonne();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async jetVie() {
|
||||
let myRoll = new Roll("1d20").roll();
|
||||
myRoll.showDice = true;
|
||||
await RdDDice.show(myRoll);
|
||||
|
||||
let roll = await RdDDice.roll("1d20", { showDice: true });
|
||||
const actorData = Misc.data(this);
|
||||
let msgText = "Jet de Vie : " + myRoll.total + " / " + actorData.data.sante.vie.value + "<br>";
|
||||
if (myRoll.total <= actorData.data.sante.vie.value) {
|
||||
let msgText = "Jet de Vie : " + roll.total + " / " + actorData.data.sante.vie.value + "<br>";
|
||||
if (roll.total <= actorData.data.sante.vie.value) {
|
||||
msgText += "Jet réussi, pas de perte de point de vie (prochain jet dans 1 round pour 1 critique, SC minutes pour une grave)";
|
||||
if (myRoll.total == 1) {
|
||||
if (roll.total == 1) {
|
||||
msgText += "La durée entre 2 jets de vie est multipliée par 20 (20 rounds pour une critique, SCx20 minutes pour une grave)";
|
||||
}
|
||||
} else {
|
||||
msgText += "Jet échoué, vous perdez 1 point de vie";
|
||||
await this.santeIncDec("vie", -1);
|
||||
if (myRoll.total == 20) {
|
||||
if (roll.total == 20) {
|
||||
msgText += "Votre personnage est mort !!!!!";
|
||||
}
|
||||
}
|
||||
@ -1589,8 +1592,7 @@ export class RdDActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async jetDeMoral(situation, messageReussi = undefined, messageManque = undefined) {
|
||||
let jetMoral = new Roll("1d20").roll();
|
||||
RdDDice.show(jetMoral);
|
||||
let jetMoral = await RdDDice.roll("1d20", { showDice: true });
|
||||
let moralActuel = Misc.toInt(Misc.templateData(this).compteurs.moral.value);
|
||||
const difficulte = 10 + moralActuel;
|
||||
const succes = jetMoral.total <= difficulte;
|
||||
@ -1694,7 +1696,7 @@ export class RdDActor extends Actor {
|
||||
RdDResolutionTable.displayRollData(jetVieView, this, 'chat-resultat-ethylisme.html');
|
||||
|
||||
if (rollEthylisme.isEchec) {
|
||||
let enduranceLostRoll = new Roll("1d6").roll();
|
||||
let enduranceLostRoll = await RdDDice.roll("1d6");
|
||||
// enduranceLostRoll.showDice = true;
|
||||
RdDDice.show(enduranceLostRoll);
|
||||
let enduranceLost = enduranceLostRoll.total;
|
||||
@ -2973,14 +2975,14 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
computeArmure(attackerRoll) {
|
||||
async computeArmure(attackerRoll) {
|
||||
let dmg = (attackerRoll.dmg.dmgArme ?? 0) + (attackerRoll.dmg.dmgActor ?? 0);
|
||||
let armeData = attackerRoll.arme;
|
||||
let protection = 0;
|
||||
const armures = this.items.map(it => Misc.data(it))
|
||||
.filter(it => it.type == "armure" && it.data.equipe);
|
||||
for (const itemData of armures) {
|
||||
protection += new Roll(itemData.data.protection.toString()).roll().total;
|
||||
protection += await RdDDice.rollTotal(itemData.data.protection.toString());
|
||||
if (dmg > 0) {
|
||||
this._deteriorerArmure(itemData, dmg);
|
||||
dmg = 0;
|
||||
@ -3041,7 +3043,7 @@ export class RdDActor extends Actor {
|
||||
console.log("encaisserDommages", rollData)
|
||||
|
||||
let santeOrig = duplicate(Misc.templateData(this).sante);
|
||||
let encaissement = this.jetEncaissement(rollData);
|
||||
let encaissement = await this.jetEncaissement(rollData);
|
||||
|
||||
this.ajouterBlessure(encaissement); // Will upate the result table
|
||||
const perteVie = this.isEntiteCauchemar()
|
||||
@ -3080,29 +3082,34 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
jetEncaissement(rollData) {
|
||||
const roll = new Roll("2d10").roll();
|
||||
roll.showDice = true;
|
||||
RdDDice.show(roll, game.settings.get("core", "rollMode"));
|
||||
async jetEncaissement(rollData) {
|
||||
const roll = await RdDDice.roll("2d10", { showDice: true });
|
||||
|
||||
const armure = this.computeArmure(rollData);
|
||||
const armure = await this.computeArmure(rollData);
|
||||
const jetTotal = roll.total + rollData.dmg.total - armure;
|
||||
|
||||
let encaissement = RdDUtility.selectEncaissement(jetTotal, rollData.dmg.mortalite)
|
||||
let over20 = Math.max(jetTotal - 20, 0);
|
||||
encaissement.dmg = rollData.dmg;
|
||||
encaissement.dmg.loc = rollData.dmg.loc ?? RdDUtility.getLocalisation(this.data.type);
|
||||
encaissement.dmg.loc = rollData.dmg.loc ?? await RdDUtility.getLocalisation(this.data.type);
|
||||
encaissement.dmg.loc.label = encaissement.dmg.loc.label ?? 'Corps;'
|
||||
encaissement.roll = roll;
|
||||
encaissement.armure = armure;
|
||||
encaissement.total = jetTotal;
|
||||
encaissement.vie = RdDUtility._evaluatePerte(encaissement.vie, over20);
|
||||
encaissement.endurance = RdDUtility._evaluatePerte(encaissement.endurance, over20);
|
||||
encaissement.vie = await RdDActor._evaluatePerte(encaissement.vie, over20);
|
||||
encaissement.endurance = await RdDActor._evaluatePerte(encaissement.endurance, over20);
|
||||
encaissement.penetration = rollData.arme?.data.penetration ?? 0;
|
||||
|
||||
return encaissement;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async _evaluatePerte(formula, over20) {
|
||||
let perte = new Roll(formula, { over20: over20 });
|
||||
await perte.evaluate({ async: true });
|
||||
return perte.total;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
ajouterBlessure(encaissement) {
|
||||
const actorData = Misc.data(this);
|
||||
@ -3684,7 +3691,7 @@ export class RdDActor extends Actor {
|
||||
potionData.reussiteReve = true;
|
||||
potionData.aphasiePermanente = false;
|
||||
if (potionData.data.reposalchimique) {
|
||||
let chanceAphasie = new Roll("1d100").evaluate({ async: false }).total;
|
||||
let chanceAphasie = await RdDDice.rollTotal("1d100");
|
||||
if (chanceAphasie <= potionData.data.pr) {
|
||||
potionData.aphasiePermanente = true;
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { Misc } from "./misc.js";
|
||||
import { RdDDice } from "./rdd-dice.js";
|
||||
import { RdDRollTables } from "./rdd-rolltables.js";
|
||||
import { TMRType } from "./tmr-utility.js";
|
||||
|
||||
@ -68,7 +69,7 @@ export class RdDItemSigneDraconique {
|
||||
}
|
||||
|
||||
static async randomSigneDraconique() {
|
||||
let modele = await Misc.rollOneOf(tableSignesIndicatifs);
|
||||
let modele = await RdDDice.rollOneOf(tableSignesIndicatifs);
|
||||
return {
|
||||
name: await RdDItemSigneDraconique.randomSigneDescription(),
|
||||
type: "signedraconique",
|
||||
@ -85,9 +86,9 @@ export class RdDItemSigneDraconique {
|
||||
|
||||
static async randomTmrs(nbTmr = undefined) {
|
||||
let tmrs = Object.values(TMRType).map(value => Misc.upperFirst(value.name));
|
||||
let keep = nbTmr ?? (await new Roll("1d" + TMRType.length).evaluate().total + 1);
|
||||
let keep = nbTmr ?? (await RdDDice.rollTotal("1d" + TMRType.length) + 1);
|
||||
for (let i = tmrs.length; i > keep; i--) {
|
||||
tmrs.splice(await new Roll("1d" + i).evaluate().total, 1);
|
||||
tmrs.splice(await RdDDice.rollTotal("1d" + i), 1);
|
||||
}
|
||||
return tmrs;
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { RdDDice } from "./rdd-dice.js";
|
||||
|
||||
/**
|
||||
* This class is intended as a placeholder for utility methods unrelated
|
||||
@ -92,10 +93,6 @@ export class Misc {
|
||||
}
|
||||
}
|
||||
|
||||
static rollOneOf(array) {
|
||||
return array[new Roll("1d" + array.length).evaluate({ async: false }).total - 1];
|
||||
}
|
||||
|
||||
static distinct(array) {
|
||||
return [...new Set(array)];
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { Misc } from "./misc.js"
|
||||
import { RdDDice } from "./rdd-dice.js";
|
||||
|
||||
const poesieHautReve = [
|
||||
{
|
||||
@ -64,8 +65,8 @@ const poesieHautReve = [
|
||||
]
|
||||
|
||||
export class Poetique {
|
||||
static getExtrait(){
|
||||
return Misc.rollOneOf(poesieHautReve);
|
||||
static async getExtrait(){
|
||||
return await RdDDice.rollOneOf(poesieHautReve);
|
||||
}
|
||||
|
||||
}
|
@ -5,6 +5,8 @@ import { HtmlUtility } from "./html-utility.js";
|
||||
import { RdDResolutionTable } from "./rdd-resolution-table.js";
|
||||
import { RdDUtility } from "./rdd-utility.js";
|
||||
import { Grammar } from "./grammar.js";
|
||||
import { Misc } from "./misc.js";
|
||||
import {RdDDice } from "./rdd-dice.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
const dossierIconesHeures = 'systems/foundryvtt-reve-de-dragon/icons/heures/'
|
||||
@ -124,9 +126,9 @@ export class RdDCalendrier extends Application {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
ajouterNombreAstral(index) {
|
||||
async ajouterNombreAstral(index) {
|
||||
return {
|
||||
nombreAstral: new Roll("1d12").evaluate( {async:false} ).total,
|
||||
nombreAstral: await RdDDice.rollTotal("1dh"),
|
||||
valeursFausses: [],
|
||||
index: index
|
||||
}
|
||||
@ -278,11 +280,10 @@ export class RdDCalendrier extends Application {
|
||||
request.isValid = true;
|
||||
if (!request.rolled.isSuccess) {
|
||||
request.isValid = false;
|
||||
let nbAstralFaux = new Roll("1d11").evaluate( { async: false} ).total;
|
||||
nbAstral = nbAstral==nbAstralFaux ? 12 : nbAstralFaux;
|
||||
nbAstral = await RdDDice.rollTotal("1dhr"+nbAstral);
|
||||
// Mise à jour des nombres astraux du joueur
|
||||
let astralData = this.listeNombreAstral.find((nombreAstral, i) => nombreAstral.index == request.date);
|
||||
astralData.valeursFausses.push({ actorId: request.id, nombreAstral: nbAstralFaux });
|
||||
astralData.valeursFausses.push({ actorId: request.id, nombreAstral: nbAstral });
|
||||
game.settings.set("foundryvtt-reve-de-dragon", "liste-nombre-astral", this.listeNombreAstral);
|
||||
}
|
||||
request.nbAstral = nbAstral;
|
||||
|
@ -283,16 +283,14 @@ export class RdDCommands {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollDeDraconique(msg) {
|
||||
let ddr = new Roll("1dr + 7").evaluate();
|
||||
ddr.showDice = true;
|
||||
await RdDDice.showDiceSoNice(ddr);
|
||||
RdDCommands._chatAnswer(msg, `Lancer d'un Dé draconique: ${ddr.total}`);
|
||||
let ddr = await RdDDice.rollTotal("1dr + 7", { showDice:true });
|
||||
RdDCommands._chatAnswer(msg, `Lancer d'un Dé draconique: ${ddr}`);
|
||||
}
|
||||
|
||||
getTMRAleatoire(msg, params) {
|
||||
async getTMRAleatoire(msg, params) {
|
||||
if (params.length < 2) {
|
||||
let type = params[0];
|
||||
const tmr = TMRUtility.getTMRAleatoire(type ? (it => it.type == type) : (it => true));
|
||||
const tmr = await TMRUtility.getTMRAleatoire(type ? (it => it.type == type) : (it => true));
|
||||
RdDCommands._chatAnswer(msg, `Case aléatoire: ${tmr.coord} - ${tmr.label}`);
|
||||
}
|
||||
else {
|
||||
|
@ -36,7 +36,7 @@ export class De7 extends Die {
|
||||
super(termData);
|
||||
}
|
||||
|
||||
evaluate() {
|
||||
async evaluate() {
|
||||
super.evaluate();
|
||||
this.explode("x=8");
|
||||
return this;
|
||||
@ -73,7 +73,7 @@ export class DeDraconique extends Die {
|
||||
super(termData);
|
||||
}
|
||||
|
||||
evaluate() {
|
||||
async evaluate() {
|
||||
super.evaluate();
|
||||
this.explode("x=7");
|
||||
return this;
|
||||
@ -124,6 +124,27 @@ export class RdDDice {
|
||||
CONFIG.Dice.terms[DeHeure.DENOMINATION] = DeHeure;
|
||||
}
|
||||
|
||||
static async roll(formula, options = { showDice: false }) {
|
||||
const roll = new Roll(formula);
|
||||
await roll.evaluate({ async: true });
|
||||
if (options.showDice) {
|
||||
roll.showDice = options.showDice;
|
||||
}
|
||||
await RdDDice.show(roll, game.settings.get("core", "rollMode"));
|
||||
return roll;
|
||||
}
|
||||
|
||||
static async rollTotal(formula) {
|
||||
const roll = new Roll(formula);
|
||||
await roll.evaluate({ async: true });
|
||||
return roll.total;
|
||||
}
|
||||
|
||||
static async rollOneOf(array) {
|
||||
const roll = await RdDDice.rollTotal(`1d${array.length}`);
|
||||
return array[roll-1];
|
||||
}
|
||||
|
||||
static diceSoNiceReady(dice3d) {
|
||||
for (const system of Object.keys(dice3d.DiceFactory.systems)) {
|
||||
dice3d.addDicePreset(De7.diceSoNiceData(system));
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Grammar } from "./grammar.js";
|
||||
import { Misc } from "./misc.js";
|
||||
import { RdDDice } from "./rdd-dice.js";
|
||||
|
||||
const words = [ 'pore', 'pre', 'flor', 'lane', 'turlu', 'pin', 'a', 'alph', 'i', 'onse', 'iane', 'ane', 'zach', 'arri', 'ba', 'bo', 'bi',
|
||||
'alta', 'par', 'pir', 'zor', 'zir', 'de', 'pol', 'tran', 'no', 'la','al' , 'pul', 'one', 'ner', 'nur' ];
|
||||
@ -7,8 +7,8 @@ const words = [ 'pore', 'pre', 'flor', 'lane', 'turlu', 'pin', 'a', 'alph', 'i',
|
||||
/* -------------------------------------------- */
|
||||
export class RdDNameGen {
|
||||
|
||||
static getName( msg, params ) {
|
||||
let name = Misc.upperFirst( Misc.rollOneOf(words) + Misc.rollOneOf(words) )
|
||||
static async getName( msg, params ) {
|
||||
let name = Misc.upperFirst( await RdDDice.rollOneOf(words) + await RdDDice.rollOneOf(words) )
|
||||
//console.log(name);
|
||||
ChatMessage.create( { content: `Nom : ${name}`, whisper: ChatMessage.getWhisperRecipients("GM") } );
|
||||
}
|
||||
|
@ -149,10 +149,7 @@ export class RdDResolutionTable {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async rollChances(chances, diviseur) {
|
||||
let myRoll = new Roll("1d100").evaluate( {async: false} );
|
||||
myRoll.showDice = chances.showDice;
|
||||
await RdDDice.show(myRoll);
|
||||
chances.roll = myRoll.total;
|
||||
chances.roll = await RdDDice.rollTotal("1d100", {showDice:chances.showDice});
|
||||
mergeObject(chances, this.computeReussite(chances, chances.roll, diviseur), { overwrite: true });
|
||||
return chances;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import { Draconique } from "./tmr/draconique.js";
|
||||
import { Misc } from "./misc.js";
|
||||
import { HtmlUtility } from "./html-utility.js";
|
||||
import { ReglesOptionelles } from "./regles-optionelles.js";
|
||||
import { RdDDice } from "./rdd-dice.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class RdDTMRDialog extends Dialog {
|
||||
@ -535,7 +536,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
if (rencontre) {
|
||||
return rencontre;
|
||||
}
|
||||
let myRoll = new Roll("1d7").evaluate({ async: false }).total;
|
||||
let myRoll = await RdDDice.rollTotal("1d7");
|
||||
if (TMRUtility.isForceRencontre() || myRoll == 7) {
|
||||
return await this.rencontreTMRRoll(tmr, this.actor.isRencontreSpeciale());
|
||||
}
|
||||
@ -596,7 +597,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
await this._rollMaitriseCaseHumide(rollData);
|
||||
return;
|
||||
}
|
||||
rollData.poesie = Poetique.getExtrait();
|
||||
rollData.poesie = await Poetique.getExtrait();
|
||||
ChatMessage.create({
|
||||
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
|
||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-resultat-maitrise-tmr.html`, rollData)
|
||||
@ -713,7 +714,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
}
|
||||
this.toclose = rollData.rolled.isEchec;
|
||||
|
||||
rollData.poesie = Poetique.getExtrait();
|
||||
rollData.poesie = await Poetique.getExtrait();
|
||||
ChatMessage.create({
|
||||
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
|
||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-resultat-maitrise-tmr.html`, rollData)
|
||||
|
@ -7,6 +7,7 @@ import { Grammar } from "./grammar.js";
|
||||
import { TMRUtility } from "./tmr-utility.js";
|
||||
import { DialogItemAchat } from "./dialog-item-achat.js";
|
||||
import { ReglesOptionelles } from "./regles-optionelles.js";
|
||||
import { RdDDice } from "./rdd-dice.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
// This table starts at 0 -> niveau -10
|
||||
@ -444,8 +445,8 @@ export class RdDUtility {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getLocalisation(type = 'personnage') {
|
||||
let result = new Roll("1d20").roll().total;
|
||||
static async getLocalisation(type = 'personnage') {
|
||||
let result = await RdDDice.rollTotal("1d20");
|
||||
let txt = ""
|
||||
if (type == 'personnage') {
|
||||
if (result <= 3) txt = "Jambe, genou, pied, jarret";
|
||||
@ -477,15 +478,6 @@ export class RdDUtility {
|
||||
return duplicate(table[0]);
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static _evaluatePerte(formula, over20) {
|
||||
console.log("_evaluatePerte", formula, over20);
|
||||
let perte = new Roll(formula, { over20: over20 });
|
||||
perte.evaluate();
|
||||
return perte.total;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static currentFatigueMalus(value, max) {
|
||||
if (ReglesOptionelles.isUsing("appliquer-fatigue")) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { Grammar } from "./grammar.js";
|
||||
import { Misc } from "./misc.js";
|
||||
import { RdDDice } from "./rdd-dice.js";
|
||||
import { TMRUtility } from "./tmr-utility.js";
|
||||
import { TMRType } from "./tmr-utility.js";
|
||||
|
||||
@ -268,7 +269,7 @@ const rencontresStandard = [
|
||||
{ code: "reflet", name: "Reflet d'ancien Rêve", type: "reflet", genre: "m", force: "2d6", isPersistant: true },
|
||||
{ code: "tbblanc", name: "Tourbillon blanc", type: "tbblanc", genre: "m", force: "2d6", isPersistant: true },
|
||||
{ code: "tbnoir", name: "Tourbillon noir", type: "tbnoir", genre: "m", force: "2d8", isPersistant: true },
|
||||
{ code: "rdd", name: "Rêve de Dragon", type: "rdd", genre: "m", force: "1ddr + 7", refoulement: 2, quitterTMR: true }
|
||||
{ code: "rdd", name: "Rêve de Dragon", type: "rdd", genre: "m", force: "1dr + 7", refoulement: 2, quitterTMR: true }
|
||||
];
|
||||
|
||||
const rencontresPresentCite = [
|
||||
@ -324,7 +325,7 @@ export class TMRRencontres {
|
||||
return false;
|
||||
}
|
||||
if (!roll || roll <= 0 || roll > 100) {
|
||||
roll = new Roll("1d100").evaluate().total;
|
||||
roll = await RdDDice.rollTotal("1d100");
|
||||
}
|
||||
let rencontre = await TMRRencontres.getRencontreAleatoire(terrain, roll);
|
||||
ChatMessage.create({
|
||||
@ -356,15 +357,13 @@ export class TMRRencontres {
|
||||
/* -------------------------------------------- */
|
||||
static async getRencontreAleatoire(terrain, roll = undefined) {
|
||||
if (!roll || roll <= 0 || roll > 100) {
|
||||
roll = new Roll("1d100").evaluate({ async: false }).total;
|
||||
roll = await RdDDice.rollTotal("1d100");
|
||||
}
|
||||
terrain = Grammar.toLowerCaseNoAccent(terrain);
|
||||
//console.log("getRencontreAleatoire", terrain, roll);
|
||||
const code = tableRencontres[terrain].find(it => it.range[0] <= roll && roll <= it.range[1]).code;
|
||||
const rencontre = duplicate(rencontresStandard.find(it => it.code == code));
|
||||
rencontre.roll = roll;
|
||||
await TMRRencontres.evaluerForceRencontre(rencontre);
|
||||
//console.log(rencontre);
|
||||
return rencontre;
|
||||
}
|
||||
|
||||
@ -373,20 +372,14 @@ export class TMRRencontres {
|
||||
const rencontre = duplicate(
|
||||
(index && index >= 0 && index < mauvaisesRencontres.length)
|
||||
? mauvaisesRencontres[index]
|
||||
: Misc.rollOneOf(mauvaisesRencontres));
|
||||
: await RdDDice.rollOneOf(mauvaisesRencontres));
|
||||
await TMRRencontres.evaluerForceRencontre(rencontre);
|
||||
return rencontre;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async evaluerForceRencontre(rencontre) {
|
||||
if (TMRRencontres.isReveDeDragon(rencontre)) {
|
||||
const ddr = new Roll("1dr + 7").evaluate();
|
||||
rencontre.force = 7 + ddr.total;
|
||||
}
|
||||
else {
|
||||
rencontre.force = new Roll(rencontre.force).evaluate({ async: false }).total;
|
||||
}
|
||||
rencontre.force = await new Roll(rencontre.force).evaluate().total;
|
||||
return rencontre.force;
|
||||
}
|
||||
|
||||
@ -426,14 +419,14 @@ export class TMRRencontres {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static msgEchecPasseurFou(tmrData) {
|
||||
static async msgEchecPasseurFou(tmrData) {
|
||||
tmrData.sortReserve = Misc.templateData(tmrData.actor).reve.reserve.list[0];
|
||||
if (tmrData.sortReserve) {
|
||||
// Passeur fou positionne sur la case d'un ort en réserve // TODO : Choisir le sort le plus loin ou au hasard
|
||||
tmrData.newTMR = TMRUtility.getTMR(tmrData.sortReserve.coord);
|
||||
} else {
|
||||
// Déplacement aléatoire de la force du Passeur Fou
|
||||
const newCoord = Misc.rollOneOf(TMRUtility.getTMRPortee(tmrData.tmr.coord, tmrData.rencontre.force));
|
||||
const newCoord = await RdDDice.rollOneOf(TMRUtility.getTMRPortee(tmrData.tmr.coord, tmrData.rencontre.force));
|
||||
tmrData.newTMR = TMRUtility.getTMR(newCoord);
|
||||
}
|
||||
if (tmrData.sortReserve) {
|
||||
@ -472,7 +465,7 @@ export class TMRRencontres {
|
||||
static async _toubillonner(tmrDialog, actor, cases) {
|
||||
let coord = Misc.templateData(actor).reve.tmrpos.coord;
|
||||
for (let i = 0; i < cases; i++) {
|
||||
coord = TMRUtility.deplaceTMRAleatoire(actor, coord).coord;
|
||||
coord = await TMRUtility.deplaceTMRAleatoire(actor, coord).coord;
|
||||
}
|
||||
await tmrDialog.forceDemiRevePosition(coord)
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { TMRRencontres } from "./tmr-rencontres.js";
|
||||
import { Misc } from "./misc.js";
|
||||
import { Grammar } from "./grammar.js";
|
||||
import { RdDDice } from "./rdd-dice.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
const TMRMapping = {
|
||||
@ -386,13 +387,13 @@ export class TMRUtility {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getDirectionPattern() {
|
||||
return Misc.rollOneOf(tmrRandomMovePatten);
|
||||
static async getDirectionPattern() {
|
||||
return await RdDDice.rollOneOf(tmrRandomMovePatten);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static deplaceTMRAleatoire(actor, coord) {
|
||||
return TMRUtility.deplaceTMRSelonPattern(actor, coord, TMRUtility.getDirectionPattern(), 1);
|
||||
static async deplaceTMRAleatoire(actor, coord) {
|
||||
return TMRUtility.deplaceTMRSelonPattern(actor, coord, await TMRUtility.getDirectionPattern(), 1);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -424,8 +425,8 @@ export class TMRUtility {
|
||||
return TMRUtility.filterTMR(filter).map(it => it.coord);
|
||||
}
|
||||
|
||||
static getTMRAleatoire(filter = it => true) {
|
||||
return Misc.rollOneOf(TMRUtility.filterTMR(filter))
|
||||
static async getTMRAleatoire(filter = it => true) {
|
||||
return await RdDDice.rollOneOf(TMRUtility.filterTMR(filter))
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { Grammar } from "../grammar.js";
|
||||
import { Misc } from "../misc.js";
|
||||
import { RdDDice } from "../rdd-dice.js";
|
||||
import { tmrColors, tmrConstants, tmrTokenZIndex, TMRUtility } from "../tmr-utility.js";
|
||||
import { Draconique } from "./draconique.js";
|
||||
|
||||
@ -31,7 +32,7 @@ export class Conquete extends Draconique {
|
||||
async _creerConquete(actor, queue) {
|
||||
let existants = actor.data.items.filter(it => this.isCase(it)).map(it => Misc.data(it).data.coord);
|
||||
let possibles = TMRUtility.filterTMR(tmr => !TMRUtility.isCaseHumide(tmr) && !existants.includes(tmr.coord));
|
||||
let conquete = Misc.rollOneOf(possibles);
|
||||
let conquete =await RdDDice.rollOneOf(possibles);
|
||||
await this.createCaseTmr(actor, 'Conquête: ' + conquete.label, conquete, queue.id);
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ export class Debordement extends Draconique {
|
||||
manualMessage() { return false }
|
||||
async onActorCreateOwned(actor, souffle) {
|
||||
const existants = actor.data.items.filter(it => this.isCase(it)).map(it => it.data.coord);
|
||||
const tmr = TMRUtility.getTMRAleatoire(it => !(TMRUtility.isCaseHumide(it) || existants.includes(it.coord)));
|
||||
const tmr = await TMRUtility.getTMRAleatoire(it => !(TMRUtility.isCaseHumide(it) || existants.includes(it.coord)));
|
||||
await this.createCaseTmr(actor, 'Debordement: ' + tmr.label, tmr, souffle.id);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { Grammar } from "../grammar.js";
|
||||
import { Misc } from "../misc.js";
|
||||
import { RdDDice } from "../rdd-dice.js";
|
||||
import { tmrColors, tmrConstants, tmrTokenZIndex, TMRType, TMRUtility } from "../tmr-utility.js";
|
||||
import { Draconique } from "./draconique.js";
|
||||
|
||||
@ -13,7 +14,7 @@ export class Desorientation extends Draconique {
|
||||
manualMessage() { return false }
|
||||
|
||||
async onActorCreateOwned(actor, souffle) {
|
||||
const type = Misc.rollOneOf(this._typesPossibles(actor));
|
||||
const type = await RdDDice.rollOneOf(this._typesPossibles(actor));
|
||||
console.log("désorientation", type);
|
||||
souffle.name += ": " + TMRType[type].name;
|
||||
await this._creerCasesTmr(actor, type, souffle);
|
||||
|
@ -13,7 +13,7 @@ export class Pelerinage extends Draconique {
|
||||
manualMessage() { return false }
|
||||
|
||||
async onActorCreateOwned(actor, queue) {
|
||||
let tmr = TMRUtility.getTMRAleatoire();
|
||||
let tmr = await TMRUtility.getTMRAleatoire();
|
||||
await this.createCaseTmr(actor, 'Pèlerinage: ' + tmr.label, tmr, queue.id);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { Grammar } from "../grammar.js";
|
||||
import { tmrColors, tmrConstants, tmrTokenZIndex, TMRUtility } from "../tmr-utility.js";
|
||||
import { RdDDice } from "../rdd-dice.js";
|
||||
import { tmrConstants, tmrTokenZIndex, TMRUtility } from "../tmr-utility.js";
|
||||
import { Draconique } from "./draconique.js";
|
||||
|
||||
export class Periple extends Draconique {
|
||||
@ -13,7 +14,7 @@ export class Periple extends Draconique {
|
||||
manualMessage() { return false }
|
||||
|
||||
async onActorCreateOwned(actor, souffle) {
|
||||
let terrain = new Roll("1d2").evaluate().total == 1 ? 'sanctuaire' : 'necropole';
|
||||
let terrain = (await RdDDice.rollTotal("1d2")) == 1 ? 'sanctuaire' : 'necropole';
|
||||
let tmrs = TMRUtility.getListTMR(terrain);
|
||||
for (let tmr of tmrs) {
|
||||
await this.createCaseTmr(actor, 'Périple: ' + tmr.label, tmr, souffle.id);
|
||||
|
@ -12,7 +12,7 @@ export class ReserveExtensible extends Draconique {
|
||||
manualMessage() { return "Vous pouvez re-configurer votre Réserve extensible" }
|
||||
async onActorCreateOwned(actor, tete) {
|
||||
const existants = actor.data.items.filter(it => this.isCase(it)).map(it => it.data.coord);
|
||||
const tmr = TMRUtility.getTMRAleatoire(it => !(it.type == 'fleuve' || existants.includes(it.coord)));
|
||||
const tmr = await TMRUtility.getTMRAleatoire(it => !(it.type == 'fleuve' || existants.includes(it.coord)));
|
||||
await this.createCaseTmr(actor, "Nouvelle Réserve extensible", tmr, tete.id);
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ export class TrouNoir extends Draconique {
|
||||
|
||||
async onActorCreateOwned(actor, souffle) {
|
||||
const existants = actor.data.items.filter(it => this.isCase(it)).map(it => it.data.coord);
|
||||
const tmr = TMRUtility.getTMRAleatoire(it => !(TMRUtility.isCaseHumide(it) || existants.includes(it.coord)));
|
||||
const tmr = await TMRUtility.getTMRAleatoire(it => !(TMRUtility.isCaseHumide(it) || existants.includes(it.coord)));
|
||||
await this.createCaseTmr(actor, 'Trou noir: ' + tmr.label, tmr, souffle.id);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user