mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
[BUG] Feature Actions/Effects Lost On Creation (#457)
* Fixed so that features get their actions and effects * . * Refactor features creations --------- Co-authored-by: Joaquin Pereyra <joaquinpereyra98@users.noreply.github.com>
This commit is contained in:
parent
2c4d3bd4a3
commit
18fac18df3
2 changed files with 24 additions and 27 deletions
|
|
@ -123,26 +123,21 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
|
|||
|
||||
this.updateSource({ actions: [action] });
|
||||
}
|
||||
}
|
||||
|
||||
_onCreate(data, _, userId) {
|
||||
if (userId !== game.user.id) return;
|
||||
|
||||
if (!this.actor || this.actor.type !== 'character' || !this.features) return;
|
||||
|
||||
this.actor.createEmbeddedDocuments(
|
||||
'Item',
|
||||
this.features.map(feature => ({
|
||||
...(feature.item ?? feature),
|
||||
system: {
|
||||
...(feature.item?.system ?? feature.system),
|
||||
originItemType: this.parent.type,
|
||||
originId: data._id,
|
||||
identifier: feature.identifier,
|
||||
subType: feature.item ? feature.type : undefined
|
||||
}
|
||||
}))
|
||||
);
|
||||
if (this.actor && this.actor.type === 'character' && this.features) {
|
||||
for (let f of this.features) {
|
||||
const feature = f.item ?? f;
|
||||
const createData = foundry.utils.mergeObject(feature.toObject(), {
|
||||
system: {
|
||||
originItemType: this.parent.type,
|
||||
originId: data._id,
|
||||
identifier: feature.identifier,
|
||||
subType: feature.item ? feature.type : undefined
|
||||
}
|
||||
}, { inplace: false });
|
||||
await this.actor.createEmbeddedDocuments('Item', [createData]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async _preDelete() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue