Skip to content

Commit b2923ad

Browse files
committed
no counting after game has ended
1 parent 59cc80a commit b2923ad

File tree

1 file changed

+13
-13
lines changed
  • src/main/client/src/feature/game

1 file changed

+13
-13
lines changed

src/main/client/src/feature/game/Game.jsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ function Board({gameState, setGameState}) {
105105
let dragging = useLayoutStore(state => state.dragging)
106106
let muted = useMuteStore(state => state.muted)
107107
let howler = useRef()
108-
let showMoveNumbers = ctrlKeyDown && (isKibitz(gameState, auth) || gameHasEnded(gameState))
108+
let end = gameHasEnded(gameState)
109+
let showMoveNumbers = ctrlKeyDown && (isKibitz(gameState, auth) || end)
109110
let intervalIdRef = useRef()
110111

111112
let resetCountdown = useCallback(() => {
@@ -174,10 +175,7 @@ function Board({gameState, setGameState}) {
174175
}, [board.length])
175176

176177
let getCountingGroup = useCallback(() => {
177-
if (gameHasEnded(gameState)) {
178-
return undefined
179-
}
180-
if (!counting) {
178+
if (end || !counting) {
181179
return undefined
182180
}
183181
if (!isCursorInBounds()) {
@@ -190,7 +188,7 @@ function Board({gameState, setGameState}) {
190188
return undefined
191189
}
192190
return has
193-
}, [gameState, counting, board, isCursorInBounds])
191+
}, [counting, board, isCursorInBounds, end])
194192

195193
let context = useMemo(() => {
196194
let dim = board.length
@@ -251,10 +249,10 @@ function Board({gameState, setGameState}) {
251249
}, [board, canvasRef, zoom])
252250

253251
useEffect(() => {
254-
if (!showMoveNumbers) {
252+
if (!showMoveNumbers && !counting && !end) {
255253
paintLastMove(context, lastMove, timeout)
256254
}
257-
}, [showMoveNumbers, context, lastMove, timeout])
255+
}, [showMoveNumbers, context, lastMove, timeout, counting, end])
258256

259257
let onMouseMove = useCallback((e) => {
260258
if (dragging) {
@@ -286,7 +284,7 @@ function Board({gameState, setGameState}) {
286284
}
287285
return
288286
}
289-
if (gameHasEnded(gameState)) {
287+
if (end) {
290288
return
291289
}
292290
if (!board.length) {
@@ -323,7 +321,7 @@ function Board({gameState, setGameState}) {
323321
destination: "/app/game/move",
324322
body: JSON.stringify(move),
325323
})
326-
}, [gameState, setGameState, auth, board, stompClient, counting, forbidden_x, forbidden_y, myColor, playClickSound, isCursorInBounds, showMoveNumbers, resetCountdown])
324+
}, [gameState, setGameState, auth, board, stompClient, counting, forbidden_x, forbidden_y, myColor, playClickSound, isCursorInBounds, showMoveNumbers, resetCountdown, end])
327325

328326
useEffect(() => {
329327
if (!board.length) {
@@ -344,8 +342,10 @@ function Board({gameState, setGameState}) {
344342
paintStones(context, board, showMoveNumbers)
345343
if (showMoveNumbers) {
346344
paintMoveNumbers(context, board)
347-
} else {
345+
} else if (!counting && !end) {
348346
paintLastMove(context, lastMove, timeoutRef.current)
347+
} else {
348+
paintLastMove(context, lastMove)
349349
}
350350
if (currentPlayer(gameState) !== auth.name) {
351351
return
@@ -362,10 +362,10 @@ function Board({gameState, setGameState}) {
362362
if (cursor_x == forbidden_x && cursor_y == forbidden_y) {
363363
return
364364
}
365-
if (!showMoveNumbers) {
365+
if (!showMoveNumbers && !counting && !end) {
366366
paintShadow(context, cursor_x, cursor_y, currentColor(gameState))
367367
}
368-
}, [gameState, context, cursor_x, cursor_y, ctrlKeyDown, canvasRef, auth, board, counting, forbidden_x, forbidden_y, lastMove, isCursorInBounds, getCountingGroup, showMoveNumbers])
368+
}, [gameState, context, cursor_x, cursor_y, ctrlKeyDown, canvasRef, auth, board, counting, forbidden_x, forbidden_y, lastMove, isCursorInBounds, getCountingGroup, showMoveNumbers, end])
369369

370370
useEffect(() => {
371371
if (id === gameId && queueStatus === "up_to_date") {

0 commit comments

Comments
 (0)