fixed auto reveal
This commit is contained in:
parent
fcbfad55a4
commit
ee1fb098af
|
|
@ -62,7 +62,7 @@ function App() {
|
|||
</button>
|
||||
{showScores && (
|
||||
<div>
|
||||
{scores.map((score) => (
|
||||
{scores.slice(0, 10).map((score) => (
|
||||
<p key={score.user}>
|
||||
{score.user} - {score.stage}
|
||||
</p>
|
||||
|
|
@ -88,7 +88,7 @@ function App() {
|
|||
</div>
|
||||
</div>
|
||||
<div className="footer">
|
||||
<pre>Version: 1.1.2</pre>
|
||||
<pre>Version: 1.1.3</pre>
|
||||
<pre>
|
||||
Made by MasterGordon -{" "}
|
||||
<a target="_blank" href="https://github.com/MasterGordon/minesweeper">
|
||||
|
|
|
|||
|
|
@ -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]) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue