main #3

Merged
sageTheDm merged 3 commits from interstellar_development/interstellar_website:main into main 2025-01-06 11:26:33 +01:00
Showing only changes of commit 0754689f33 - Show all commits

View file

@ -36,7 +36,7 @@ class Minesweeper {
for (let i = 0; i < this.bombAmount; i++) { for (let i = 0; i < this.bombAmount; i++) {
let x = Math.floor(Math.random() * this.width); let x = Math.floor(Math.random() * this.width);
let y = Math.floor(Math.random() * this.height); let y = Math.floor(Math.random() * this.height);
this.bombs[x][y] && this.field[x][y] != 0 ? i-- : this.bombs[x][y] = true; (this.bombs[x][y] || this.field[x][y] == 0) ? i-- : this.bombs[x][y] = true;
} }
this.firstClick = true; this.firstClick = true;
} }
@ -58,11 +58,14 @@ class Minesweeper {
for (let y = 0; y < this.field[x].length; y++) { for (let y = 0; y < this.field[x].length; y++) {
if (this.field[x][y] != 0 && !this.bombs[x][y]) { if (this.field[x][y] != 0 && !this.bombs[x][y]) {
return; return;
} else if (this.field[x][y] == 0 && this.bombs[x][y]) {
alert(`[ERROR]: Square (${x}|${y}) should not be a bomb!`);
this.bombs[x][y] = false;
} }
} }
} }
this.drawField(); this.drawField();
alert("You won!"); alert('You won!');
window.location.reload(); window.location.reload();
} }
@ -88,7 +91,7 @@ class Minesweeper {
uncoverSquare(x, y) { uncoverSquare(x, y) {
if (x < this.field.length && x >= 0 && y < this.field[0].length && y >= 0) { if (x < this.field.length && x >= 0 && y < this.field[0].length && y >= 0) {
if (this.bombs[x][y] && this.field[x][y] == 1) { if (this.bombs[x][y] && this.field[x][y] == 1) {
alert("You lost!"); alert('You lost!');
window.location.reload(); window.location.reload();
} else if (this.field[x][y] == 1) { } else if (this.field[x][y] == 1) {
this.field[x][y] = 0; this.field[x][y] = 0;