Browse Source

Flagged number cells count as flooded

feature_Minesweeper_Playfield
kfkama 3 years ago
parent
commit
5d1aba4408
  1. 8
      src/main/java/Minesweeper/Cell.java
  2. 4
      src/main/java/Minesweeper/Playfield.java

8
src/main/java/Minesweeper/Cell.java

@ -62,16 +62,20 @@ public class Cell extends JButton {
if (isEnabled()) {
if (flagged) {
flagged = false;
if (type == CellType.Number) {
setBackground(Color.gray);
playfield.cellDried();
} else {
setBackground(Color.red);
}
} else {
flagged = true;
setBackground(Color.cyan);
if (type == CellType.Number) {
playfield.cellFlooded();
}
}
}
}

4
src/main/java/Minesweeper/Playfield.java

@ -134,4 +134,8 @@ public class Playfield {
System.exit(0);
}
}
public void cellDried() {
cellsFlooded--;
}
}
Loading…
Cancel
Save