fix(arcade): add Number Guesser to game config helpers

Fixes server-side session creation for Number Guesser:
- Import DEFAULT_NUMBER_GUESSER_CONFIG
- Add case for 'number-guesser' in getDefaultGameConfig()
- Add validation for number-guesser config
- Include arcade-games validators in server TypeScript build

This resolves the "Unknown game: number-guesser" error when creating sessions.

🤖 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-15 19:09:52 -05:00
parent 3e81c1f480
commit 7d1a351ed6
2 changed files with 18 additions and 0 deletions

View File

@@ -14,6 +14,7 @@ import {
DEFAULT_MATCHING_CONFIG,
DEFAULT_MEMORY_QUIZ_CONFIG,
DEFAULT_COMPLEMENT_RACE_CONFIG,
DEFAULT_NUMBER_GUESSER_CONFIG,
} from './game-configs'
/**
@@ -27,6 +28,8 @@ function getDefaultGameConfig(gameName: GameName): GameConfigByName[GameName] {
return DEFAULT_MEMORY_QUIZ_CONFIG
case 'complement-race':
return DEFAULT_COMPLEMENT_RACE_CONFIG
case 'number-guesser':
return DEFAULT_NUMBER_GUESSER_CONFIG
default:
throw new Error(`Unknown game: ${gameName}`)
}
@@ -194,6 +197,18 @@ export function validateGameConfig(gameName: GameName, config: any): boolean {
// TODO: Add validation when complement-race settings are defined
return typeof config === 'object' && config !== null
case 'number-guesser':
return (
typeof config === 'object' &&
config !== null &&
typeof config.minNumber === 'number' &&
typeof config.maxNumber === 'number' &&
typeof config.roundsToWin === 'number' &&
config.minNumber >= 1 &&
config.maxNumber > config.minNumber &&
config.roundsToWin >= 1
)
default:
return false
}

View File

@@ -19,9 +19,12 @@
"src/db/schema/**/*.ts",
"src/db/migrate.ts",
"src/lib/arcade/**/*.ts",
"src/arcade-games/**/Validator.ts",
"src/arcade-games/**/types.ts",
"src/app/games/matching/context/types.ts",
"src/app/games/matching/utils/cardGeneration.ts",
"src/app/games/matching/utils/matchValidation.ts",
"src/app/arcade/memory-quiz/types.ts",
"src/socket-server.ts"
],
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts"]