|
@ -13,7 +13,6 @@ public class Playfield { |
|
|
private int bombAmount; |
|
|
private int bombAmount; |
|
|
private int cellsFlooded = 0; |
|
|
private int cellsFlooded = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Playfield(MinesweeperGame _MsG, int _Size, int _bombAmount) { |
|
|
public Playfield(MinesweeperGame _MsG, int _Size, int _bombAmount) { |
|
|
MsG = _MsG; |
|
|
MsG = _MsG; |
|
|
Size = _Size; |
|
|
Size = _Size; |
|
@ -65,7 +64,6 @@ public class Playfield { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void reset() { |
|
|
public void reset() { |
|
|
JOptionPane.showMessageDialog(MsG,"KABOOM! Try again!"); |
|
|
|
|
|
cellsFlooded = 0; |
|
|
cellsFlooded = 0; |
|
|
for (int i = 0; i < Size; i++) { |
|
|
for (int i = 0; i < Size; i++) { |
|
|
for (int j = 0; j < Size; j++) { |
|
|
for (int j = 0; j < Size; j++) { |
|
@ -129,9 +127,9 @@ public class Playfield { |
|
|
|
|
|
|
|
|
public void cellFlooded() { |
|
|
public void cellFlooded() { |
|
|
cellsFlooded++; |
|
|
cellsFlooded++; |
|
|
if(cellsFlooded >= Size * Size - bombAmount) { |
|
|
|
|
|
|
|
|
if (cellsFlooded >= Size * Size - bombAmount) { |
|
|
JOptionPane.showMessageDialog(MsG, "You won, congratulations!"); |
|
|
JOptionPane.showMessageDialog(MsG, "You won, congratulations!"); |
|
|
System.exit(0); |
|
|
|
|
|
|
|
|
reset(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|