Browse Source

Flagged number cells count as flooded

feature_Minesweeper_Playfield
kfkama 2 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 (isEnabled()) {
if (flagged) { if (flagged) {
flagged = false; flagged = false;
if (type == CellType.Number) { if (type == CellType.Number) {
setBackground(Color.gray); setBackground(Color.gray);
playfield.cellDried();
} else { } else {
setBackground(Color.red); setBackground(Color.red);
} }
} else { } else {
flagged = true; flagged = true;
setBackground(Color.cyan); 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); System.exit(0);
} }
} }
public void cellDried() {
cellsFlooded--;
}
} }
Loading…
Cancel
Save