From ce53388d26b5d623ab539d7a8a660c1e6c6f19be Mon Sep 17 00:00:00 2001 From: Inga Date: Tue, 19 Nov 2024 02:27:04 +0000 Subject: [PATCH] implemented autoplay configuration --- src/backend/components/boardgame.tsx | 39 ++++- src/backend/main/boardgame-handler.ts | 4 +- src/shared/array-utils.ts | 4 + src/shared/boardgame-state.spec.ts | 202 +++++++++++++++++++++----- src/shared/boardgame-state.ts | 45 +++++- src/shared/datatypes.ts | 3 + src/shared/display.ts | 6 +- 7 files changed, 255 insertions(+), 48 deletions(-) diff --git a/src/backend/components/boardgame.tsx b/src/backend/components/boardgame.tsx index ca46281..ef237c3 100644 --- a/src/backend/components/boardgame.tsx +++ b/src/backend/components/boardgame.tsx @@ -3,6 +3,7 @@ import { BoardgameStateType, CurrentOutcome, GameRules, + Player, SquareState, formatSquareState, } from "../../shared/datatypes.ts"; @@ -17,6 +18,12 @@ const getClassAndDisplayAttributes = ( style: getDisplayStates(gameState, currentOutcome)[className] ? {} : { display: "none" }, }); +const getSubmitAttributes = (key: string, targetState: BoardgameStateType) => ({ + type: "submit" as const, + name: key, + value: targetState.serialize(), +}); + const getCellHtml = ({ key, gameState, @@ -32,7 +39,7 @@ const getCellHtml = ({ }) => { if (!gameState.board) { return ( - ); @@ -44,7 +51,7 @@ const getCellHtml = ({ ? gameState.withMove(row, column) : gameState; return ( - ); @@ -76,6 +83,34 @@ export const getBoardgameHtml = (key: string, gameState: BoardgameStateType, rul Draw

+

+ Currently X moves are made manually.{" "} + +

+ +

+ Currently X moves are made by computer.{" "} + +

+ +

+ Currently O moves are made manually.{" "} + +

+ +

+ Currently O moves are made by computer.{" "} + +

+