diff --git a/css/ready-set-roll.css b/css/ready-set-roll.css index fb1f096..58b1f3f 100644 --- a/css/ready-set-roll.css +++ b/css/ready-set-roll.css @@ -33,6 +33,14 @@ padding: 0px 4px 0px 4px; } +.dice-roll .dice-total.critical { + color: var(--color-text-dark-primary); +} + +.dice-roll .dice-total.fumble { + color: var(--color-text-dark-primary); +} + .rsr-dual .dice-row .failure { color: #aa0200; } diff --git a/lang/en.json b/lang/en.json index cf2bf71..bfd0fbd 100644 --- a/lang/en.json +++ b/lang/en.json @@ -9,6 +9,8 @@ "enableItemQuickRoll.hint": "When clicking on an item's image (weapons, spells, features, etc.), automatically roll to chat instead of using the normal chat output. This functionality can be bypassed by holding Alt when clicking.", "enableAltQuickRoll.name": "Enable Alternate Roll for Items", "enableAltQuickRoll.hint": "When Alt-clicking on an item's image, output a different quick roll which can be configured separately, replacing the ability to bypass quick rolling for items. This setting has no effect if item quick rolling is disabled.", + "enableQuickRollDesc.name": "Enable Descriptions by Default", + "enableQuickRollDesc.hint": "When outputting a quick roll, always show the description by default. This can still be changed per item in quick roll configuration.", "enableD20Icons.name": "Show D20 Rolls for Quick Rolls", "enableD20Icons.hint": "When outputting a quick roll, display an icon showing the natural die roll next to the total result.", "enableDiceSounds.name": "Enable Dice Sounds for Quick Rolls", diff --git a/src/module/config.js b/src/module/config.js index a0ae838..abc1e20 100644 --- a/src/module/config.js +++ b/src/module/config.js @@ -1,5 +1,6 @@ import { ITEM_TYPE } from "../utils/item.js"; import { FIELD_TYPE } from "../utils/render.js"; +import { SettingsUtility, SETTING_NAMES } from "../utils/settings.js"; import { MODULE_SHORT } from "./const.js"; /** @@ -31,7 +32,7 @@ CONFIG[MODULE_SHORT] = { }, flags: { weapon: { - quickDesc: { type: "Boolean", value: false, altValue: false }, + quickDesc: { type: "Boolean", get value() { return SettingsUtility.getSettingValue(SETTING_NAMES.QUICK_ROLL_DESC_ENABLED) }, altValue: false }, quickFlavor: { type: "Boolean", value: true, altValue: true }, quickFooter: { type: "Boolean", value: true, altValue: true }, quickAttack: { type: "Boolean", value: true, altValue: true }, @@ -83,7 +84,7 @@ CONFIG[MODULE_SHORT] = { consumeRecharge: { type: "Boolean", value: true, altValue: true } }, tool: { - quickDesc: { type: "Boolean", value: false, altValue: false }, + quickDesc: { type: "Boolean", get value() { return SettingsUtility.getSettingValue(SETTING_NAMES.QUICK_ROLL_DESC_ENABLED) }, altValue: false }, quickFlavor: { type: "Boolean", value: true, altValue: true }, quickFooter: { type: "Boolean", value: true, altValue: true }, quickCheck: { type: "Boolean", value: true, altValue: true } diff --git a/src/module/quickroll.js b/src/module/quickroll.js index fcf813c..6ee3c20 100644 --- a/src/module/quickroll.js +++ b/src/module/quickroll.js @@ -117,7 +117,12 @@ export class QuickRoll { * @returns {Promise} A quick roll instance derived from stored message data. */ static async fromMessage(message) { - const data = message.flags[`${MODULE_SHORT}`]; + const data = message.flags[MODULE_SHORT]; + + // convert JSON string back to objects + if (typeof(data?.fields[0]) === "string") { + data.fields = data.fields.map(JSON.parse); + } // Rolls in fields are unpacked and must be recreated. const fields = data?.fields ?? []; @@ -175,6 +180,12 @@ export class QuickRoll { ...CoreUtility.getWhisperData(rollMode), } + // Can't store classes in flags, but the fields may contain D20Roll classes, so convert them to JSON strings. + const flags = chatData.flags[MODULE_SHORT]; + if (flags.fields) { + flags.fields = flags.fields.map(JSON.stringify); + } + if (this.item) { Hooks.callAll(HOOKS_DND5E.PRE_DISPLAY_CARD, item, chatData, { createMessage }); } @@ -345,7 +356,7 @@ export class QuickRoll { */ _getFlags() { const flags = { - rsr5e: { + [MODULE_SHORT]: { version: CoreUtility.getVersion(), actorId: this.actorId, itemId: this.itemId, @@ -353,7 +364,7 @@ export class QuickRoll { params: this.params, fields: this.fields } - }; + }; if (this.fields.some(f => f[0] === ROLL_TYPE.ATTACK)) { flags["dnd5e.roll.type"] = ROLL_TYPE.ATTACK; diff --git a/src/utils/item.js b/src/utils/item.js index 5d31d88..00245ad 100644 --- a/src/utils/item.js +++ b/src/utils/item.js @@ -177,7 +177,12 @@ export class ItemUtility { * These booleans give a quick indication on if the item has that specific consume property. * @param {Item} item The item on which to ensure consume properties exist. */ - static ensureConsumePropertiesOnItem(item) { + static ensureConsumePropertiesOnItem(item) { + if (item?.type === ITEM_TYPE.SPELL) + { + return; + } + if (item) { // For items with quantity (weapons, tools, consumables...) item.hasQuantity = ("quantity" in item.system); diff --git a/src/utils/render.js b/src/utils/render.js index a577fed..725e34a 100644 --- a/src/utils/render.js +++ b/src/utils/render.js @@ -178,8 +178,10 @@ async function _renderMultiRoll(renderData = {}) { if (roll.options.halflingLucky && d20Rolls.results[i].result === 1) { i++; tmpResults.push(d20Rolls.results[i]); - } + } + let critOptions = { critThreshold: roll.options.critical, fumbleThreshold: roll.options.fumble }; + // Die terms must have active results or the base roll total of the generated roll is 0. // This does not apply to dice that have been rerolled (unless they are replaced by a fixer value eg. for reliable talent). tmpResults.forEach(r => { @@ -198,7 +200,7 @@ async function _renderMultiRoll(renderData = {}) { roll: baseRoll, total: baseRoll.total + (bonusRoll?.total ?? 0), ignored: tmpResults.some(r => r.discarded) ? true : undefined, - critType: RollUtility.getCritTypeForDie(baseTerm), + critType: RollUtility.getCritTypeForDie(baseTerm, critOptions), d20Result: SettingsUtility.getSettingValue(SETTING_NAMES.D20_ICONS_ENABLED) ? d20Rolls.results[i].result : null }); } diff --git a/src/utils/settings.js b/src/utils/settings.js index fafc455..6687de5 100644 --- a/src/utils/settings.js +++ b/src/utils/settings.js @@ -12,6 +12,7 @@ export const SETTING_NAMES = { QUICK_ABILITY_ENABLED: "enableAbilityQuickRoll", QUICK_ITEM_ENABLED: "enableItemQuickRoll", ALT_ROLL_ENABLED: "enableAltQuickRoll", + QUICK_ROLL_DESC_ENABLED: "enableQuickRollDesc", D20_ICONS_ENABLED: "enableD20Icons", DICE_SOUNDS_ENABLED: "enableDiceSounds", OVERLAY_BUTTONS_ENABLED: "enableOverlayButtons", @@ -75,6 +76,7 @@ export class SettingsUtility { // ADDITIONAL ROLL SETTINGS const extraRollOptions = [ { name: SETTING_NAMES.ALT_ROLL_ENABLED, default: false, scope: "world" }, + { name: SETTING_NAMES.QUICK_ROLL_DESC_ENABLED, default: false, scope: "world" }, { name: SETTING_NAMES.ALWAYS_ROLL_MULTIROLL, default: false, scope: "client" }, { name: SETTING_NAMES.ALWAYS_MANUAL_DAMAGE, default: false, scope: "client" } ];