All files / web/src/lib/arcade game-configs.ts

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

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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157                                                                                                                                                                                                                                                                                                                         
/**
 * Shared game configuration types
 *
 * All config types are defined using Zod schemas in each game's types.ts file.
 * This file re-exports them for centralized access.
 */

// Import config types from Zod schemas (single source of truth)
import type { MemoryQuizConfig } from '@/arcade-games/memory-quiz/types'
import type { MatchingConfig } from '@/arcade-games/matching/types'
import type { CardSortingConfig } from '@/arcade-games/card-sorting/types'
import type { YjsDemoConfig } from '@/arcade-games/yjs-demo/types'
import type { RithmomachiaConfig } from '@/arcade-games/rithmomachia/types'
import type { KnowYourWorldConfig } from '@/arcade-games/know-your-world/types'
import type { ComplementRaceGameConfig } from '@/arcade-games/complement-race/types'
import type { MusicConfig } from '@/arcade-games/music-matching/types'
import type { TypeRacerJrConfig } from '@/arcade-games/type-racer-jr/types'
import type { ConstantExplorerConfig } from '@/arcade-games/constant-explorer/types'

// Re-export all config types
export type { MemoryQuizConfig as MemoryQuizGameConfig } from '@/arcade-games/memory-quiz/types'
export type { MatchingConfig as MatchingGameConfig } from '@/arcade-games/matching/types'
export type { CardSortingConfig as CardSortingGameConfig } from '@/arcade-games/card-sorting/types'
export type { YjsDemoConfig as YjsDemoGameConfig } from '@/arcade-games/yjs-demo/types'
export type { RithmomachiaConfig as RithmomachiaGameConfig } from '@/arcade-games/rithmomachia/types'
export type { KnowYourWorldConfig } from '@/arcade-games/know-your-world/types'
export type { ComplementRaceGameConfig } from '@/arcade-games/complement-race/types'
export type { MusicConfig as MusicMatchingConfig } from '@/arcade-games/music-matching/types'
export type { TypeRacerJrConfig } from '@/arcade-games/type-racer-jr/types'
export type { ConstantExplorerConfig } from '@/arcade-games/constant-explorer/types'

// ============================================================================
// Combined Types
// ============================================================================

/**
 * Union type of all game configs for type-safe access
 */
export type GameConfigByName = {
  'memory-quiz': MemoryQuizConfig
  matching: MatchingConfig
  'card-sorting': CardSortingConfig
  'yjs-demo': YjsDemoConfig
  rithmomachia: RithmomachiaConfig
  'know-your-world': KnowYourWorldConfig
  'complement-race': ComplementRaceGameConfig
  'music-matching': MusicConfig
  'type-racer-jr': TypeRacerJrConfig
  'constant-explorer': ConstantExplorerConfig
}

/**
 * Room's game configuration object (nested by game name)
 * This matches the structure stored in room_game_configs table
 */
export type RoomGameConfig = {
  [K in keyof GameConfigByName]?: GameConfigByName[K]
}

/**
 * Default configurations for each game
 */
export const DEFAULT_MATCHING_CONFIG: MatchingConfig = {
  gameType: 'abacus-numeral',
  difficulty: 6,
  turnTimer: 30,
}

export const DEFAULT_MEMORY_QUIZ_CONFIG: MemoryQuizConfig = {
  selectedCount: 5,
  displayTime: 2.0,
  selectedDifficulty: 'easy',
  playMode: 'cooperative',
}

export const DEFAULT_CARD_SORTING_CONFIG: CardSortingConfig = {
  cardCount: 8,
  timeLimit: null,
  gameMode: 'solo',
}

export const DEFAULT_RITHMOMACHIA_CONFIG: RithmomachiaConfig = {
  pointWinEnabled: false,
  pointWinThreshold: 30,
  repetitionRule: true,
  fiftyMoveRule: true,
  allowAnySetOnRecheck: true,
  timeControlMs: null,
}

export const DEFAULT_YIJS_DEMO_CONFIG: YjsDemoConfig = {
  gridSize: 8,
  duration: 60,
}

export const DEFAULT_KNOW_YOUR_WORLD_CONFIG: KnowYourWorldConfig = {
  selectedMap: 'world',
  gameMode: 'cooperative',
  includeSizes: ['huge', 'large', 'medium'],
  assistanceLevel: 'helpful',
  studyDuration: 0,
  selectedContinent: 'all',
}

export const DEFAULT_COMPLEMENT_RACE_CONFIG: ComplementRaceGameConfig = {
  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',
  routeCount: 3,
  targetScore: 100,
  timeLimit: 300,
}

export const DEFAULT_MUSIC_MATCHING_CONFIG: MusicConfig = {
  gameType: 'staff-to-name',
  clef: 'treble',
  difficulty: 6,
  turnTimer: 30,
}

// ============================================================================
// Default Config Map — single source of truth for game-config-helpers.ts
// Adding a new game? Just add its default here. No switch statements needed.
// ============================================================================

export const DEFAULT_CONFIGS: Record<string, GameConfigByName[keyof GameConfigByName]> = {
  matching: DEFAULT_MATCHING_CONFIG,
  'memory-quiz': DEFAULT_MEMORY_QUIZ_CONFIG,
  'card-sorting': DEFAULT_CARD_SORTING_CONFIG,
  'yjs-demo': DEFAULT_YIJS_DEMO_CONFIG,
  rithmomachia: DEFAULT_RITHMOMACHIA_CONFIG,
  'know-your-world': DEFAULT_KNOW_YOUR_WORLD_CONFIG,
  'complement-race': DEFAULT_COMPLEMENT_RACE_CONFIG,
  'music-matching': DEFAULT_MUSIC_MATCHING_CONFIG,
  'type-racer-jr': {
    gameMode: 'free-play',
    timeLimit: null,
    startingDifficulty: 'level1',
    wordCount: 5,
    keyboardLayout: 'qwerty',
    showVirtualKeyboard: false,
  } satisfies TypeRacerJrConfig,
  'constant-explorer': {
    constantId: 'random',
  } satisfies ConstantExplorerConfig,
}