diff --git a/lang/en.json b/lang/en.json index 3e7889cf..91f41f12 100755 --- a/lang/en.json +++ b/lang/en.json @@ -3263,7 +3263,8 @@ "knowTheTide": "Know The Tide gained a token", "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" + "behaviorRegionRequiresGM": "Creating a Region with an attached Behavior requires an online GM", + "reloadRequired": "The {weapon} must be reloaded to be used!" }, "Progress": { "migrationLabel": "Performing system migration. Please wait and do not close Foundry." diff --git a/module/applications/sheets/actors/character.mjs b/module/applications/sheets/actors/character.mjs index 1a4ecafa..ea69f27d 100644 --- a/module/applications/sheets/actors/character.mjs +++ b/module/applications/sheets/actors/character.mjs @@ -961,12 +961,11 @@ export default class CharacterSheet extends DHBaseActorSheet { static async #onToggleItemReload(_, target) { const item = await getDocFromElement(target); - if (!item || !item.system.resource?.type === 'simple' || !item.system.resource.max) + if (!item || !item.system.resource?.max) return; - const isReloaded = item.system.resource.value > 0; - await item.update({ - 'system.resource.value': isReloaded ? 0 : itemAbleRollParse(item.system.resource.max, this.document, item) + await item.update({ 'system.resource.value': + item.system.needsReload ? itemAbleRollParse(item.system.resource.max, this.document, item) : 0 }) } diff --git a/module/data/action/attackAction.mjs b/module/data/action/attackAction.mjs index a1030c24..7024c96e 100644 --- a/module/data/action/attackAction.mjs +++ b/module/data/action/attackAction.mjs @@ -51,6 +51,10 @@ export default class DHAttackAction extends DHDamageAction { } async use(event, options) { + if (this.item?.system.needsReload) { + return ui.notifications.error(game.i18n.format('DAGGERHEART.UI.Notifications.reloadRequired', { weapon: this.item.name })); + } + const result = await super.use(event, options); if (result?.message?.system.action?.roll?.type === 'attack') { diff --git a/module/data/item/weapon.mjs b/module/data/item/weapon.mjs index 4448b3a5..96550bc3 100644 --- a/module/data/item/weapon.mjs +++ b/module/data/item/weapon.mjs @@ -122,6 +122,10 @@ export default class DHWeapon extends AttachableItem { return Boolean(this.weaponFeatures.find(x => x.value === 'reloading')); } + get needsReload() { + return this.hasReload && this.resource.value === 0; + } + /**@inheritdoc */ async getDescriptionData() { const baseDescription = this.description; diff --git a/templates/sheets/global/partials/item-resource.hbs b/templates/sheets/global/partials/item-resource.hbs index 21e268cf..f0d0ffe7 100644 --- a/templates/sheets/global/partials/item-resource.hbs +++ b/templates/sheets/global/partials/item-resource.hbs @@ -2,8 +2,8 @@ {{#if (eq item.system.resource.type 'simple')}}