Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
EchtkPvL committed Feb 1, 2024
1 parent 921ea68 commit 2a1b20b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
setInterval(gameMeta, 100);
function gameMeta() {
var time = game.getTime();
if (time > 999) window.location.reload();
if (time > 1999) window.location.reload();
var el = document.getElementById('time');
el.innerHTML = time;

Expand Down
18 changes: 18 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class TwitchSweeper {

setup() {
this.score = 0;
this.won = false;
this.x = 0;
this.y = 0;
this.mines = 0;
Expand Down Expand Up @@ -181,6 +182,21 @@ class TwitchSweeper {
} else {
if (this.turns > 1) this.turns--;
}

let remaining = 0;
this.savedata.forEach(function each(item) {
if (Array.isArray(item)) {
// If is array, continue repeat loop
item.forEach(each);
} else {
if (item <= 9) remaining++;
}
});

if (remaining === this.mines) {
this.endGame();
this.won = true;
}
}

endGame() {
Expand All @@ -191,6 +207,8 @@ class TwitchSweeper {
if (this.savedata[i][j] === 9) this.savedata[i][j] = 19;
}
}

this.draw();
}

getTime() {
Expand Down

0 comments on commit 2a1b20b

Please sign in to comment.