diff --git a/.yarn/patches/react-chessboard-npm-4.7.3-53276f9bfb.patch b/.yarn/patches/react-chessboard-npm-4.7.3-53276f9bfb.patch new file mode 100644 index 00000000..bb94b16a --- /dev/null +++ b/.yarn/patches/react-chessboard-npm-4.7.3-53276f9bfb.patch @@ -0,0 +1,135 @@ +diff --git a/dist/index.esm.js b/dist/index.esm.js +index 3267047874ff62812505a97c7a96d3fae7a8e220..0992869f2bc525d938ad60815cd0630895a02bac 100644 +--- a/dist/index.esm.js ++++ b/dist/index.esm.js +@@ -69,9 +69,9 @@ const WHITE_COLUMN_VALUES = { + c: 2, + d: 3, + e: 4, +- f: 5, +- g: 6, +- h: 7, ++ f: 0, ++ g: 1, ++ h: 2, + }; + const BLACK_COLUMN_VALUES = { + a: 7, +@@ -83,8 +83,8 @@ const BLACK_COLUMN_VALUES = { + g: 1, + h: 0, + }; +-const WHITE_ROWS = [7, 6, 5, 4, 3, 2, 1, 0]; +-const BLACK_ROWS = [0, 1, 2, 3, 4, 5, 6, 7]; ++const WHITE_ROWS = [2, 1, 0]; ++const BLACK_ROWS = [0, 1, 2]; + + // https://commons.wikimedia.org/wiki/Category:SVG_chess_pieces + // By en:User:Cburnett - Own work +@@ -778,19 +778,19 @@ function Notation({ row, col }) { + const whiteColor = customLightSquareStyle.backgroundColor; + const blackColor = customDarkSquareStyle.backgroundColor; + const isRow = col === 0; +- const isColumn = row === 7; ++ const isColumn = row === 2; + const isBottomLeftSquare = isRow && isColumn; + function getRow() { +- return boardOrientation === "white" ? 8 - row : row + 1; ++ return boardOrientation === "white" ? 3 - row : row + 1; + } + function getColumn() { + return boardOrientation === "black" ? COLUMNS[7 - col] : COLUMNS[col]; + } + function renderBottomLeft() { +- return (jsxs(Fragment, { children: [jsx("div", Object.assign({ style: Object.assign(Object.assign({ zIndex: 3, position: "absolute" }, { color: whiteColor }), numericStyle(boardWidth, customNotationStyle)) }, { children: getRow() })), jsx("div", Object.assign({ style: Object.assign(Object.assign({ zIndex: 3, position: "absolute" }, { color: whiteColor }), alphaStyle(boardWidth, customNotationStyle)) }, { children: getColumn() }))] })); ++ return (jsxs(Fragment, { children: [jsx("div", Object.assign({ style: Object.assign(Object.assign({ zIndex: 3, position: "absolute" }, { color: blackColor }), numericStyle(boardWidth, customNotationStyle)) }, { children: getRow() })), jsx("div", Object.assign({ style: Object.assign(Object.assign({ zIndex: 3, position: "absolute" }, { color: blackColor }), alphaStyle(boardWidth, customNotationStyle)) }, { children: getColumn() }))] })); + } + function renderLetters() { +- return (jsx("div", Object.assign({ style: Object.assign(Object.assign({ userSelect: "none", zIndex: 3, position: "absolute" }, { color: col % 2 !== 0 ? blackColor : whiteColor }), alphaStyle(boardWidth, customNotationStyle)) }, { children: getColumn() }))); ++ return (jsx("div", Object.assign({ style: Object.assign(Object.assign({ userSelect: "none", zIndex: 3, position: "absolute" }, { color: col % 2 === 0 ? blackColor : whiteColor }), alphaStyle(boardWidth, customNotationStyle)) }, { children: getColumn() }))); + } + function renderNumbers() { + return (jsx("div", Object.assign({ style: Object.assign(Object.assign({ userSelect: "none", zIndex: 3, position: "absolute" }, (boardOrientation === "black" +@@ -4844,15 +4844,15 @@ function Squares() { + }); + return result; + }, [premoves]); +- return (jsx("div", Object.assign({ "data-boardid": id }, { children: [...Array(8)].map((_, r) => { ++ return (jsx("div", Object.assign({ "data-boardid": id }, { children: [...Array(3)].map((_, r) => { + return (jsx("div", Object.assign({ style: { + display: "flex", + flexWrap: "nowrap", + width: boardWidth, +- } }, { children: [...Array(8)].map((_, c) => { ++ } }, { children: [...Array(3)].map((_, c) => { + const square = boardOrientation === "black" +- ? (COLUMNS[7 - c] + (r + 1)) +- : (COLUMNS[c] + (8 - r)); ++ ? (COLUMNS[2 - c] + (r + 2)) ++ : (COLUMNS[c] + (4 - r)); + const squareColor = c % 2 === r % 2 ? "white" : "black"; + const squareHasPremove = premoves.find((p) => p.sourceSq === square || p.targetSq === square); + const squareHasPremoveTarget = premovesHistory +diff --git a/dist/index.js b/dist/index.js +index a55a978e1a9de9b7eb3ec174177fc60186384931..fddcb4cc3fdd5ff2697ab748afc24bf4a58da8fb 100644 +--- a/dist/index.js ++++ b/dist/index.js +@@ -30,7 +30,7 @@ function __rest(s, e) { + return t; + } + +-const COLUMNS = "abcdefgh".split(""); ++const COLUMNS = "abc".split(""); + const START_POSITION_OBJECT = { + a8: "bR", + b8: "bN", +@@ -69,24 +69,14 @@ const WHITE_COLUMN_VALUES = { + a: 0, + b: 1, + c: 2, +- d: 3, +- e: 4, +- f: 5, +- g: 6, +- h: 7, + }; + const BLACK_COLUMN_VALUES = { +- a: 7, +- b: 6, +- c: 5, +- d: 4, +- e: 3, +- f: 2, +- g: 1, +- h: 0, ++ a: 2, ++ b: 1, ++ c: 0, + }; +-const WHITE_ROWS = [7, 6, 5, 4, 3, 2, 1, 0]; +-const BLACK_ROWS = [0, 1, 2, 3, 4, 5, 6, 7]; ++const WHITE_ROWS = [2, 1, 0]; ++const BLACK_ROWS = [0, 1, 2]; + + // https://commons.wikimedia.org/wiki/Category:SVG_chess_pieces + // By en:User:Cburnett - Own work +@@ -4846,15 +4836,15 @@ function Squares() { + }); + return result; + }, [premoves]); +- return (jsxRuntime.jsx("div", Object.assign({ "data-boardid": id }, { children: [...Array(8)].map((_, r) => { ++ return (jsxRuntime.jsx("div", Object.assign({ "data-boardid": id }, { children: [...Array(3)].map((_, r) => { + return (jsxRuntime.jsx("div", Object.assign({ style: { + display: "flex", + flexWrap: "nowrap", + width: boardWidth, +- } }, { children: [...Array(8)].map((_, c) => { ++ } }, { children: [...Array(3)].map((_, c) => { + const square = boardOrientation === "black" +- ? (COLUMNS[7 - c] + (r + 1)) +- : (COLUMNS[c] + (8 - r)); ++ ? (COLUMNS[2 - c] + (r + 1)) ++ : (COLUMNS[c] + (3 - r)); + const squareColor = c % 2 === r % 2 ? "white" : "black"; + const squareHasPremove = premoves.find((p) => p.sourceSq === square || p.targetSq === square); + const squareHasPremoveTarget = premovesHistory diff --git a/.yarnrc.yml b/.yarnrc.yml new file mode 100644 index 00000000..3186f3f0 --- /dev/null +++ b/.yarnrc.yml @@ -0,0 +1 @@ +nodeLinker: node-modules diff --git a/package.json b/package.json index 4c8a76d6..19f71714 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,10 @@ "name": "utd-chess-bots", "private": true, "version": "0.0.0", - "workspaces": ["src/client", "src/server"], + "workspaces": [ + "src/client", + "src/server" + ], "scripts": { "dev": "ts-node src/server/main.ts", "devup": "nodemon src/server/main.ts", @@ -44,5 +47,5 @@ "optionalDependencies": { "bufferutil": "^4.0.8" }, - "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" + "packageManager": "yarn@4.13.0" } diff --git a/src/client/chessboard/chessboard-wrapper.tsx b/src/client/chessboard/chessboard-wrapper.tsx index f9865899..6b7182c7 100644 --- a/src/client/chessboard/chessboard-wrapper.tsx +++ b/src/client/chessboard/chessboard-wrapper.tsx @@ -113,7 +113,7 @@ export function ChessboardWrapper(props: ChessboardWrapperProps): JSX.Element { { diff --git a/src/client/game/game.tsx b/src/client/game/game.tsx index 4075c1f8..61c9a1e9 100644 --- a/src/client/game/game.tsx +++ b/src/client/game/game.tsx @@ -117,7 +117,7 @@ export function Game(): JSX.Element { setGameInterruptedReason(gameState.gameEndReason); } return gameState; - }) + }); }, false, ); @@ -132,6 +132,8 @@ export function Game(): JSX.Element { ); // go to /home if error } else if (isError) { + console.log(isError); + console.log("error"); return ; } @@ -184,6 +186,7 @@ export function Game(): JSX.Element { (move: Move): void => { setChess(chess.copy(move)); sendMessage(new MoveMessage(move)); + window.location.reload(); } : () => {}; //send a do-nothing function if game is paused diff --git a/src/client/package.json b/src/client/package.json index 06963ff4..a36d9a03 100644 --- a/src/client/package.json +++ b/src/client/package.json @@ -12,7 +12,7 @@ "interactjs": "^1.10.27", "motion": "^12.6.0", "react": "^18.2.0", - "react-chessboard": "^4.5.0", + "react-chessboard": "patch:react-chessboard@npm%3A4.7.3#~/.yarn/patches/react-chessboard-npm-4.7.3-53276f9bfb.patch", "react-dom": "^18.2.0", "react-joystick-component": "^6.2.1", "react-router-dom": "^6.21.3", diff --git a/src/client/setup/setup-game.tsx b/src/client/setup/setup-game.tsx index 4e81e26f..54f0c1cb 100644 --- a/src/client/setup/setup-game.tsx +++ b/src/client/setup/setup-game.tsx @@ -95,10 +95,14 @@ export function SetupGame(props: SetupGameProps) { side: selectedSide, difficulty: difficulty.toString(), }); - } else { + } else if (props.gameType === GameType.HUMAN){ promise = post("/start-human-game", { side: selectedSide, }); + } else{ + promise = post("/start-hexapawn-game", { + side: selectedSide, + }); } promise.then(() => { navigate("/game"); diff --git a/src/client/setup/setup.tsx b/src/client/setup/setup.tsx index a6ce96fd..6155a452 100644 --- a/src/client/setup/setup.tsx +++ b/src/client/setup/setup.tsx @@ -27,6 +27,7 @@ enum SetupType { COMPUTER = "computer", HUMAN = "human", PUZZLE = "puzzle", + HEXAPAWN = "hexapawn", } /** @@ -60,13 +61,14 @@ export function Setup(): JSX.Element { : null} {( setupType === SetupType.COMPUTER || - setupType === SetupType.HUMAN + setupType === SetupType.HUMAN || + setupType === SetupType.HEXAPAWN ) ? : null} @@ -132,6 +134,14 @@ function SetupMain(props: SetupMainProps) { onClick={() => props.onPageChange(SetupType.PUZZLE)} className={buttonColor()} /> +