34 lines
724 B
JavaScript
34 lines
724 B
JavaScript
import AspectItem from "./Aspect.mjs";
|
|
import SpellItem from "./Spell.mjs";
|
|
|
|
/** @extends {Item} */
|
|
export class ItemHandler extends Item {
|
|
proxyTargets = {
|
|
aspect: AspectItem,
|
|
spell: SpellItem
|
|
};
|
|
|
|
constructor(data, ctx) {
|
|
super(data, ctx);
|
|
};
|
|
|
|
/** @type {class|undefined} */
|
|
get fn() {
|
|
return this.proxyTargets[this.type];
|
|
};
|
|
|
|
async migrateSystemData() {
|
|
if (!this.fn?.migrateSystemData) return;
|
|
this.fn?.migrateSystemData.bind(this)();
|
|
};
|
|
|
|
async proxyFunction(funcName, ...args) {
|
|
if (!this.fn?.[funcName]) return;
|
|
return await this.fn?.[funcName].bind(this)(...args);
|
|
};
|
|
|
|
async _preCreate(...args) {
|
|
if (!this.fn?._preCreate) return;
|
|
return this.fn?._preCreate.bind(this)(...args);
|
|
};
|
|
};
|