|
@ -8,18 +8,20 @@ public class Playfield { |
|
|
public int Size; |
|
|
public int Size; |
|
|
private MinesweeperGame MsG; |
|
|
private MinesweeperGame MsG; |
|
|
public Cell[][] cells; |
|
|
public Cell[][] cells; |
|
|
|
|
|
private int bombAmount; |
|
|
|
|
|
|
|
|
public Playfield(MinesweeperGame _MsG, int _Size, int _bombAmount) { |
|
|
public Playfield(MinesweeperGame _MsG, int _Size, int _bombAmount) { |
|
|
MsG = _MsG; |
|
|
MsG = _MsG; |
|
|
Size = _Size; |
|
|
Size = _Size; |
|
|
generatePlayfield(_bombAmount); |
|
|
|
|
|
|
|
|
bombAmount = _bombAmount; |
|
|
|
|
|
generatePlayfield(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void generatePlayfield(int _bombAmount) { |
|
|
|
|
|
|
|
|
public void generatePlayfield() { |
|
|
|
|
|
|
|
|
cells = new Cell[Size][Size]; |
|
|
cells = new Cell[Size][Size]; |
|
|
|
|
|
|
|
|
int[] bPlacement = new int[_bombAmount]; |
|
|
|
|
|
|
|
|
int[] bPlacement = new int[bombAmount]; |
|
|
for (int i = 0; i < bPlacement.length; i++) { |
|
|
for (int i = 0; i < bPlacement.length; i++) { |
|
|
bPlacement[i] = (int) (Math.random() * Size * Size); |
|
|
bPlacement[i] = (int) (Math.random() * Size * Size); |
|
|
|
|
|
|
|
@ -58,6 +60,15 @@ public class Playfield { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void reset() { |
|
|
|
|
|
for (int i = 0; i < Size; i++) { |
|
|
|
|
|
for (int j = 0; j < Size; j++) { |
|
|
|
|
|
MsG.remove(cells[i][j]); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
generatePlayfield(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public void calculateBombProximity(int row, int column) { |
|
|
public void calculateBombProximity(int row, int column) { |
|
|
|
|
|
|
|
|
if (row > 0) { |
|
|
if (row > 0) { |
|
|