diff --git a/src/game.jsx b/src/game.jsx
index 74ed5d7..cf3aedd 100644
--- a/src/game.jsx
+++ b/src/game.jsx
@@ -32,6 +32,40 @@ const getWinningCombo = (grid) => {
return combos.find(wins) || [];
};
+const GridButton = ({ onClick, symbol, turn, disabled, won }) => {
+ const Symbol = symbol == "X" ? Cross : Oval;
+ let symbolColor = symbol == "X" ? "text-blue-700" : "text-yellow-700";
+
+ const SymbolOutline = turn == "X" ? CrossOutline : OvalOutline;
+ let outlineColor = turn == "X" ? "text-blue-700" : "text-yellow-700";
+
+ let background = "bg-navy-400 inner-shadow-2-navy";
+
+ if (won) {
+ symbolColor = "text-navy-400";
+ background =
+ symbol == "X"
+ ? "bg-blue-400 inner-shadow-2-blue"
+ : "bg-yellow-400 inner-shadow-2-yellow";
+ }
+
+ return (
+
+ );
+};
+
export default ({ players }) => {
const [score, updateScore] = useImmer({ X: 0, O: 0, ties: 0 });
const [grid, updateGrid] = useImmer(Array(9).fill(""));
@@ -40,7 +74,7 @@ export default ({ players }) => {
const [roundModal, setRoundModal] = useState(false);
const turn = grid.filter((s) => s == "").length % 2 != 0 ? "X" : "O";
- const TurnOutline = turn == "X" ? CrossOutline : OvalOutline;
+ const cpuTurn = players[turn] == "CPU";
const TurnIndicator = turn == "X" ? Cross : Oval;
const winningCombo = getWinningCombo(grid);
@@ -48,9 +82,6 @@ export default ({ players }) => {
const gridFull = !grid.some((s) => s == "");
const roundOver = winner || gridFull;
- const tie = roundOver && !winner;
-
- const cpuTurn = players[turn] == "CPU";
useEffect(() => {
if (roundOver) {
@@ -89,39 +120,6 @@ export default ({ players }) => {
updateGrid(() => Array(9).fill(""));
};
- const renderSymbol = (symbol, index) => {
- if (symbol == "") {
- const colorClass = turn == "X" ? "text-blue-700" : "text-yellow-700";
-
- return (
-