Various fixes for TMR, WIP

This commit is contained in:
sladecraven 2021-03-28 22:37:04 +02:00
parent f043c3b504
commit 36df301144
7 changed files with 15 additions and 13 deletions

View File

@ -1051,7 +1051,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async ajouterRefoulement(value = 1) { async ajouterRefoulement(value = 1) {
let refoulement = Misc.templateData(this).reve.refoulement.value + value; let refoulement = Misc.templateData(this).reve.refoulement.value + value;
let total = new Roll("1d20").roll().total; let total = new Roll("1d20").evaluate( {async: false}).total;
if (total <= refoulement) { if (total <= refoulement) {
refoulement = 0; refoulement = 0;
await this.ajouterSouffle({ chat: true }); await this.ajouterSouffle({ chat: true });
@ -1426,9 +1426,9 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async moralIncDec(ajustementMoral) { async moralIncDec(ajustementMoral) {
let actorData
if (ajustementMoral != 0) { if (ajustementMoral != 0) {
const actorData = Misc.data(this); actorData = Misc.data(this);
let moral = Misc.toInt(actorData.data.compteurs.moral.value) + ajustementMoral let moral = Misc.toInt(actorData.data.compteurs.moral.value) + ajustementMoral
if (moral > 3) { // exaltation if (moral > 3) { // exaltation
const exaltation = Misc.toInt(actorData.data.compteurs.exaltation.value) + moral - 3; const exaltation = Misc.toInt(actorData.data.compteurs.exaltation.value) + moral - 3;

View File

@ -72,7 +72,7 @@ export class Misc {
} }
static rollOneOf(array) { static rollOneOf(array) {
return array[new Roll("1d" + array.length).evaluate().total - 1]; return array[new Roll("1d" + array.length).evaluate( { async: false} ).total - 1];
} }
static distinct(array) { static distinct(array) {

View File

@ -151,7 +151,7 @@ export class RdDResolutionTable {
/* -------------------------------------------- */ /* -------------------------------------------- */
static async rollChances(chances) { static async rollChances(chances) {
let myRoll = new Roll("1d100").roll(); let myRoll = new Roll("1d100").evaluate( {async: false} );
myRoll.showDice = chances.showDice; myRoll.showDice = chances.showDice;
await RdDDice.show(myRoll); await RdDDice.show(myRoll);
chances.roll = myRoll.total; chances.roll = myRoll.total;

View File

@ -144,9 +144,10 @@ export class RdDRoll extends Dialog {
console.log(rollData); console.log(rollData);
// Update html, according to data // Update html, according to data
if (rollData.competence) { if (rollData.competence) {
let compData = rollData.competence.data.data || rollData.competence.data;
// Set the default carac from the competence item // Set the default carac from the competence item
rollData.selectedCarac = rollData.carac[rollData.competence.data.data.defaut_carac]; rollData.selectedCarac = rollData.carac[compData.defaut_carac];
$("#carac").val(rollData.competence.data.data.defaut_carac); $("#carac").val(compData.defaut_carac);
} }
if (rollData.selectedSort) { if (rollData.selectedSort) {
$("#draconic").val(rollData.selectedSort.data.listIndex); // Uniquement a la selection du sort, pour permettre de changer $("#draconic").val(rollData.selectedSort.data.listIndex); // Uniquement a la selection du sort, pour permettre de changer

View File

@ -15,9 +15,10 @@ export class RdDRollTables {
static async drawItemFromRollTable(tableName, toChat) { static async drawItemFromRollTable(tableName, toChat) {
const draw = await RdDRollTables.genericGetTableResult(tableName, toChat); const draw = await RdDRollTables.genericGetTableResult(tableName, toChat);
const drawnItemRef = draw.results.length > 0 ? draw.results[0] : undefined; const drawnItemRef = draw.results.length > 0 ? draw.results[0] : undefined;
if (drawnItemRef.collection) { if (drawnItemRef.data.collection) {
const pack = game.packs.get(drawnItemRef.collection); console.log(drawnItemRef);
return await pack.getDocument(drawnItemRef.resultId); const pack = game.packs.get(drawnItemRef.data.collection);
return await pack.getDocument(drawnItemRef.data.resultId);
} }
ui.notifications.warn("le tirage ne correspond pas à une entrée d'un Compendium") ui.notifications.warn("le tirage ne correspond pas à une entrée d'un Compendium")
return drawnItemRef.text; return drawnItemRef.text;

View File

@ -457,7 +457,7 @@ export class RdDTMRDialog extends Dialog {
if (rencontre) { if (rencontre) {
return rencontre; return rencontre;
} }
let myRoll = new Roll("1d7").evaluate().total; let myRoll = new Roll("1d7").evaluate( { async: false} ).total;
if (TMRUtility.isForceRencontre() || myRoll == 7) { if (TMRUtility.isForceRencontre() || myRoll == 7) {
return await this.rencontreTMRRoll(tmr, this.actor.isRencontreSpeciale()); return await this.rencontreTMRRoll(tmr, this.actor.isRencontreSpeciale());
} }

View File

@ -357,7 +357,7 @@ export class TMRRencontres {
/* -------------------------------------------- */ /* -------------------------------------------- */
static async getRencontreAleatoire(terrain, roll = undefined) { static async getRencontreAleatoire(terrain, roll = undefined) {
if (!roll || roll <= 0 || roll > 100) { if (!roll || roll <= 0 || roll > 100) {
roll = new Roll("1d100").evaluate().total; roll = new Roll("1d100").evaluate( {async: false}).total;
} }
terrain = Grammar.toLowerCaseNoAccent(terrain); terrain = Grammar.toLowerCaseNoAccent(terrain);
//console.log("getRencontreAleatoire", terrain, roll); //console.log("getRencontreAleatoire", terrain, roll);
@ -386,7 +386,7 @@ export class TMRRencontres {
rencontre.force = 7 + ddr.total; rencontre.force = 7 + ddr.total;
} }
else { else {
rencontre.force = new Roll(rencontre.force).evaluate().total; rencontre.force = new Roll(rencontre.force).evaluate( {async: false} ).total;
} }
return rencontre.force; return rencontre.force;
} }