refactor: improve embedded document creation
This commit is contained in:
parent
eb2bbe1282
commit
8f3a72a7f4
2 changed files with 5 additions and 4 deletions
|
@ -92,14 +92,15 @@ export class DS4ActiveEffect extends ActiveEffect {
|
||||||
/**
|
/**
|
||||||
* Create a new {@link DS4ActiveEffect} using default data.
|
* Create a new {@link DS4ActiveEffect} using default data.
|
||||||
*
|
*
|
||||||
* @param context The context for the creation of the effect, requiring a parent {@link DS4Actor} or {@link DS4Item}.
|
* @param parent The parent {@link DS4Actor} or {@link DS4Item} of the effect.
|
||||||
* @returns A promise that resolved to the created effect or udifined of the creation was prevented.
|
* @returns A promise that resolved to the created effect or udifined of the creation was prevented.
|
||||||
*/
|
*/
|
||||||
static async createDefault(parent: DS4Actor | DS4Item): Promise<DS4ActiveEffect[]> {
|
static async createDefault(parent: DS4Actor | DS4Item): Promise<DS4ActiveEffect | undefined> {
|
||||||
const createData = {
|
const createData = {
|
||||||
label: getGame().i18n.localize(`DS4.NewEffectLabel`),
|
label: getGame().i18n.localize(`DS4.NewEffectLabel`),
|
||||||
icon: this.FALLBACK_ICON,
|
icon: this.FALLBACK_ICON,
|
||||||
};
|
};
|
||||||
return parent.createEmbeddedDocuments("ActiveEffect", [createData]) as Promise<DS4ActiveEffect[]>;
|
|
||||||
|
return this.create(createData, { parent, pack: parent.pack ?? undefined });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,7 +141,7 @@ export class DS4ActorSheet extends ActorSheet<ActorSheet.Options, DS4ActorSheetD
|
||||||
type: type,
|
type: type,
|
||||||
data: data,
|
data: data,
|
||||||
};
|
};
|
||||||
this.actor.createEmbeddedDocuments("Item", [itemData]);
|
Item.create(itemData, { parent: this.actor, pack: this.actor.pack ?? undefined });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue