Skip to content

Commit 17d946c

Browse files
authored
更新 script.js fix check mine bug
1 parent ada1744 commit 17d946c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

05-Minesweeper-Game/script.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ function checkMine(r, c) {
138138
if (board[r][c].classList.contains("tile-clicked")) {
139139
return;
140140
}
141+
// 如果方块被标记为旗帜,则移除旗帜并减少flagCount
142+
if (tile.innerText == "🚩") {
143+
tile.innerText = "";
144+
flagCount -= 1;
145+
document.getElementById("flag-button").innerText = "🚩" + (flagCount == 0 ? "" : flagCount);
146+
}
141147

142148
board[r][c].classList.add("tile-clicked");
143149
tilesClicked += 1;

0 commit comments

Comments
 (0)