[Fix] BaseAction Getter Fixes (#2105)

This commit is contained in:
WBHarry 2026-07-23 02:54:42 +02:00 committed by GitHub
parent 80cc7f1502
commit a9000e5408
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 39 additions and 19 deletions

23
module/data/action/_types.d.ts vendored Normal file
View file

@ -0,0 +1,23 @@
import { DHDamageData, DHResourceData } from '../fields/action/damageField.mjs';
declare module './baseAction.mjs' {
export default interface DHBaseAction {
_id: string;
systemPath: string;
type?: string;
baseAction: boolean;
name?: string;
description: string;
img?: string;
chatDisplay: boolean;
originItem: object;
actionType: string;
targetUuid?: string;
damage: {
main: DHDamageData;
/** An iterable record of items (todo: type the iterable record) */
resources: Record<string, DHResourceData>;
}
}
}

View file

@ -429,11 +429,11 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
}
get hasDamage() {
return this.type !== 'healing' && (Boolean(this.damage?.main) || !foundry.utils.isEmpty(this.damage?.resources));
return this.type !== 'healing' && (Boolean(this.damage?.main) || Object.keys(this.damage?.resources ?? {}).length);
}
get hasHealing() {
return this.type === 'healing' && !foundry.utils.isEmpty(this.damage?.resources);
return this.type === 'healing' && Object.keys(this.damage?.resources ?? {}).length;
}
get hasSave() {