index.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { Castor } from './Castor';
  2. import type { Character, CharacterStats } from './Character';
  3. import { Chat } from './Chat';
  4. import { Gege } from './Gege';
  5. import { Leon } from './Leon';
  6. import { Generic } from './Generic';
  7. import { Magicien } from './Magicien';
  8. import { Mamie } from './Mamie';
  9. import { Pompier } from './Pompier';
  10. import { Prout } from './Prout';
  11. import { Pyromanchot } from './Pyromanchot';
  12. import { Tatie } from './Tatie';
  13. // Menu order (readme §4 table), then the test character.
  14. const registry: Record<string, new (stats: CharacterStats) => Character> = {
  15. castor: Castor,
  16. mamie: Mamie,
  17. pyromanchot: Pyromanchot,
  18. gege: Gege,
  19. pompier: Pompier,
  20. prout: Prout,
  21. chat: Chat,
  22. magicien: Magicien,
  23. tatie: Tatie,
  24. leon: Leon,
  25. generic: Generic,
  26. };
  27. /** Characters offered to players (the test character is for development only). */
  28. export const PLAYABLE_CHARACTER_IDS = Object.keys(registry).filter((id) => id !== 'generic');
  29. /** Ids of playable characters, in menu order. */
  30. export const CHARACTER_IDS = Object.keys(registry);
  31. export function isCharacterId(id: string): boolean {
  32. return Object.hasOwn(registry, id);
  33. }
  34. export function createCharacter(stats: CharacterStats): Character {
  35. const ctor = registry[stats.id];
  36. if (!ctor) throw new Error(`Unknown character "${stats.id}"`);
  37. return new ctor(stats);
  38. }
  39. export { Anim, Character, parseCharacterStats } from './Character';
  40. export type { Blast, CharacterContext, CharacterCue, CharacterStats, ProjectileSpec, Spell, TurretSpec } from './Character';