From ee1fb098af31536c978fb88c554bfc867080761a Mon Sep 17 00:00:00 2001 From: MasterGordon Date: Sun, 15 Sep 2024 19:45:10 +0200 Subject: [PATCH] fixed auto reveal --- src/App.tsx | 4 ++-- src/Button.tsx | 25 +++++++++++++++++-------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 150679b..8a2ee11 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -62,7 +62,7 @@ function App() { {showScores && (
- {scores.map((score) => ( + {scores.slice(0, 10).map((score) => (

{score.user} - {score.stage}

@@ -88,7 +88,7 @@ function App() {
-
Version: 1.1.2
+
Version: 1.1.3
           Made by MasterGordon -{" "}
           
diff --git a/src/Button.tsx b/src/Button.tsx
index 8046ad1..206d676 100644
--- a/src/Button.tsx
+++ b/src/Button.tsx
@@ -67,14 +67,23 @@ export const Button = ({ x, y }: ButtonProps) => {
               .filter((n) => n).length;
             const value = game.getValue(x, y);
             if (neighborFlagCount === value) {
-              if (!game.isFlagged[x - 1]?.[y]) game.reveal(x - 1, y);
-              if (!game.isFlagged[x - 1]?.[y - 1]) game.reveal(x - 1, y - 1);
-              if (!game.isFlagged[x - 1]?.[y + 1]) game.reveal(x - 1, y + 1);
-              if (!game.isFlagged[x]?.[y - 1]) game.reveal(x, y - 1);
-              if (!game.isFlagged[x]?.[y + 1]) game.reveal(x, y + 1);
-              if (!game.isFlagged[x + 1]?.[y - 1]) game.reveal(x + 1, y - 1);
-              if (!game.isFlagged[x + 1]?.[y]) game.reveal(x + 1, y);
-              if (!game.isFlagged[x + 1]?.[y + 1]) game.reveal(x + 1, y + 1);
+              const currentStage = game.stage;
+              if (!game.isFlagged[x - 1]?.[y] && currentStage == game.stage)
+                game.reveal(x - 1, y);
+              if (!game.isFlagged[x - 1]?.[y - 1] && currentStage == game.stage)
+                game.reveal(x - 1, y - 1);
+              if (!game.isFlagged[x - 1]?.[y + 1] && currentStage == game.stage)
+                game.reveal(x - 1, y + 1);
+              if (!game.isFlagged[x]?.[y - 1] && currentStage == game.stage)
+                game.reveal(x, y - 1);
+              if (!game.isFlagged[x]?.[y + 1] && currentStage == game.stage)
+                game.reveal(x, y + 1);
+              if (!game.isFlagged[x + 1]?.[y - 1] && currentStage == game.stage)
+                game.reveal(x + 1, y - 1);
+              if (!game.isFlagged[x + 1]?.[y] && currentStage == game.stage)
+                game.reveal(x + 1, y);
+              if (!game.isFlagged[x + 1]?.[y + 1] && currentStage == game.stage)
+                game.reveal(x + 1, y + 1);
             }
           }
         } else if (e.button === 2 && !game.isRevealed[x][y]) {