264 - Action Feature Swap (#265)

* Removed action fields on Adversary/Environment in favor of using Feature Items

* Added drag/drop for features onto adversary/environment settings

* Added Drag of features from Adversary/Environment settings to anywhere in Foundry

* Updated all item types except Class/Subclass

* Added for Class/Subclass

* Items now copy over their features to Character

* Corrected back to actions for right items

* Fixed adversary/environment features display

* PR Fixes
This commit is contained in:
WBHarry 2025-07-05 22:35:05 +02:00 committed by GitHub
parent eac58c1386
commit e9ad9c539a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
58 changed files with 1146 additions and 1114 deletions

View file

@ -29,19 +29,19 @@ export default class AdversarySheet extends DaggerheartSheet(ActorSheetV2) {
static PARTS = {
sidebar: { template: 'systems/daggerheart/templates/sheets/actors/adversary/sidebar.hbs' },
header: { template: 'systems/daggerheart/templates/sheets/actors/adversary/header.hbs' },
actions: { template: 'systems/daggerheart/templates/sheets/actors/adversary/actions.hbs' },
features: { template: 'systems/daggerheart/templates/sheets/actors/adversary/features.hbs' },
notes: { template: 'systems/daggerheart/templates/sheets/actors/adversary/notes.hbs' },
effects: { template: 'systems/daggerheart/templates/sheets/actors/adversary/effects.hbs' }
};
static TABS = {
actions: {
features: {
active: true,
cssClass: '',
group: 'primary',
id: 'actions',
id: 'features',
icon: null,
label: 'DAGGERHEART.General.tabs.actions'
label: 'DAGGERHEART.General.tabs.features'
},
notes: {
active: false,
@ -71,9 +71,9 @@ export default class AdversarySheet extends DaggerheartSheet(ActorSheetV2) {
return context;
}
getAction(element) {
getItem(element) {
const itemId = (element.target ?? element).closest('[data-item-id]').dataset.itemId,
item = this.document.system.actions.find(x => x.id === itemId);
item = this.document.items.get(itemId);
return item;
}
@ -109,7 +109,7 @@ export default class AdversarySheet extends DaggerheartSheet(ActorSheetV2) {
}
static async useItem(event) {
const action = this.getAction(event) ?? this.actor.system.attack;
const action = this.getItem(event) ?? this.actor.system.attack;
action.use(event);
}
@ -135,7 +135,7 @@ export default class AdversarySheet extends DaggerheartSheet(ActorSheetV2) {
cls.create(msg.toObject());
} else {
const item = this.getAction(event) ?? this.document.system.attack;
const item = this.getItem(event) ?? this.document.system.attack;
item.toChat(this.document.id);
}
}

View file

@ -307,12 +307,12 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
getItem(element) {
const listElement = (element.target ?? element).closest('[data-item-id]');
const itemId = listElement.dataset.itemId;
if (listElement.dataset.type === 'effect') {
return this.document.effects.get(itemId);
} else if (['armor', 'weapon', 'feature', 'consumable', 'miscellaneous'].includes(listElement.dataset.type)) {
return this.document.items.get(itemId);
} else {
return this.document.system[listElement.dataset.type].system.actions.find(x => x.id === itemId);
switch (listElement.dataset.type) {
case 'effect':
return this.document.effects.get(itemId);
default:
return this.document.items.get(itemId);
}
}

View file

@ -26,7 +26,7 @@ export default class DhpEnvironment extends DaggerheartSheet(ActorSheetV2) {
static PARTS = {
header: { template: 'systems/daggerheart/templates/sheets/actors/environment/header.hbs' },
actions: { template: 'systems/daggerheart/templates/sheets/actors/environment/actions.hbs' },
features: { template: 'systems/daggerheart/templates/sheets/actors/environment/features.hbs' },
potentialAdversaries: {
template: 'systems/daggerheart/templates/sheets/actors/environment/potentialAdversaries.hbs'
},
@ -34,13 +34,13 @@ export default class DhpEnvironment extends DaggerheartSheet(ActorSheetV2) {
};
static TABS = {
actions: {
features: {
active: true,
cssClass: '',
group: 'primary',
id: 'actions',
id: 'features',
icon: null,
label: 'DAGGERHEART.General.tabs.actions'
label: 'DAGGERHEART.General.tabs.features'
},
potentialAdversaries: {
active: false,
@ -69,9 +69,9 @@ export default class DhpEnvironment extends DaggerheartSheet(ActorSheetV2) {
return context;
}
getAction(element) {
getItem(element) {
const itemId = (element.target ?? element).closest('[data-item-id]').dataset.itemId,
item = this.document.system.actions.find(x => x.id === itemId);
item = this.document.items.get(itemId);
return item;
}
@ -114,7 +114,7 @@ export default class DhpEnvironment extends DaggerheartSheet(ActorSheetV2) {
}
static async useItem(event, button) {
const action = this.getAction(event);
const action = this.getItem(event);
if (!action) {
await this.viewAdversary(event, button);
} else {
@ -123,7 +123,7 @@ export default class DhpEnvironment extends DaggerheartSheet(ActorSheetV2) {
}
static async toChat(event) {
const item = this.getAction(event);
const item = this.getItem(event);
item.toChat(this.document.id);
}