From dc3fd61bd3de7aff0d4778dd94d7269c931f3b0d Mon Sep 17 00:00:00 2001 From: djmil Date: Fri, 1 Dec 2023 10:01:27 +0100 Subject: [PATCH] DRAW req alerts --- webapp/src/container/games/GameBoard.jsx | 14 +++++++++++--- webapp/src/container/games/GameSelector.jsx | 6 ------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/webapp/src/container/games/GameBoard.jsx b/webapp/src/container/games/GameBoard.jsx index 31e8eaa..e60ba7a 100644 --- a/webapp/src/container/games/GameBoard.jsx +++ b/webapp/src/container/games/GameBoard.jsx @@ -13,10 +13,18 @@ export default function GameBoard({ dispatchGuide, username, getGame, onStoneCli const optionalOnStoneClick = (typeof onStoneClick !== 'function') ? null : (cellId) => onStoneClick(game.uuid, cellId); - const optionalOnStoneMove = (typeof onStoneMove !== 'function' || isPushing || game.status === 'DRAW_REQUEST_WAIT_FOR_YOU' || game.status === 'DRAW_REQUEST_WAIT_FOR_OPPONENT') ? null : + const optionalOnStoneMove = (typeof onStoneMove !== 'function' || isPushing) ? null : (move) => { - if (move[0] !== move[1] && game.board[move[1]] === undefined) - onStoneMove(game.uuid, move) + if (move[0] === move[1] || game.board[move[1]] !== undefined) + return; // ignore obviosly wrong move + + if (game.status === 'DRAW_REQUEST_WAIT_FOR_YOU') + return alert("You have to descide on Draw request from " + game.opponentName); + + if (game.status === 'DRAW_REQUEST_WAIT_FOR_OPPONENT') + return alert("Awating for " + game.opponentName + "'s decision on the Draw request"); + + onStoneMove(game.uuid, move) }; const currMove = (() => { diff --git a/webapp/src/container/games/GameSelector.jsx b/webapp/src/container/games/GameSelector.jsx index 723a18a..b6752ff 100644 --- a/webapp/src/container/games/GameSelector.jsx +++ b/webapp/src/container/games/GameSelector.jsx @@ -133,12 +133,6 @@ function Selectable({ game, selected, onClick }) { const opponentName = game.opponentName; const flipBoard = (game?.myColor === Color.black) ? true : null; - const color = 'red';//game.status === 'DRAW_REQUEST_WAIT_FOR_YOU' || game.status === 'DRAW_REQUEST_WAIT_FOR_OPPONENT'; - - // const style = { - // border: 1px 'red' - // }; - return (
onClick(game.uuid)}