4 Commits

Author SHA1 Message Date
kfkama 896413211c Bugfix worng colors on unflag 3 years ago
kfkama 9c2de1f2f7 Bugfix numbers not showen 3 years ago
kfkama 3160bf1ed5 Merge branch 'Minesweeper_Game' into feature_Minesweeper_Playfield 3 years ago
kfkama 5c365de0d2 .gitignore fix 3 years ago
  1. 11
      src/main/java/Minesweeper/Cell.java

11
src/main/java/Minesweeper/Cell.java

@ -18,7 +18,7 @@ public class Cell extends JButton {
private static final Color FLAGCOLOR = Color.RED; private static final Color FLAGCOLOR = Color.RED;
private static final Color FLOODEDCOLOR = Color.LIGHT_GRAY; private static final Color FLOODEDCOLOR = Color.LIGHT_GRAY;
private static final Color HIDDENCOLOR = Color.GRAY;
private static final Color HIDDENCOLOR = Color.WHITE;
private static final Color MINECOLOR = Color.BLACK; private static final Color MINECOLOR = Color.BLACK;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Playfield playfield; private Playfield playfield;
@ -33,7 +33,7 @@ public class Cell extends JButton {
cord = _cord; cord = _cord;
playfield = _playfield; playfield = _playfield;
setBackground(Color.white);
setBackground(HIDDENCOLOR);
addActionListener(new ActionListener() { addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -72,11 +72,9 @@ public class Cell extends JButton {
if (flagged) { if (flagged) {
flagged = false; flagged = false;
if (type == CellType.Number) {
setBackground(HIDDENCOLOR); setBackground(HIDDENCOLOR);
if (type == CellType.Number) {
playfield.cellDried(); playfield.cellDried();
} else {
setBackground(MINECOLOR);
} }
} else { } else {
@ -91,7 +89,9 @@ public class Cell extends JButton {
public void reveal() { public void reveal() {
if (type == CellType.Number) { if (type == CellType.Number) {
if(value > 0) {
setText(String.valueOf(value)); setText(String.valueOf(value));
}
} else { } else {
setBackground(MINECOLOR); setBackground(MINECOLOR);
} }
@ -104,6 +104,7 @@ public class Cell extends JButton {
setBackground(FLOODEDCOLOR); setBackground(FLOODEDCOLOR);
setEnabled(false); setEnabled(false);
reveal();
playfield.cellFlooded(); playfield.cellFlooded();
if (value == 0) { if (value == 0) {

Loading…
Cancel
Save