Some checks failed
Deploy to Production / test (push) Failing after 33s
- tighten route authorization and schema handling - update user route tests and server coverage - refresh player dashboard behavior
7 lines
6.1 KiB
JSON
7 lines
6.1 KiB
JSON
{
|
|
"timestamp": "2026-04-07T11:54:27.973Z",
|
|
"code": "import { readFile } from 'node:fs/promises';\n\nasync function inspectChessLogic() {\n const pluginPath = 'shared/games/chess/chess.plugin.ts';\n const typesPath = 'shared/games/chess/chess.types.ts';\n\n try {\n console.log(`--- Reading ${pluginPath} ---`);\n const pluginContent = await readFile(pluginPath, 'utf8');\n // Print only a snippet to avoid overwhelming the log if it's huge\n console.log(pluginContent.substring(0, 2000) + \"\\n... [truncated]\");\n\n console.log(`\\n--- Reading ${typesPath} ---`);\n const typesContent = await readFile(typesPath, 'utf8');\n console.log(typesContent);\n\n } catch (e) {\n console.error(\"Error reading chess files:\", e);\n }\n}\n\ninspectChessLogic();\n",
|
|
"output": "--- Reading shared/games/chess/chess.plugin.ts ---\nimport { Chess } from \"chess.js\";\nimport type { GamePlugin, GameResult, GameOverResult } from \"../types\";\nimport type {\n ChessState, ChessAction, ChessPlayerView,\n ChessSpectatorView, ChessClock,\n} from \"./chess.types\";\nimport { TIME_CONTROLS } from \"./chess.types\";\n\nfunction colorOfPlayer(state: ChessState, playerId: string): \"white\" | \"black\" | null {\n const isWhite = state.players.white === playerId;\n const isBlack = state.players.black === playerId;\n if (isWhite && isBlack) {\n // Solo test mode — same player controls both sides, return current turn\n return currentTurn(state.fen);\n }\n if (isWhite) return \"white\";\n if (isBlack) return \"black\";\n return null;\n}\n\nfunction currentTurn(fen: string): \"white\" | \"black\" {\n // FEN active color field is the second space-separated token\n return fen.split(\" \")[1] === \"w\" ? \"white\" : \"black\";\n}\n\nfunction applyClockTick(clock: ChessClock, turn: \"white\" | \"black\"): ChessClock {\n const now = Date.now();\n const elapsed = now - clock.lastMoveAt;\n const remaining = Math.max(0, clock[turn] - elapsed);\n return { ...clock, [turn]: remaining, lastMoveAt: now };\n}\n\nfunction addIncrement(clock: ChessClock, color: \"white\" | \"black\"): ChessClock {\n return { ...clock, [color]: clock[color] + clock.increment };\n}\n\nexport const chessPlugin: GamePlugin<ChessState, ChessAction> = {\n slug: \"chess\",\n name: \"Chess\",\n minPlayers: 2,\n maxPlayers: 2,\n\n createInitialState(players: string[], options?: Record<string, unknown>): ChessState {\n const game = new Chess();\n const timeControlKey = (options?.timeControl as string) ?? \"blitz_5_3\";\n const tc = TIME_CONTROLS[timeControlKey] ?? TIME_CONTROLS.blitz_5_3;\n\n // Randomly assign colors\n const shuffled = Math.random() < 0.5 ? [players[0], players[1]] : [players[1], players[0]];\n\n const clock: ChessClock | null = tc.time > 0\n ? { white: tc.time, black: tc.time, increment: tc.incr\n... [truncated]\n\n--- Reading shared/games/chess/chess.types.ts ---\nexport interface ChessClock {\n white: number; // ms remaining\n black: number; // ms remaining\n increment: number; // ms added per move\n lastMoveAt: number; // timestamp of last move (for computing elapsed time)\n}\n\nexport interface ChessState {\n fen: string;\n pgn: string;\n players: { white: string; black: string };\n clock: ChessClock | null;\n drawOffer: \"white\" | \"black\" | null;\n result: \"white\" | \"black\" | \"draw\" | null;\n resultReason: string | null;\n moveHistory: { from: string; to: string; san: string; color: \"w\" | \"b\" }[];\n}\n\nexport type ChessAction =\n | { type: \"move\"; from: string; to: string; promotion?: string }\n | { type: \"resign\" }\n | { type: \"offer_draw\" }\n | { type: \"accept_draw\" }\n | { type: \"decline_draw\" }\n | { type: \"claim_timeout\" };\n\nexport interface ChessPlayerView {\n fen: string;\n pgn: string;\n myColor: \"white\" | \"black\";\n turn: \"white\" | \"black\";\n clock: { white: number; black: number; increment: number; activeColor: \"white\" | \"black\" | null } | null;\n drawOffer: \"white\" | \"black\" | null;\n result: \"white\" | \"black\" | \"draw\" | null;\n resultReason: string | null;\n moveHistory: { from: string; to: string; san: string; color: \"w\" | \"b\" }[];\n isCheck: boolean;\n legalMoves: { from: string; to: string; promotion?: string }[];\n}\n\nexport interface ChessSpectatorView {\n fen: string;\n pgn: string;\n players: { white: string; black: string };\n turn: \"white\" | \"black\";\n clock: { white: number; black: number; increment: number; activeColor: \"white\" | \"black\" | null } | null;\n drawOffer: \"white\" | \"black\" | null;\n result: \"white\" | \"black\" | \"draw\" | null;\n resultReason: string | null;\n moveHistory: { from: string; to: string; san: string; color: \"w\" | \"b\" }[];\n isCheck: boolean;\n}\n\nexport interface ChessRoomOptions {\n timeControl: \"bullet_1_0\" | \"bullet_2_1\" | \"blitz_3_0\" | \"blitz_3_2\" | \"blitz_5_0\" | \"blitz_5_3\" | \"rapid_10_0\" | \"rapid_15_10\" | \"classical_30_0\" | \"none\";\n}\n\nexport const TIME_CONTROLS: Record<string, { name: string; time: number; increment: number }> = {\n bullet_1_0: { name: \"Bullet 1+0\", time: 1 * 60_000, increment: 0 },\n bullet_2_1: { name: \"Bullet 2+1\", time: 2 * 60_000, increment: 1_000 },\n blitz_3_0: { name: \"Blitz 3+0\", time: 3 * 60_000, increment: 0 },\n blitz_3_2: { name: \"Blitz 3+2\", time: 3 * 60_000, increment: 2_000 },\n blitz_5_0: { name: \"Blitz 5+0\", time: 5 * 60_000, increment: 0 },\n blitz_5_3: { name: \"Blitz 5+3\", time: 5 * 60_000, increment: 3_000 },\n rapid_10_0: { name: \"Rapid 10+0\", time: 10 * 60_000, increment: 0 },\n rapid_15_10: { name: \"Rapid 15+10\", time: 15 * 60_000, increment: 10_000 },\n classical_30_0:{ name: \"Classical 30+0\", time: 30 * 60_000, increment: 0 },\n none: { name: \"No Clock\", time: 0, increment: 0 },\n};\n\n",
|
|
"exitCode": 0,
|
|
"durationMs": 18
|
|
} |