"use client" import { PieceColor, type ChessPiece, GameMode } from "@/lib/chess-types" import { getPieceSymbol } from "@/lib/chess-utils" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs" interface GameInfoProps { currentPlayer: PieceColor gameStatus: string moveHistory: string[] capturedPieces: { [PieceColor.WHITE]: ChessPiece[] [PieceColor.BLACK]: ChessPiece[] } gameMode?: GameMode } export default function GameInfo({ currentPlayer, gameStatus, moveHistory, capturedPieces, gameMode = GameMode.CLASSIC }: GameInfoProps) { return (
Game Status ({gameMode === GameMode.CLASSIC ? "Classic" : "Ghost"} Chess)
{currentPlayer === PieceColor.WHITE ? "White" : "Black"}'s turn
{gameStatus === "ongoing" ? (

Game in progress {gameMode === GameMode.GHOST && ( Goal: Lose all your pieces to win! )}

) : gameStatus.includes("check") && !gameStatus.includes("checkmate") && !gameStatus.includes("ghost-win") ? (

{gameStatus.split("-")[1] === PieceColor.WHITE ? "White" : "Black"} is in check!

) : null}
Move History Captured Pieces {moveHistory.length > 0 ? (
{Array.from({ length: Math.ceil(moveHistory.length / 2) }).map((_, i) => (
{i + 1}. {moveHistory[i * 2]}
{moveHistory[i * 2 + 1] &&
{moveHistory[i * 2 + 1]}
}
))}
) : (

No moves yet

)}

White captured{gameMode === GameMode.GHOST ? " (White's progress)" : ""}:

{capturedPieces[PieceColor.BLACK].length > 0 ? ( capturedPieces[PieceColor.BLACK].map((piece, i) => ( {getPieceSymbol(piece)} )) ) : ( None )}

Black captured{gameMode === GameMode.GHOST ? " (Black's progress)" : ""}:

{capturedPieces[PieceColor.WHITE].length > 0 ? ( capturedPieces[PieceColor.WHITE].map((piece, i) => ( {getPieceSymbol(piece)} )) ) : ( None )}
) }