-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgameBoardDisplay.tsx
38 lines (36 loc) · 1.1 KB
/
gameBoardDisplay.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import GamePiece from '@/components/gamePiece'
import {
GameBoardState,
GamePieceId,
GamePieceStates,
PlayStates,
} from '@/types/gameStateTypes'
import { isLegalMoveCurried } from '@/utils/gameUtils'
interface GameBoardDisplayProps extends GameBoardState {
onPieceClick: (gamePieceId: GamePieceId) => void
playState: PlayStates
}
export default function GameBoardDisplay({
gameBoard,
onPieceClick,
playState,
}: GameBoardDisplayProps) {
return (
<div className="h-full flex flex-col space-y-4 border-l-8 border-r-8 px-4 py-4">
{gameBoard.map((gameRow, rowIndex) => (
<div className="w-full flex space-x-4" key={`gameRow-${rowIndex}`}>
{gameRow.map((piece, pieceIndex) => (
<GamePiece
gamePieceState={piece}
gamePieceId={{ row: rowIndex, col: pieceIndex }}
onPieceClick={onPieceClick}
isLegalMoveCurried={isLegalMoveCurried(gameBoard)}
playState={playState}
key={`${GamePieceStates[piece]}-${pieceIndex}`}
/>
))}
</div>
))}
</div>
)
}