import { ChapterNewPlayTypeEnum, type ChapterPlayData } from '../../game/ChapterPlayTypes'; import type { IBattleMechanism } from './IBattleMechanism'; import { WitchMechanism } from './implementations/WitchMechanism'; import { ParatroopsMechanism } from './implementations/ParatroopsMechanism'; import { BloodMoonMechanism } from './implementations/BloodMoonMechanism'; import { SpiderSpiritMechanism } from './implementations/SpiderSpiritMechanism'; import { CharmMechanism } from './implementations/CharmMechanism'; type MechanismFactory = () => IBattleMechanism; const FACTORIES = new Map([ [ChapterNewPlayTypeEnum.Witch, () => new WitchMechanism()], [ChapterNewPlayTypeEnum.Paratroops, () => new ParatroopsMechanism()], [ChapterNewPlayTypeEnum.BossAirdrop, () => new ParatroopsMechanism(ChapterNewPlayTypeEnum.BossAirdrop)], [ChapterNewPlayTypeEnum.BloodMoon, () => new BloodMoonMechanism()], [ChapterNewPlayTypeEnum.VinesGrass, () => new SpiderSpiritMechanism()], [ChapterNewPlayTypeEnum.Charm, () => new CharmMechanism()], ]); export function createMechanismsForPlayIds(playIds: number[]): IBattleMechanism[] { const list: IBattleMechanism[] = []; for (const rawId of playIds) { const id = rawId as ChapterNewPlayTypeEnum; const factory = FACTORIES.get(id); if (!factory) continue; list.push(factory()); } return list; } export function resolveMechanismConfig(typeId: ChapterNewPlayTypeEnum): ChapterPlayData | undefined { return gg.data.project.getChapterNewPlayInfo(typeId); }