refactor: extract shared FightData interface to fight/types.ts
Move FightData, FightRound, FightBot, FightArenaInfo types from local definitions in FightViewer.vue to shared fight/types.ts. Replace `any` typing in HumanFightPage, FightPage, useFightPolling, and useFightCache with proper typed interfaces. Fix null-safety guards exposed by typing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
2f7c10e4b8
commit
945a776a5a
@@ -2,6 +2,8 @@ import type kaplay from 'kaplay'
|
||||
import type { GameObj, SpriteComp, PosComp, ScaleComp, AnchorComp, OpacityComp, ColorComp, RotateComp, ZComp } from 'kaplay'
|
||||
import type { SpriteCustomization } from '../sprites'
|
||||
|
||||
export type { SpriteCustomization }
|
||||
|
||||
export type Fighter = GameObj<SpriteComp | PosComp | ScaleComp | AnchorComp | OpacityComp | ColorComp | RotateComp | ZComp>
|
||||
|
||||
export type KaplayInstance = ReturnType<typeof kaplay>
|
||||
@@ -85,3 +87,56 @@ export interface RoundEvent {
|
||||
botAResponse?: string
|
||||
botBResponse?: string
|
||||
}
|
||||
|
||||
// --- Shared fight data types (used across pages & composables) ---
|
||||
|
||||
export interface FightRound {
|
||||
roundNumber: number
|
||||
challengeType: string
|
||||
challengeData: string
|
||||
botAResponse: string | null
|
||||
botATimeMs: number | null
|
||||
botAScore: number | null
|
||||
botBResponse: string | null
|
||||
botBTimeMs: number | null
|
||||
botBScore: number | null
|
||||
winnerId: string | null
|
||||
narration: string | null
|
||||
}
|
||||
|
||||
export interface FightBot {
|
||||
id: string
|
||||
name: string
|
||||
avatarSeed: string
|
||||
archetype?: string
|
||||
customization?: SpriteCustomization | null
|
||||
profilePicUrl?: string | null
|
||||
eloRating: number
|
||||
wins: number
|
||||
losses: number
|
||||
tier: number
|
||||
botType?: string
|
||||
}
|
||||
|
||||
export interface FightArenaInfo {
|
||||
id: string
|
||||
name: string
|
||||
description: string
|
||||
modifier: string | null
|
||||
}
|
||||
|
||||
export interface FightData {
|
||||
id: string
|
||||
botAId: string
|
||||
botBId: string
|
||||
botA: FightBot | null
|
||||
botB: FightBot | null
|
||||
arenaInfo: FightArenaInfo | null
|
||||
arena: string
|
||||
winnerId: string | null
|
||||
botAHp: number
|
||||
botBHp: number
|
||||
totalRounds: number
|
||||
status: string
|
||||
rounds: FightRound[]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user