diff --git a/lang/en.json b/lang/en.json index d0b8d0f7..51f15b1e 100755 --- a/lang/en.json +++ b/lang/en.json @@ -126,7 +126,7 @@ "damageOnSave": "Damage on Save", "useDefaultItemValues": "Use default Item values" }, - "Reload": { + "Reload": { "checkReload": "Check Reload", "reloadRequired": "Reload Required!" }, @@ -3274,7 +3274,9 @@ "lackingItemTransferPermission": "User {user} lacks owner permission needed to transfer items to {target}", "noTokenTargeted": "No token is targeted", "behaviorRegionRequiresGM": "Creating a Region with an attached Behavior requires an online GM", - "reloadRequired": "The {weapon} must be reloaded to be used!" + "reloadRequired": "The {weapon} must be reloaded to be used!", + "reloadRequiredRollResponse": "Reload Check: 1d6 -> {roll}. Reload required.", + "noReloadRequiredRollResponse": "Reload Check: 1d6 -> {roll}. No reload required." }, "Progress": { "migrationLabel": "Performing system migration. Please wait and do not close Foundry." @@ -3329,7 +3331,8 @@ "immune": "Immune", "middleClick": "[Middle Click] Keep tooltip view", "tokenSize": "The token size used on the canvas", - "previewTokenHelp": "Left-click to place, right-click to cancel" + "previewTokenHelp": "Left-click to place, right-click to cancel", + "noReloadRequired": "No Reload Required!" } } } diff --git a/module/applications/ui/chatLog.mjs b/module/applications/ui/chatLog.mjs index 0ad436ec..0c6e1f02 100644 --- a/module/applications/ui/chatLog.mjs +++ b/module/applications/ui/chatLog.mjs @@ -281,7 +281,12 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo async onRollReloadCheck(_event, messageData) { const message = game.messages.get(messageData._id); - const needsReload = await message.system.action.handleReload?.({ awaitRoll: true }); - await message.update({ 'system.needsReload': needsReload }); + const { needsReload, rollValue } = await message.system.action.handleReload?.({ awaitRoll: true }); + await message.update({ 'system.reloadCheckValue': rollValue }); + + if (needsReload) + ui.notifications.info(_loc('DAGGERHEART.UI.Notifications.reloadRequiredRollResponse', { roll: rollValue })); + else + ui.notifications.info(_loc('DAGGERHEART.UI.Notifications.noReloadRequiredRollResponse', { roll: rollValue })); } } diff --git a/module/data/action/attackAction.mjs b/module/data/action/attackAction.mjs index bf78520d..ba11c6ff 100644 --- a/module/data/action/attackAction.mjs +++ b/module/data/action/attackAction.mjs @@ -74,13 +74,13 @@ export default class DHAttackAction extends DHDamageAction { else game.dice3d.showForRoll(roll, game.user, true); } - - const needsToReload = roll.total === 1; - if (needsToReload) { + + const needsReload = roll.total === 1; + if (needsReload) { this.item.update({ 'system.resource.value': 0 }); } - return needsToReload; + return { needsReload, rollValue: roll.total }; } /** diff --git a/module/data/chat-message/actorRoll.mjs b/module/data/chat-message/actorRoll.mjs index 11dca9e1..58080f84 100644 --- a/module/data/chat-message/actorRoll.mjs +++ b/module/data/chat-message/actorRoll.mjs @@ -42,7 +42,7 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel { hasEffect: new fields.BooleanField({ initial: false }), hasSave: new fields.BooleanField({ initial: false }), hasTarget: new fields.BooleanField({ initial: false }), - needsReload: new fields.BooleanField({ initial: false }), + reloadCheckValue: new fields.NumberField({ integer: true, nullable: true, initial: null }), isDirect: new fields.BooleanField({ initial: false }), onSave: new fields.StringField(), source: new fields.SchemaField({ @@ -99,6 +99,10 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel { return this.item?.system.hasReload; } + get needsReload() { + return this.reloadCheckValue === 1; + } + get action() { const { actionActor, actionItem: itemAction } = this; if (!this.source.action) return null; diff --git a/module/dice/dhRoll.mjs b/module/dice/dhRoll.mjs index 62d9ff9f..ae75d458 100644 --- a/module/dice/dhRoll.mjs +++ b/module/dice/dhRoll.mjs @@ -139,7 +139,14 @@ export default class DHRoll extends BaseRoll { item?.system.hasReload && action?.type === 'attack' && reloadSetting === CONFIG.DH.SETTINGS.reloadChoices.auto.id; - const needsReload = useReload ? await action?.handleReload?.() : false; + const reloadResult = useReload ? await action?.handleReload?.() : {}; + + if (useReload) { + if (reloadResult.needsReload) + ui.notifications.info(_loc('DAGGERHEART.UI.Notifications.reloadRequiredRollResponse', { roll: reloadResult.rollValue })); + else + ui.notifications.info(_loc('DAGGERHEART.UI.Notifications.noReloadRequiredRollResponse', { roll: reloadResult.rollValue })); + } const cls = getDocumentClass('ChatMessage'), msgData = { @@ -148,7 +155,11 @@ export default class DHRoll extends BaseRoll { title: roll.title, speaker: cls.getSpeaker({ actor: roll.data?.parent }), sound: config.mute ? null : CONFIG.sounds.dice, - system: { ...config, actionDescription, needsReload }, + system: { + ...config, + actionDescription, + reloadCheckValue: reloadResult.rollValue + }, rolls: [roll] }; diff --git a/templates/ui/chat/parts/button-part.hbs b/templates/ui/chat/parts/button-part.hbs index 56c8625b..3472c684 100644 --- a/templates/ui/chat/parts/button-part.hbs +++ b/templates/ui/chat/parts/button-part.hbs @@ -1,6 +1,8 @@
{{#if (and parent.system.hasReload (eq automationSettings.reload 'button'))}} - + {{/if}} {{#if areas.length}}{{/if}} {{#if hasDamage}}