From 81048ff22fd9e1de77feb23137e2dd4174a834b0 Mon Sep 17 00:00:00 2001 From: Dorian Date: Mon, 9 Mar 2026 06:21:06 +0000 Subject: [PATCH] fix: make vhsTracking accept ChoreoContext directly, remove as any cast Effect functions now accept FightContext | ChoreoContext union type, eliminating the unsafe cast in rounds.ts. Co-Authored-By: Claude Opus 4.6 --- frontend/src/game/fight/effects.ts | 12 +++++++----- frontend/src/game/fight/rounds.ts | 3 +-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/frontend/src/game/fight/effects.ts b/frontend/src/game/fight/effects.ts index 39acf94..57788c6 100644 --- a/frontend/src/game/fight/effects.ts +++ b/frontend/src/game/fight/effects.ts @@ -1,7 +1,9 @@ import type { GameObj } from 'kaplay' -import type { FightContext } from './types' +import type { FightContext, ChoreoContext } from './types' -export function glitchRGB(ctx: FightContext, duration: number = 0.2): void { +type EffectContext = FightContext | ChoreoContext + +export function glitchRGB(ctx: EffectContext, duration: number = 0.2): void { const { k, W, H, safeColor, trackedTimeout } = ctx const layers = [ { color: '#ff0000', dx: 4 + Math.random() * 6, dy: -2 }, @@ -20,7 +22,7 @@ export function glitchRGB(ctx: FightContext, duration: number = 0.2): void { } } -export function scanlineGlitch(ctx: FightContext, duration: number = 0.3): void { +export function scanlineGlitch(ctx: EffectContext, duration: number = 0.3): void { const { k, W, H, safeColor } = ctx const lines: GameObj[] = [] const count = 6 + Math.floor(Math.random() * 8) @@ -41,7 +43,7 @@ export function scanlineGlitch(ctx: FightContext, duration: number = 0.3): void ctx.trackedTimeout(() => { lines.forEach(l => { if (l.exists()) l.destroy() }) }, duration * 1000) } -export function vhsTracking(ctx: FightContext, duration: number = 0.4): void { +export function vhsTracking(ctx: EffectContext, duration: number = 0.4): void { const { k, W, H, safeColor, theme } = ctx const bands: GameObj[] = [] const bandCount = 3 @@ -61,7 +63,7 @@ export function vhsTracking(ctx: FightContext, duration: number = 0.4): void { ctx.trackedTimeout(() => { bands.forEach(b => { if (b.exists()) b.destroy() }) }, duration * 1000) } -export function dimensionalShift(ctx: FightContext, duration: number = 0.6): void { +export function dimensionalShift(ctx: EffectContext, duration: number = 0.6): void { const { k, W, H, safeColor, trackedInterval, trackedTimeout, clearTracked } = ctx const colors = ['#ff00ff', '#00ffff', '#ff0000', '#0000ff', '#ffff00'] let idx = 0 diff --git a/frontend/src/game/fight/rounds.ts b/frontend/src/game/fight/rounds.ts index d463955..7673469 100644 --- a/frontend/src/game/fight/rounds.ts +++ b/frontend/src/game/fight/rounds.ts @@ -64,9 +64,8 @@ export function createRoundSystem(ctx: ChoreoContext, deps: RoundDeps) { showSpeechBubble, } = deps - // Local vhsTracking wrapper — effects.ts expects FightContext, pass ctx as compatible function vhsTracking(duration?: number) { - _vhsTracking(ctx as any, duration) + _vhsTracking(ctx, duration) } const heartfeltLines = [