index.ts 995 B

1234567891011121314151617181920212223242526272829
  1. import { Castor } from './Castor';
  2. import type { Character, CharacterStats } from './Character';
  3. import { Generic } from './Generic';
  4. import { Mamie } from './Mamie';
  5. import { Pyromanchot } from './Pyromanchot';
  6. // Menu order: the three M5 characters, then the test character.
  7. const registry: Record<string, new (stats: CharacterStats) => Character> = {
  8. castor: Castor,
  9. mamie: Mamie,
  10. pyromanchot: Pyromanchot,
  11. generic: Generic,
  12. };
  13. /** Ids of playable characters, in menu order. */
  14. export const CHARACTER_IDS = Object.keys(registry);
  15. export function isCharacterId(id: string): boolean {
  16. return Object.hasOwn(registry, id);
  17. }
  18. export function createCharacter(stats: CharacterStats): Character {
  19. const ctor = registry[stats.id];
  20. if (!ctor) throw new Error(`Unknown character "${stats.id}"`);
  21. return new ctor(stats);
  22. }
  23. export { Anim, Character, parseCharacterStats } from './Character';
  24. export type { Blast, CharacterContext, CharacterStats, ProjectileSpec } from './Character';