23 lines
782 B
TypeScript
23 lines
782 B
TypeScript
// SPDX-FileCopyrightText: 2022 Johannes Loher
|
|
//
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import { getGame } from "../helpers";
|
|
import { DS4Actor } from "./actor";
|
|
import { DS4Character } from "./character/character";
|
|
import { DS4Creature } from "./creature/creature";
|
|
|
|
const handler = {
|
|
construct(_: typeof DS4Actor, args: ConstructorParameters<typeof DS4Actor>) {
|
|
switch (args[0]?.type) {
|
|
case "character":
|
|
return new DS4Character(...args);
|
|
case "creature":
|
|
return new DS4Creature(...args);
|
|
default:
|
|
throw new Error(getGame().i18n.format("DS4.ErrorInvalidActorType", { type: args[0]?.type }));
|
|
}
|
|
},
|
|
};
|
|
|
|
export const DS4ActorProxy: typeof DS4Actor = new Proxy(DS4Actor, handler);
|