Skip to content

Commit

Permalink
no counting after game has ended
Browse files Browse the repository at this point in the history
  • Loading branch information
h908714124 committed Sep 5, 2024
1 parent 59cc80a commit b2923ad
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/main/client/src/feature/game/Game.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ function Board({gameState, setGameState}) {
let dragging = useLayoutStore(state => state.dragging)
let muted = useMuteStore(state => state.muted)
let howler = useRef()
let showMoveNumbers = ctrlKeyDown && (isKibitz(gameState, auth) || gameHasEnded(gameState))
let end = gameHasEnded(gameState)
let showMoveNumbers = ctrlKeyDown && (isKibitz(gameState, auth) || end)
let intervalIdRef = useRef()

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

let getCountingGroup = useCallback(() => {
if (gameHasEnded(gameState)) {
return undefined
}
if (!counting) {
if (end || !counting) {
return undefined
}
if (!isCursorInBounds()) {
Expand All @@ -190,7 +188,7 @@ function Board({gameState, setGameState}) {
return undefined
}
return has
}, [gameState, counting, board, isCursorInBounds])
}, [counting, board, isCursorInBounds, end])

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

useEffect(() => {
if (!showMoveNumbers) {
if (!showMoveNumbers && !counting && !end) {
paintLastMove(context, lastMove, timeout)
}
}, [showMoveNumbers, context, lastMove, timeout])
}, [showMoveNumbers, context, lastMove, timeout, counting, end])

let onMouseMove = useCallback((e) => {
if (dragging) {
Expand Down Expand Up @@ -286,7 +284,7 @@ function Board({gameState, setGameState}) {
}
return
}
if (gameHasEnded(gameState)) {
if (end) {
return
}
if (!board.length) {
Expand Down Expand Up @@ -323,7 +321,7 @@ function Board({gameState, setGameState}) {
destination: "/app/game/move",
body: JSON.stringify(move),
})
}, [gameState, setGameState, auth, board, stompClient, counting, forbidden_x, forbidden_y, myColor, playClickSound, isCursorInBounds, showMoveNumbers, resetCountdown])
}, [gameState, setGameState, auth, board, stompClient, counting, forbidden_x, forbidden_y, myColor, playClickSound, isCursorInBounds, showMoveNumbers, resetCountdown, end])

useEffect(() => {
if (!board.length) {
Expand All @@ -344,8 +342,10 @@ function Board({gameState, setGameState}) {
paintStones(context, board, showMoveNumbers)
if (showMoveNumbers) {
paintMoveNumbers(context, board)
} else {
} else if (!counting && !end) {
paintLastMove(context, lastMove, timeoutRef.current)
} else {
paintLastMove(context, lastMove)
}
if (currentPlayer(gameState) !== auth.name) {
return
Expand All @@ -362,10 +362,10 @@ function Board({gameState, setGameState}) {
if (cursor_x == forbidden_x && cursor_y == forbidden_y) {
return
}
if (!showMoveNumbers) {
if (!showMoveNumbers && !counting && !end) {
paintShadow(context, cursor_x, cursor_y, currentColor(gameState))
}
}, [gameState, context, cursor_x, cursor_y, ctrlKeyDown, canvasRef, auth, board, counting, forbidden_x, forbidden_y, lastMove, isCursorInBounds, getCountingGroup, showMoveNumbers])
}, [gameState, context, cursor_x, cursor_y, ctrlKeyDown, canvasRef, auth, board, counting, forbidden_x, forbidden_y, lastMove, isCursorInBounds, getCountingGroup, showMoveNumbers, end])

useEffect(() => {
if (id === gameId && queueStatus === "up_to_date") {
Expand Down

0 comments on commit b2923ad

Please sign in to comment.