import { C4_COLS, C4_ROWS, c4DropRow, c4WinningCells, type Cell, } from '@chat-app/shared/chat'; interface Props { board: Cell[]; myPlayerIdx: 0 | 1 | null; disabled: boolean; onMove: (column: number) => void; } export function ConnectFourBoard({ board, myPlayerIdx, disabled, onMove }: Props) { const winCells = c4WinningCells(board); const winSet = new Set(winCells ?? []); return (
{Array.from({ length: C4_ROWS * C4_COLS }, (_, idx) => { const cell = board[idx]; const col = idx % C4_COLS; const dropTo = c4DropRow(board, col); const canClickColumn = !disabled && dropTo >= 0 && myPlayerIdx !== null; const inWin = winSet.has(idx); return (
); }