diff --git a/src/main/client/src/component/BabyStone.jsx b/src/main/client/src/component/BabyStone.jsx new file mode 100644 index 0000000..025355d --- /dev/null +++ b/src/main/client/src/component/BabyStone.jsx @@ -0,0 +1,14 @@ +import { + FaCircle, +} from "react-icons/fa" +import { + IconContext, +} from "react-icons" + +export function BabyStone({color, className}) { + return ( + + + + ) +} diff --git a/src/main/client/src/feature/game/Game.jsx b/src/main/client/src/feature/game/Game.jsx index bc1e55c..fb81efb 100644 --- a/src/main/client/src/feature/game/Game.jsx +++ b/src/main/client/src/feature/game/Game.jsx @@ -115,7 +115,11 @@ function Board({gameState, setGameState}) { } setTimeout(10) intervalIdRef.current = setInterval(() => { - setTimeout(timeoutRef.current - 1) + let t = timeoutRef.current - 1 + setTimeout(t) + if (t <= 0) { + clearInterval(intervalIdRef.current) + } }, 1000) }, [setTimeout]) diff --git a/src/main/client/src/feature/game/GamePanel.jsx b/src/main/client/src/feature/game/GamePanel.jsx index 268f733..0722ff7 100644 --- a/src/main/client/src/feature/game/GamePanel.jsx +++ b/src/main/client/src/feature/game/GamePanel.jsx @@ -15,12 +15,15 @@ import { import { StompContext, base, + BLACK, + WHITE, } from "src/util.js" import { Button, } from "src/component/Button.jsx" import { useAuthStore, + useTimeoutStore, } from "src/store.js" import { Chat, @@ -28,9 +31,13 @@ import { import { SideBar, } from "src/component/SideBar.jsx" +import { + BabyStone, +} from "src/component/BabyStone.jsx" import { countingComplete, currentPlayer, + currentColor, isKibitz, moveBack, moveForward, @@ -53,7 +60,7 @@ export const GamePanel = ({gameState, setGameState}) => { function Panel({gameState, setGameState}) { let {gameId} = useParams() let auth = useAuthStore(state => state.auth) - let {black, white, counting, board} = gameState + let {counting, board} = gameState if (!board.length) { return Loading... @@ -61,7 +68,7 @@ function Panel({gameState, setGameState}) { let activePlay = !isKibitz(gameState, auth) && !gameHasEnded(gameState) return ( <> - + state.timeout) + let color = currentColor(gameState) let navigate = useNavigate() let onExit = useCallback(() => { navigate(base + "/lobby") }, [navigate]) return ( -
-
{white}
-
vs
-
{black}
-
+
+
{white}
+
VS
+
{black}
+
+
{color === WHITE ? timeout : "10"}
+
+
{color === BLACK ? timeout : "10"}
+
+
) } diff --git a/src/main/client/src/feature/lobby/OpenGames.jsx b/src/main/client/src/feature/lobby/OpenGames.jsx index ebae3f8..8ed815a 100644 --- a/src/main/client/src/feature/lobby/OpenGames.jsx +++ b/src/main/client/src/feature/lobby/OpenGames.jsx @@ -6,7 +6,6 @@ import { useCallback, } from "react" import { - FaCircle, FaAngleLeft, FaAngleRight, } from "react-icons/fa" @@ -25,6 +24,9 @@ import { import { Button, } from "src/component/Button.jsx" +import { + BabyStone, +} from "src/component/BabyStone.jsx" import { base, StompContext, @@ -156,13 +158,13 @@ function AcceptDialog({acceptableGame, onAccept}) { className="absolute bg-sky-200 px-4 py-3 rounded-lg z-10 flex flex-col">
@@ -193,10 +195,3 @@ function AcceptDialog({acceptableGame, onAccept}) { ) } -function BabyStone({color}) { - return ( - - - - ) -}