diff --git a/components/board.tsx b/components/board.tsx index add8c71..57e2531 100644 --- a/components/board.tsx +++ b/components/board.tsx @@ -87,7 +87,7 @@ export default function Board() { return (
- {status === "won" && } + {status === "won" && } {status === "lost" && }
{renderTiles()}
{renderGrid()}
diff --git a/context/game-context.tsx b/context/game-context.tsx index a654a22..16cc100 100644 --- a/context/game-context.tsx +++ b/context/game-context.tsx @@ -78,7 +78,7 @@ export default function GameProvider({ children }: PropsWithChildren) { if (isWon) { dispatch({ type: "update_status", status: "won" }); - return + return; } const { tiles, board } = gameState; @@ -86,16 +86,26 @@ export default function GameProvider({ children }: PropsWithChildren) { const maxIndex = tileCountPerDimension - 1; for (let x = 0; x < maxIndex; x += 1) { for (let y = 0; y < maxIndex; y += 1) { - if (isNil(gameState.board[x][y]) || isNil(gameState.board[x + 1][y]) || isNil(gameState.board[x][y + 1])) { - return + if ( + isNil(gameState.board[x][y]) || + isNil(gameState.board[x + 1][y]) || + isNil(gameState.board[x][y + 1]) + ) { + return; } - if (x < maxIndex && tiles[board[x][y]].value === tiles[board[x + 1][y]].value) { - return + if ( + x < maxIndex && + tiles[board[x][y]].value === tiles[board[x + 1][y]].value + ) { + return; } - if (y < maxIndex && tiles[board[x][y]].value === tiles[board[x][y + 1]].value) { - return + if ( + y < maxIndex && + tiles[board[x][y]].value === tiles[board[x][y + 1]].value + ) { + return; } } } @@ -112,7 +122,6 @@ export default function GameProvider({ children }: PropsWithChildren) { } }, [gameState.hasChanged]); - useEffect(() => { if (!gameState.hasChanged) { checkGameState(); diff --git a/styles/splash.module.css b/styles/splash.module.css index 5855bca..36d17c5 100644 --- a/styles/splash.module.css +++ b/styles/splash.module.css @@ -15,7 +15,7 @@ .win { background: rgba(237, 194, 46, 0.6); - color: white + color: white; } .splash > div { @@ -36,7 +36,7 @@ border-radius: calc(var(--pixel-size) * 0.5); font-size: calc(var(--pixel-size) * 2); line-height: calc(var(--pixel-size) * 4); - padding: calc(var(--pixel-size) * .5) calc(var(--pixel-size) * 2); + padding: calc(var(--pixel-size) * 0.5) calc(var(--pixel-size) * 2); font-weight: bold; color: white; cursor: pointer;