diff --git a/src/main/client/src/feature/game/Game.jsx b/src/main/client/src/feature/game/Game.jsx
index efcad20..a210d7d 100644
--- a/src/main/client/src/feature/game/Game.jsx
+++ b/src/main/client/src/feature/game/Game.jsx
@@ -44,6 +44,7 @@ export const Game = () => {
let stompClient = useContext(StompContext)
let auth = useAuthStore(state => state.auth)
let id = useGameStore(state => state.id)
+ let gameHasEnded = useGameStore(state => state.gameHasEnded)
let lastMove = useGameStore(state => state.lastMove)
let setGameState = useGameStore(state => state.setGameState)
let queueStatus = useGameStore(state => state.queueStatus)
@@ -52,9 +53,9 @@ export const Game = () => {
let currentPlayer = useGameStore(state => state.currentPlayer)
let counting = useGameStore(state => state.counting)
let currentColor = useGameStore(state => state.currentColor)
- let {board, forbidden: [forbidden_x, forbidden_y], gameHasEnded} = useGameStore(state => state.gameState)
+ let {board, forbidden: [forbidden_x, forbidden_y]} = useGameStore(state => state.gameState)
let canvasRef = useRef()
- let countingGroup = !gameHasEnded && counting ? getCountingGroup(board, cursor_x, cursor_y) : undefined
+ let countingGroup = !gameHasEnded() && counting ? getCountingGroup(board, cursor_x, cursor_y) : undefined
let context = useMemo(() => {
let dim = board.length
@@ -116,7 +117,7 @@ export const Game = () => {
}, [board.length, canvasRef, zoom])
let onMouseMove = useCallback((e) => {
- if (gameHasEnded) {
+ if (gameHasEnded()) {
return
}
if (!board.length) {
@@ -137,7 +138,7 @@ export const Game = () => {
}, [context, currentPlayer, auth, board.length, counting, gameHasEnded])
let onClick = useCallback((e) => {
- if (gameHasEnded) {
+ if (gameHasEnded()) {
return
}
if (!board.length) {
@@ -222,7 +223,7 @@ export const Game = () => {
"Authorization": "Bearer " + auth.token,
},
})
- setGameState(game)
+ setGameState(game, auth)
}, () => navigate(base + "/lobby"))
}, [setGameState, queueStatus, auth, id, gameId, navigate])
@@ -232,7 +233,7 @@ export const Game = () => {
addMove(move)
})
return sub.unsubscribe
- }, [setGameState, addMove, stompClient, gameId, auth])
+ }, [addMove, stompClient, gameId])
if (!board.length) {
return
Loading...
diff --git a/src/main/client/src/feature/game/GamePanel.jsx b/src/main/client/src/feature/game/GamePanel.jsx
index b8e617f..c84b429 100644
--- a/src/main/client/src/feature/game/GamePanel.jsx
+++ b/src/main/client/src/feature/game/GamePanel.jsx
@@ -53,11 +53,11 @@ function Panel({zoom, setZoom}) {
let queueLength = useGameStore(state => state.queueLength)
let movesLength = useGameStore(state => state.moves.length)
let counting = useGameStore(state => state.counting)
- let agreeCounting = useGameStore(state => state.agreeCounting)
- let setAgreeCounting = useGameStore(state => state.setAgreeCounting)
+ let countingAgreed = useGameStore(state => state.countingAgreed)
+ let gameHasEnded = useGameStore(state => state.gameHasEnded)
let countingComplete = useGameStore(state => state.countingComplete)
let currentPlayer = useGameStore(state => state.currentPlayer)
- let { board, gameHasEnded } = useGameStore(state => state.gameState)
+ let {board} = useGameStore(state => state.gameState)
let navigate = useNavigate()
let onExit = useCallback(() => {
navigate(base + "/lobby")
@@ -81,7 +81,6 @@ function Panel({zoom, setZoom}) {
})
}, [stompClient, movesLength])
let onCountingAgree = useCallback(() => {
- setAgreeCounting(true)
stompClient.publish({
destination: "/app/game/move",
body: JSON.stringify({
@@ -89,11 +88,11 @@ function Panel({zoom, setZoom}) {
action: "agreeCounting",
}),
})
- }, [stompClient, movesLength, setAgreeCounting])
+ }, [stompClient, movesLength])
if (!board.length) {
return Loading...
}
- let result = gameHasEnded ? getScore(board) : undefined
+ let result = gameHasEnded() ? getScore(board) : undefined
return (
<>
@@ -146,7 +145,7 @@ function Panel({zoom, setZoom}) {
@@ -154,14 +153,14 @@ function Panel({zoom, setZoom}) {