All files / web/src/arcade-games/complement-race index.tsx

0% Statements 0/84
0% Branches 0/1
0% Functions 0/1
0% Lines 0/84

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85                                                                                                                                                                         
/**
 * Complement Race - Modular Game Definition
 * Complete integration into the arcade system with multiplayer support
 */

import { defineGame, getGameTheme } from '@/lib/arcade/game-sdk'
import type { GameManifest } from '@/lib/arcade/game-sdk'
import { complementRaceValidator } from './Validator'
import { ComplementRaceProvider } from './Provider'
import { GameComponent } from './components/GameComponent'
import type { ComplementRaceConfig, ComplementRaceState, ComplementRaceMove } from './types'

// Game manifest
const manifest: GameManifest = {
  name: 'complement-race',
  displayName: 'Speed Complement Race 🏁',
  description: 'Race against opponents while solving complement problems',
  longDescription:
    'Battle AI opponents or real players in an epic math race! Find complement numbers (friends of 5 and 10) to build momentum and speed ahead. Choose from three exciting modes: Practice (linear race), Sprint (train journey with passengers), or Survival (infinite laps). Perfect for multiplayer competition!',
  maxPlayers: 4,
  icon: '🏁',
  chips: ['👥 1-4 Players', '🚂 Sprint Mode', '🤖 AI Opponents', '🔥 Speed Challenge'],
  ...getGameTheme('blue'),
  difficulty: 'Intermediate',
  available: true,
  practiceBreakReady: false,
  coPlay: { mode: 'none' },
}

// Default configuration
const defaultConfig: ComplementRaceConfig = {
  style: 'practice',
  mode: 'mixed',
  complementDisplay: 'random',
  timeoutSetting: 'normal',
  enableAI: true,
  aiOpponentCount: 2,
  maxPlayers: 4,
  routeDuration: 60,
  enablePassengers: true,
  passengerCount: 6,
  maxConcurrentPassengers: 3,
  raceGoal: 20,
  winCondition: 'infinite', // Sprint mode is infinite by default (Steam Sprint)
  routeCount: 3,
  targetScore: 100,
  timeLimit: 300,
}

// Config validation function
function validateComplementRaceConfig(config: unknown): config is ComplementRaceConfig {
  const c = config as any
  return (
    typeof c === 'object' &&
    c !== null &&
    ['practice', 'sprint', 'survival'].includes(c.style) &&
    ['friends5', 'friends10', 'mixed'].includes(c.mode) &&
    typeof c.maxPlayers === 'number' &&
    c.maxPlayers >= 1 &&
    c.maxPlayers <= 4
  )
}

// Export game definition with proper generics
export const complementRaceGame = defineGame<
  ComplementRaceConfig,
  ComplementRaceState,
  ComplementRaceMove
>({
  manifest,
  Provider: ComplementRaceProvider,
  GameComponent,
  validator: complementRaceValidator,
  defaultConfig,
  validateConfig: validateComplementRaceConfig,
})

// Re-export types for convenience
export type {
  ComplementRaceConfig,
  ComplementRaceState,
  ComplementRaceMove,
} from './types'
export { complementRaceValidator } from './Validator'