refactor: replace 97 any types in fight system with Fighter/GameObj

- fighter: any → Fighter in entrances, morphs, finishers, rounds, types
- any[] → GameObj[] for spawned game objects across all choreography files
- as any cast in particles.ts replaced with closure variables
- Record<string, unknown> for morph sprite opts
- this: any → this: GameObj in basic choreography callback

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-09 06:26:33 +00:00
co-authored by Claude Opus 4.6
parent 81048ff22f
commit a86d39b982
13 changed files with 90 additions and 77 deletions
+9 -8
View File
@@ -1,4 +1,5 @@
import type { ChoreoContext } from './types'
import type { GameObj } from 'kaplay'
import type { Fighter, ChoreoContext } from './types'
import { generateSpriteSheet, MAX_FRAMES, TOTAL_ROWS, type SpriteCustomization } from '../sprites'
import { spriteAnims } from './constants'
import { announceHype } from '../audio'
@@ -14,14 +15,14 @@ interface MorphDeps {
colorsB: { primary: string; secondary: string }
isHumanA: boolean
isHumanB: boolean
loadSpriteWithTimeout: (name: string, src: string, opts: any) => Promise<void>
loadSpriteWithTimeout: (name: string, src: string, opts: Record<string, unknown>) => Promise<void>
}
export function createMorphSystem(ctx: ChoreoContext, deps: MorphDeps) {
const { k, safeColor, screenFlash, spawnShockwave, glitchRGB, sfxZoomWhoosh, sfxSpecial, theme } = ctx
const { botA, botB, colorsA, colorsB, isHumanA, isHumanB, loadSpriteWithTimeout } = deps
interface MorphOverlay { obj: any; type: string }
interface MorphOverlay { obj: GameObj; type: string }
let activeMorphs: MorphOverlay[] = []
function destroyMorphOverlays() {
@@ -30,7 +31,7 @@ function destroyMorphOverlays() {
}
// Morph 0: ELEMENTAL — fire/ice/electric aura wraps around the fighter
function applyElementalMorph(fighter: any, side: 'a' | 'b') {
function applyElementalMorph(fighter: Fighter, side: 'a' | 'b') {
const seed = side === 'a' ? botA.seed : botB.seed
let h = 0
for (let i = 0; i < seed.length; i++) h = ((h << 5) - h + seed.charCodeAt(i)) | 0
@@ -88,7 +89,7 @@ function applyElementalMorph(fighter: any, side: 'a' | 'b') {
}
// Morph 1: MECH — armor plates, wings/jets, metallic overlay
function applyMechMorph(fighter: any, _side: 'a' | 'b') {
function applyMechMorph(fighter: Fighter, _side: 'a' | 'b') {
const dir = fighter.scale.x > 0 ? 1 : -1
// Shoulder armor plates
@@ -152,7 +153,7 @@ function applyMechMorph(fighter: any, _side: 'a' | 'b') {
}
// Morph 2: BEAST — grows horns/tail/claws, goes wild
function applyBeastMorph(fighter: any, side: 'a' | 'b') {
function applyBeastMorph(fighter: Fighter, side: 'a' | 'b') {
const dir = fighter.scale.x > 0 ? 1 : -1
const seed = side === 'a' ? botA.seed : botB.seed
let h = 0
@@ -255,7 +256,7 @@ const OMNI_MORPH_ARCHETYPES = [
let omniMorphCounter = 0
async function applyCreatorOmniMorph(fighter: any, side: 'a' | 'b'): Promise<string> {
async function applyCreatorOmniMorph(fighter: Fighter, side: 'a' | 'b'): Promise<string> {
const pick = OMNI_MORPH_ARCHETYPES[Math.floor(Math.random() * OMNI_MORPH_ARCHETYPES.length)]
// Generate and load a sprite sheet for the picked archetype
@@ -346,7 +347,7 @@ function getMorphOrder(seed: string): number[] {
return orders[Math.abs(h) % 6]
}
async function playMorph(fighter: any, side: 'a' | 'b', morphIndex: number) {
async function playMorph(fighter: Fighter, side: 'a' | 'b', morphIndex: number) {
const savedScaleX = fighter.scale.x
const savedScaleY = fighter.scale.y
const isHumanFighter = side === 'a' ? isHumanA : isHumanB