mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-22 02:19:54 +02:00
Finished logic
This commit is contained in:
parent
f004227232
commit
e63d19a2c4
5 changed files with 15 additions and 7 deletions
|
|
@ -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
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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') {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue