Finished logic

This commit is contained in:
WBHarry 2026-07-03 17:06:55 +02:00
parent f004227232
commit e63d19a2c4
5 changed files with 15 additions and 7 deletions

View file

@ -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
})
}

View file

@ -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') {

View file

@ -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;