mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
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:
parent
eac58c1386
commit
e9ad9c539a
58 changed files with 1146 additions and 1114 deletions
|
|
@ -1,5 +1,3 @@
|
|||
import { actionsTypes } from '../action/_module.mjs';
|
||||
|
||||
/**
|
||||
* Describes metadata about the item data model type
|
||||
* @typedef {Object} ItemDataModelMetadata
|
||||
|
|
@ -61,8 +59,8 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
|
|||
if (!this.constructor.metadata.hasInitialAction || !foundry.utils.isEmpty(this.actions)) return;
|
||||
|
||||
const metadataType = this.constructor.metadata.type;
|
||||
const actionType = { weapon: "attack" }[metadataType];
|
||||
const ActionClass = actionsTypes[actionType];
|
||||
const actionType = { weapon: 'attack' }[metadataType];
|
||||
const ActionClass = game.system.api.models.actions.actionsTypes[actionType];
|
||||
|
||||
const action = new ActionClass(
|
||||
{
|
||||
|
|
@ -79,4 +77,31 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
|
|||
this.updateSource({ actions: [action] });
|
||||
}
|
||||
|
||||
_onCreate(data) {
|
||||
if (!this.actor || this.actor.type !== 'character' || !this.features) return;
|
||||
|
||||
this.actor.createEmbeddedDocuments(
|
||||
'Item',
|
||||
this.features.map(feature => ({
|
||||
...feature,
|
||||
system: {
|
||||
...feature.system,
|
||||
type: this.parent.type,
|
||||
originId: data._id,
|
||||
identifier: feature.identifier
|
||||
}
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
async _preDelete() {
|
||||
if (!this.actor || this.actor.type !== 'character') return;
|
||||
|
||||
const items = this.actor.items.filter(item => item.system.originId === this.parent.id);
|
||||
if (items.length > 0)
|
||||
await this.actor.deleteEmbeddedDocuments(
|
||||
'Item',
|
||||
items.map(x => x.id)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue