fix(complement-race): resolve TypeScript errors in state adapter

Fixes TypeScript compilation errors that prevented dev server from starting.

## Issues Fixed

1. **Provider.tsx - gamePhase type mismatch**
   - Added explicit type annotation for gamePhase variable
   - Properly maps multiplayer phases (setup/lobby) to single-player phases (controls)

2. **Provider.tsx - timeLimit undefined handling**
   - Convert undefined to null: `timeLimit ?? null`
   - Matches CompatibleGameState interface expectation

3. **Provider.tsx - difficultyTracker type**
   - Import DifficultyTracker type from gameTypes
   - Replace `any` with proper DifficultyTracker type
   - Fixes unknown type errors in useAdaptiveDifficulty hook

4. **useSteamJourney.ts - index signature error**
   - Add type assertion: `as keyof typeof MOMENTUM_DECAY_RATES`
   - Fixes "no index signature" error when accessing decay rates

## Verification
-  TypeScript: Zero compilation errors
-  Format: Biome passes
-  Lint: No new warnings

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Thomas Hallock
2025-10-16 12:09:40 -05:00
parent 2a9a49b6f2
commit 59abcca4c4
2 changed files with 18 additions and 7 deletions

View File

@@ -78,7 +78,9 @@ export function useSteamJourney() {
// Steam Sprint is infinite - no time limit
// Get decay rate based on timeout setting (skill level)
const decayRate = MOMENTUM_DECAY_RATES[state.timeoutSetting] || MOMENTUM_DECAY_RATES.normal
const decayRate =
MOMENTUM_DECAY_RATES[state.timeoutSetting as keyof typeof MOMENTUM_DECAY_RATES] ||
MOMENTUM_DECAY_RATES.normal
// Calculate momentum decay for this frame
const momentumLoss = (decayRate * deltaTime) / 1000

View File

@@ -16,6 +16,7 @@ import {
useViewerId,
} from '@/lib/arcade/game-sdk'
import { DEFAULT_COMPLEMENT_RACE_CONFIG } from '@/lib/arcade/game-configs'
import type { DifficultyTracker } from '@/app/arcade/complement-race/lib/gameTypes'
import type { ComplementRaceConfig, ComplementRaceMove, ComplementRaceState } from './types'
/**
@@ -43,7 +44,7 @@ interface CompatibleGameState {
// Game status
isGameActive: boolean
isPaused: boolean
gamePhase: string
gamePhase: 'intro' | 'controls' | 'countdown' | 'playing' | 'results'
// Timing
gameStartTime: number | null
@@ -79,8 +80,8 @@ interface CompatibleGameState {
// UI state
showScoreModal: boolean
activeSpeechBubbles: Map<string, string>
adaptiveFeedback: any | null
difficultyTracker: any
adaptiveFeedback: { message: string; type: string } | null
difficultyTracker: DifficultyTracker
}
/**
@@ -244,8 +245,16 @@ export function ComplementRaceProvider({ children }: { children: ReactNode }) {
const localPlayer = localPlayerId ? multiplayerState.players[localPlayerId] : null
// Map gamePhase: setup/lobby -> controls
let gamePhase = multiplayerState.gamePhase
if (gamePhase === 'setup' || gamePhase === 'lobby') {
let gamePhase: 'intro' | 'controls' | 'countdown' | 'playing' | 'results'
if (multiplayerState.gamePhase === 'setup' || multiplayerState.gamePhase === 'lobby') {
gamePhase = 'controls'
} else if (multiplayerState.gamePhase === 'countdown') {
gamePhase = 'countdown'
} else if (multiplayerState.gamePhase === 'playing') {
gamePhase = 'playing'
} else if (multiplayerState.gamePhase === 'results') {
gamePhase = 'results'
} else {
gamePhase = 'controls'
}
@@ -280,7 +289,7 @@ export function ComplementRaceProvider({ children }: { children: ReactNode }) {
// Race mechanics
raceGoal: multiplayerState.config.raceGoal,
timeLimit: multiplayerState.config.timeLimit,
timeLimit: multiplayerState.config.timeLimit ?? null,
speedMultiplier: 1.0,
aiRacers: multiplayerState.aiOpponents.map((ai) => ({
id: ai.id,