Bunch o fxies (#674)

This commit is contained in:
WBHarry 2025-08-07 10:20:46 +02:00 committed by GitHub
parent f5febe74fe
commit 0108e3d222
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 20 additions and 8 deletions

View file

@ -94,7 +94,10 @@ export default class DhpDowntime extends HandlebarsApplicationMixin(ApplicationV
const actionItems = this.actor.items.reduce((acc, x) => { const actionItems = this.actor.items.reduce((acc, x) => {
if (x.system.actions) { if (x.system.actions) {
const recoverable = x.system.actions.reduce((acc, action) => { const recoverable = x.system.actions.reduce((acc, action) => {
if (action.uses.recovery && (action.uses.recovery === 'shortRest') === this.shortrest) { if (
(action.uses.recovery && (action.uses.recovery === 'longRest') === !this.shortrest) ||
action.uses.recovery === 'shortRest'
) {
acc.push({ acc.push({
title: x.name, title: x.name,
name: action.name, name: action.name,
@ -116,7 +119,8 @@ export default class DhpDowntime extends HandlebarsApplicationMixin(ApplicationV
if ( if (
x.system.resource && x.system.resource &&
x.system.resource.type && x.system.resource.type &&
(x.system.resource.recovery === 'shortRest') === this.shortrest ((x.system.resource.recovery === 'longRest') === !this.shortrest ||
x.system.resource.recovery === 'shortRest')
) { ) {
acc.push({ acc.push({
title: game.i18n.localize(`TYPES.Item.${x.type}`), title: game.i18n.localize(`TYPES.Item.${x.type}`),
@ -226,7 +230,7 @@ export default class DhpDowntime extends HandlebarsApplicationMixin(ApplicationV
) { ) {
for (var data of this.refreshables.actionItems) { for (var data of this.refreshables.actionItems) {
const action = await foundry.utils.fromUuid(data.uuid); const action = await foundry.utils.fromUuid(data.uuid);
await action.parent.parent.update({ [`system.actions.${action.id}.uses.value`]: action.uses.max ?? 1 }); await action.parent.parent.update({ [`system.actions.${action.id}.uses.value`]: 0 });
} }
for (var data of this.refreshables.resourceItems) { for (var data of this.refreshables.resourceItems) {

View file

@ -73,7 +73,7 @@ export default class DhCharacter extends BaseDataActor {
), ),
gold: new fields.SchemaField({ gold: new fields.SchemaField({
coins: new fields.NumberField({ initial: 0, integer: true }), coins: new fields.NumberField({ initial: 0, integer: true }),
handfulls: new fields.NumberField({ initial: 0, integer: true }), handfulls: new fields.NumberField({ initial: 1, integer: true }),
bags: new fields.NumberField({ initial: 0, integer: true }), bags: new fields.NumberField({ initial: 0, integer: true }),
chests: new fields.NumberField({ initial: 0, integer: true }) chests: new fields.NumberField({ initial: 0, integer: true })
}), }),

View file

@ -12,7 +12,10 @@ export default class UsesField extends fields.SchemaField {
initial: null, initial: null,
nullable: true nullable: true
}), }),
consumeOnSuccess: new fields.BooleanField({ initial: false, label: "DAGGERHEART.ACTIONS.Settings.consumeOnSuccess.label" }) consumeOnSuccess: new fields.BooleanField({
initial: false,
label: 'DAGGERHEART.ACTIONS.Settings.consumeOnSuccess.label'
})
}; };
super(usesFields, options, context); super(usesFields, options, context);
} }
@ -30,6 +33,7 @@ export default class UsesField extends fields.SchemaField {
if (!uses) return null; if (!uses) return null;
return { return {
...uses, ...uses,
remaining: this.remainingUses,
enabled: uses.hasOwnProperty('enabled') ? uses.enabled : true enabled: uses.hasOwnProperty('enabled') ? uses.enabled : true
}; };
} }

View file

@ -1,4 +1,5 @@
import DHActionConfig from '../../applications/sheets-configs/action-config.mjs'; import DHActionConfig from '../../applications/sheets-configs/action-config.mjs';
import { itemAbleRollParse } from '../../helpers/utils.mjs';
import MappingField from './mappingField.mjs'; import MappingField from './mappingField.mjs';
/** /**
@ -167,7 +168,10 @@ export function ActionMixin(Base) {
get remainingUses() { get remainingUses() {
if (!this.uses) return null; if (!this.uses) return null;
return Math.max((this.uses.max ?? 0) - (this.uses.value ?? 0), 0); return Math.max(
(this.uses.max ? itemAbleRollParse(this.uses.max, this.actor) : 0) - (this.uses.value ?? 0),
0
);
} }
static async create(data, operation = {}) { static async create(data, operation = {}) {

View file

@ -9,7 +9,7 @@
<label for="uses.enabled">Uses{{#if uses.consumeOnSuccess}}<span class="hint">{{localize "DAGGERHEART.ACTIONS.Settings.consumeOnSuccess.short"}}{{/if}}</span></label> <label for="uses.enabled">Uses{{#if uses.consumeOnSuccess}}<span class="hint">{{localize "DAGGERHEART.ACTIONS.Settings.consumeOnSuccess.short"}}{{/if}}</span></label>
</div> </div>
</div> </div>
<label class="modifier-label">{{uses.value}}/{{formulaValue uses.max @root.rollConfig.data}}</label> <label class="modifier-label">1/{{uses.remaining}}</label>
</li> </li>
{{/if}} {{/if}}
{{#each costs as | cost index |}} {{#each costs as | cost index |}}

View file

@ -127,6 +127,6 @@
</div> </div>
{{#> 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs'}} {{#> 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs'}}
<button data-action="openSettings" data-tooltip-text="{{localize "DAGGERHEART.UI.Tooltip.openSheetSettings"}}"><i class="fa-solid fa-wrench"></i></button> <button type="button" data-action="openSettings" data-tooltip-text="{{localize "DAGGERHEART.UI.Tooltip.openSheetSettings"}}"><i class="fa-solid fa-wrench"></i></button>
{{/'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs'}} {{/'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs'}}
</header> </header>