Skip to content

Commit 160567c

Browse files
committed
negative number support on font and block on negative mines
1 parent 985208e commit 160567c

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

game.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ class MinesweeperRound {
140140

141141
val = this.padValue(val, count);
142142
let numIndex = +val.charAt(i);
143+
if (val.charAt(i) === "-") {
144+
numIndex = numImages.length - 1;
145+
}
143146
let charImg = numImages[numIndex];
144147
if (charImg) {
145148
image(charImg, charX, charY, charWidth, charHeight);
@@ -279,6 +282,11 @@ class MinesweeperRound {
279282

280283
flagCell(x, y) {
281284
let gCell = this.grid[x + y * this.width];
285+
286+
if (this.mines - this.flagged <= 0 && !gCell.flagged) {
287+
return;
288+
}
289+
282290
if (!gCell.revealed) {
283291
gCell.flagged = !gCell.flagged;
284292
if (gCell.flagged) {

0 commit comments

Comments
 (0)