mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-21 18:09:54 +02:00
Finished logic
This commit is contained in:
parent
f004227232
commit
e63d19a2c4
5 changed files with 15 additions and 7 deletions
|
|
@ -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."
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
{{#if (eq item.system.resource.type 'simple')}}
|
||||
<div class="item-resource">
|
||||
{{#if item.system.hasReload}}
|
||||
<a data-action="toggleItemReload" title="{{localize (ifThen (eq item.system.resource.value 0) 'DAGGERHEART.GENERAL.Resource.unloaded' 'DAGGERHEART.GENERAL.Resource.loaded')}}">
|
||||
<i class="fa-solid fa-gun {{#if (eq item.system.resource.value 0)}}unloaded{{/if}}"></i>
|
||||
<a data-action="toggleItemReload" title="{{localize (ifThen item.system.needsReload 'DAGGERHEART.GENERAL.Resource.unloaded' 'DAGGERHEART.GENERAL.Resource.loaded')}}">
|
||||
<i class="fa-solid fa-gun {{#if item.system.needsReload}}unloaded{{/if}}"></i>
|
||||
</a>
|
||||
{{else}}
|
||||
<i class="{{#if item.system.resource.icon}}{{item.system.resource.icon}}{{else}}fa-solid fa-hashtag{{/if}}"></i>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue