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
@@ -14,34 +14,7 @@ import {
|
||||
} from '../game/audio'
|
||||
import { isKokoroLoading, getKokoroProgress } from '../game/tts'
|
||||
import { isPerfMode, setPerfMode } from '../game/fight/config'
|
||||
|
||||
interface Round {
|
||||
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
|
||||
}
|
||||
|
||||
interface FightData {
|
||||
id: string
|
||||
botA: { id: string; name: string; avatarSeed: string; archetype?: string; customization?: Record<string, unknown> | null; profilePicUrl?: string | null; eloRating: number; wins: number; losses: number; tier: number; botType?: string } | null
|
||||
botB: { id: string; name: string; avatarSeed: string; archetype?: string; customization?: Record<string, unknown> | null; profilePicUrl?: string | null; eloRating: number; wins: number; losses: number; tier: number; botType?: string } | null
|
||||
arenaInfo: { id: string; name: string; description: string; modifier: string | null } | null
|
||||
arena: string
|
||||
winnerId: string | null
|
||||
botAHp: number
|
||||
botBHp: number
|
||||
totalRounds: number
|
||||
status: string
|
||||
rounds: Round[]
|
||||
}
|
||||
import type { FightData, FightRound } from '../game/fight/types'
|
||||
|
||||
const props = defineProps<{ fight: FightData; autoplay?: boolean }>()
|
||||
const emit = defineEmits<{ 'replay-done': [] }>()
|
||||
@@ -297,7 +270,7 @@ async function showHitText(text: string, color: string, x: number) {
|
||||
hitTextVisible.value = false
|
||||
}
|
||||
|
||||
function addRoundToLog(round: Round, stagger: boolean): Promise<void> {
|
||||
function addRoundToLog(round: FightRound, stagger: boolean): Promise<void> {
|
||||
if (!stagger) {
|
||||
const challenge = JSON.parse(round.challengeData)
|
||||
logItems.value.push(
|
||||
|
||||
Reference in New Issue
Block a user