/** * ChessBoard component — live chess board with piece animations * Design: Quantitative Finance Dark — cream/brown squares, high-contrast pieces * * FIX: Black pieces now use #FFD700 (gold) instead of #1a1a2e (invisible on dark squares) * FIX: Square colors changed to classic chess cream (#F0D9B5) and brown (#B58863) * FIX: Larger font size and stronger shadows for visibility */ import { useEffect, useState } from "react"; import { PIECES, type GameState } from "@/lib/simulation"; interface ChessBoardProps { state: GameState; } export default function ChessBoard({ state }: ChessBoardProps) { const [lastMove, setLastMove] = useState<{ from: string; to: string } | null>(null); const [prevMoves, setPrevMoves] = useState([]); useEffect(() => { if (state.moves.length > prevMoves.length) { setPrevMoves(state.moves); } }, [state.moves]); const files = "abcdefgh"; const ranks = "87654321"; const getSquareClass = (rank: number, file: number) => { const isLight = (rank + file) % 2 === 0; return isLight ? "chess-square-light" : "chess-square-dark"; }; return (
{/* Rank labels + board */}
{/* Rank labels */}
{ranks.split("").map((r) => ( {r} ))}
{/* Board */}
{state.board.map((row, rankIdx) => row.map((piece, fileIdx) => { const squareClass = getSquareClass(rankIdx, fileIdx); return (
{piece && ( {PIECES[piece] ?? piece} )}
); }) )}
{/* File labels */}
{files.split("").map((f) => ( {f} ))}
); }