From 2d3a762a0d4d9321cdbebc2ec58f5a9e44854f2a Mon Sep 17 00:00:00 2001 From: Ben Straub Date: Thu, 5 Sep 2024 13:54:43 -0700 Subject: [PATCH] Find a result that matches the original roll --- src/module/roll-table/oracle-table.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/module/roll-table/oracle-table.ts b/src/module/roll-table/oracle-table.ts index d922c5053..bf705520c 100644 --- a/src/module/roll-table/oracle-table.ts +++ b/src/module/roll-table/oracle-table.ts @@ -379,6 +379,7 @@ export class OracleTable extends RollTable { // defer render to chat so we can manually set the chat message id const { results, roll } = await oracleTable.draw({ displayChat: false }) const { cursedResults, cursedDie } = await oracleTable.cursedResults(roll) + console.log(cursedResults) const templateData = await oracleTable._prepareTemplateData( results, @@ -424,11 +425,11 @@ export class OracleTable extends RollTable { if (cursedDie.total !== 1) return { cursedDie } // Draw from the cursed table - const { results: cursedResults } = await cursedTable.draw({ - roll: originalRoll, - displayChat: false - }) - return { cursedResults, cursedDie } + const cursedResult = cursedTable.results.find( + (x) => + originalRoll.total >= x.range[0] && originalRoll.total <= x.range[1] + ) + return { cursedResults: [cursedResult], cursedDie } } }