added nakama provider using nakama package

This commit is contained in:
2025-11-27 16:51:06 +05:30
parent c6c9d10476
commit 4565c4b33a
6 changed files with 331 additions and 50 deletions

View File

@@ -1,11 +1,48 @@
import Square from "./Square";
import React from "react";
export default function Board({ squares, onClick }) {
interface BoardProps {
board: string[][];
turn: number;
winner: string | null;
onCellClick: (row: number, col: number) => void;
}
export default function Board({ board, turn, winner, onCellClick }: BoardProps) {
return (
<div className="board">
{squares.map((value, i) => (
<Square key={i} value={value} onClick={() => onClick(i)} />
))}
<div>
{winner ? (
<h2>Winner: {winner}</h2>
) : (
<h2>Turn: Player {turn === 0 ? "X" : "O"}</h2>
)}
<div
style={{
display: "grid",
gridTemplateColumns: "repeat(3, 80px)",
gap: "10px",
marginTop: "20px",
}}
>
{board.map((row, rIdx) =>
row.map((cell, cIdx) => (
<button
key={`${rIdx}-${cIdx}`}
style={{
width: "80px",
height: "80px",
fontSize: "2rem",
cursor: cell || winner ? "not-allowed" : "pointer",
}}
onClick={() => {
if (!cell && !winner) onCellClick(rIdx, cIdx);
}}
>
{cell}
</button>
))
)}
</div>
</div>
);
}