Skip to content

Commit

Permalink
Small fix for random table roll chat messages
Browse files Browse the repository at this point in the history
Chat messages handled only plain text for rolls from random tables.
This fix allows for proper display of other types (for example
macros) assigned to a roll result in the table.
  • Loading branch information
Deixx committed Dec 28, 2024
1 parent 6bbb69e commit 335ea0e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions scripts/common/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class WNGChat {
return ui.notifications.error(game.i18n.format("ROLL.CannotFindTable", {name : game.i18n.localize("TABLE.CRITICAL_HIT_TABLE")}))
roll = new Roll(table.formula)
result = await table.roll({ roll })
chatData = { content: result.results[0].text + ` (${result.roll.total})`, flavor: `Critical Hit` }
chatData = { content: result.results[0].getChatText() + ` (${result.roll.total})`, flavor: `Critical Hit` }
}
}
if (test.result.isWrathComplication) {
Expand All @@ -48,7 +48,7 @@ export default class WNGChat {
return ui.notifications.error(game.i18n.format("ROLL.CannotFindTable", {name : game.i18n.localize("TABLE.COMBAT_COMPLICATIONS")}))
roll = new Roll(table.formula)
result = await table.roll({ roll })
chatData = { content: result.results[0].text + ` (${result.roll.total})`, flavor: `Combat Complication` }
chatData = { content: result.results[0].getChatText() + ` (${result.roll.total})`, flavor: `Combat Complication` }
}
else if (test.power) {
table = game.tables.getName(game.i18n.localize("TABLE.PERILS_OF_THE_WARP"))
Expand All @@ -57,15 +57,15 @@ export default class WNGChat {
let modifier = (test.result.allDice.filter(die => die.name == "wrath-complication").length - 1) * 10
roll = new Roll(table.formula + " + " + modifier)
result = await table.roll({ roll })
chatData = { content: result.results[0].text + ` (${result.roll.total})`, flavor: `Perils of the Warp ${modifier ? "(+" + modifier + ")" : ""}` }
chatData = { content: result.results[0].getChatText() + ` (${result.roll.total})`, flavor: `Perils of the Warp ${modifier ? "(+" + modifier + ")" : ""}` }
}
else {
table = game.tables.getName(game.i18n.localize("TABLE.COMPLICATION_CONSEQUENCES"))
if (!table)
return ui.notifications.error(game.i18n.format("ROLL.CannotFindTable", {name : game.i18n.localize("TABLE.COMPLICATION_CONSEQUENCES")}))
roll = new Roll(table.formula)
result = await table.roll({ roll })
chatData = { content: result.results[0].text + ` (${result.roll.total})`, flavor: `Complication Consequence` }
chatData = { content: result.results[0].getChatText() + ` (${result.roll.total})`, flavor: `Complication Consequence` }
}
}
if (chatData.content)
Expand Down

0 comments on commit 335ea0e

Please sign in to comment.