[Fix] Downtime Actions (#1295)

* Fixed so downtime actiosn can be used again

* Update module/data/fields/action/targetField.mjs

Co-authored-by: Carlos Fernandez <CarlosFdez@users.noreply.github.com>

* .

---------

Co-authored-by: Carlos Fernandez <CarlosFdez@users.noreply.github.com>
This commit is contained in:
WBHarry 2025-11-17 10:17:22 +01:00 committed by GitHub
parent fe8e98ef35
commit b9d67e44da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 86 additions and 32 deletions

View file

@ -17,6 +17,16 @@ const targetsField = () =>
})
);
export const originItemField = () =>
new fields.SchemaField({
type: new fields.StringField({
choices: CONFIG.DH.ITEM.originItemType,
initial: CONFIG.DH.ITEM.originItemType.itemCollection
}),
itemPath: new fields.StringField(),
actionIndex: new fields.StringField()
});
export default class DHActorRoll extends foundry.abstract.TypeDataModel {
static defineSchema() {
return {
@ -35,6 +45,7 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel {
source: new fields.SchemaField({
actor: new fields.StringField(),
item: new fields.StringField(),
originItem: originItemField(),
action: new fields.StringField()
}),
damage: new fields.ObjectField(),
@ -51,14 +62,23 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel {
get actionItem() {
const actionActor = this.actionActor;
if (!actionActor || !this.source.item) return null;
return actionActor.items.get(this.source.item);
switch (this.source.originItem.type) {
case CONFIG.DH.ITEM.originItemType.restMove:
const restMoves = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).restMoves;
return Array.from(foundry.utils.getProperty(restMoves, `${this.source.originItem.itemPath}`).actions)[
this.source.originItem.actionIndex
];
default:
const item = actionActor.items.get(this.source.item);
return item ? item.system.actionsList?.find(a => a.id === this.source.action) : null;
}
}
get action() {
const actionActor = this.actionActor,
actionItem = this.actionItem;
const { actionActor, actionItem: itemAction } = this;
if (!this.source.action) return null;
if (actionItem) return actionItem.system.actionsList?.find(a => a.id === this.source.action);
if (itemAction) return itemAction;
else if (actionActor?.system.attack?._id === this.source.action) return actionActor.system.attack;
return null;
}