diff --git a/src/App.tsx b/src/App.tsx
index 055308d..dc97e3b 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,5 +1,5 @@
import { Button } from "./Button";
-import { useGame } from "./GameContext";
+import { updateGame, useGame } from "./GameContext";
import Timer from "./Timer";
import Options from "./Options";
@@ -10,6 +10,9 @@ function App() {
Minesweeper
+
@@ -28,6 +31,15 @@ function App() {
+
);
}
diff --git a/src/Button.tsx b/src/Button.tsx
index 6d43a95..6dd8ffe 100644
--- a/src/Button.tsx
+++ b/src/Button.tsx
@@ -53,7 +53,7 @@ export const Button = ({ x, y }: ButtonProps) => {
}
if (e.button === 0) {
// Left click
- if (!game?.isRevealed[x][y]) {
+ if (!game?.isRevealed[x][y] && !game?.isFlagged[x][y]) {
updateGame((game) => game?.reveal(x, y));
} else {
const neighborFlagCount = game
diff --git a/src/Game.ts b/src/Game.ts
index a5ccfb4..32043d1 100644
--- a/src/Game.ts
+++ b/src/Game.ts
@@ -128,4 +128,17 @@ export class Game {
const mines = neighbors.filter((n) => n).length;
return mines;
}
+
+ quickStart() {
+ for (let i = 0; i < this.getWidth(); i++) {
+ for (let j = 0; j < this.getHeight(); j++) {
+ const value = this.getValue(i, j);
+ const isMine = this.isMine(i, j);
+ if (value === 0 && !isMine) {
+ this.reveal(i, j);
+ return;
+ }
+ }
+ }
+ }
}
diff --git a/src/index.css b/src/index.css
index f29c0c2..3b2dd8b 100644
--- a/src/index.css
+++ b/src/index.css
@@ -44,3 +44,16 @@ body {
font-size: 2rem;
font-family: monospace;
}
+
+.footer {
+ display: flex;
+ flex-direction: column;
+ /* justify-content: space-between; */
+ align-items: center;
+ font-size: 1rem;
+ font-family: monospace;
+}
+
+pre {
+ margin: 0;
+}