Skip to content

Commit

Permalink
Find a result that matches the original roll
Browse files Browse the repository at this point in the history
  • Loading branch information
ben committed Sep 5, 2024
1 parent bda1652 commit 2d3a762
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/module/roll-table/oracle-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 }
}
}

Expand Down

0 comments on commit 2d3a762

Please sign in to comment.