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
|
|
@ -3263,7 +3263,8 @@
|
||||||
"knowTheTide": "Know The Tide gained a token",
|
"knowTheTide": "Know The Tide gained a token",
|
||||||
"lackingItemTransferPermission": "User {user} lacks owner permission needed to transfer items to {target}",
|
"lackingItemTransferPermission": "User {user} lacks owner permission needed to transfer items to {target}",
|
||||||
"noTokenTargeted": "No token is targeted",
|
"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": {
|
"Progress": {
|
||||||
"migrationLabel": "Performing system migration. Please wait and do not close Foundry."
|
"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) {
|
static async #onToggleItemReload(_, target) {
|
||||||
const item = await getDocFromElement(target);
|
const item = await getDocFromElement(target);
|
||||||
if (!item || !item.system.resource?.type === 'simple' || !item.system.resource.max)
|
if (!item || !item.system.resource?.max)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const isReloaded = item.system.resource.value > 0;
|
await item.update({ 'system.resource.value':
|
||||||
await item.update({
|
item.system.needsReload ? itemAbleRollParse(item.system.resource.max, this.document, item) : 0
|
||||||
'system.resource.value': isReloaded ? 0 : itemAbleRollParse(item.system.resource.max, this.document, item)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,10 @@ export default class DHAttackAction extends DHDamageAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
async use(event, options) {
|
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);
|
const result = await super.use(event, options);
|
||||||
|
|
||||||
if (result?.message?.system.action?.roll?.type === 'attack') {
|
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'));
|
return Boolean(this.weaponFeatures.find(x => x.value === 'reloading'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get needsReload() {
|
||||||
|
return this.hasReload && this.resource.value === 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**@inheritdoc */
|
/**@inheritdoc */
|
||||||
async getDescriptionData() {
|
async getDescriptionData() {
|
||||||
const baseDescription = this.description;
|
const baseDescription = this.description;
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
{{#if (eq item.system.resource.type 'simple')}}
|
{{#if (eq item.system.resource.type 'simple')}}
|
||||||
<div class="item-resource">
|
<div class="item-resource">
|
||||||
{{#if item.system.hasReload}}
|
{{#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')}}">
|
<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 (eq item.system.resource.value 0)}}unloaded{{/if}}"></i>
|
<i class="fa-solid fa-gun {{#if item.system.needsReload}}unloaded{{/if}}"></i>
|
||||||
</a>
|
</a>
|
||||||
{{else}}
|
{{else}}
|
||||||
<i class="{{#if item.system.resource.icon}}{{item.system.resource.icon}}{{else}}fa-solid fa-hashtag{{/if}}"></i>
|
<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