Requirement 2 and 3 are continuously failing.
Can someone help me figure out what exactly is the issue here ?
private void openTile(int i, int j) {
if (isGameStopped) {
return;
} else if (gameField[j][i].isOpen) {
return;
} else if (gameField[j][i].isFlag) {
return;
}
gameField[j][i].isOpen = true;
countClosedTiles--;
if (gameField[j][i].isMine) {
setCellValueEx(i, j, Color.RED, MINE);
gameOver();
} else {
score += 5;
if (gameField[j][i].countMineNeighbors == 0) {
setCellValue(i, j, "");
} else {
setCellNumber(i, j, gameField[j][i].countMineNeighbors);
}
List<GameObject> neighbours = getNeighbors(gameField[j][i]);
boolean mined = false;
for (GameObject o : neighbours) {
if (o.isMine) {
mined = true;
break;
}
}
if (!mined) {
for (GameObject o : neighbours) {
if (!o.isOpen) {
openTile(o.x, o.y);
}
}
}
}
setScore(score);
System.out.println(score);
setCellColor(i, j, Color.GREEN);
if (countClosedTiles == countMinesOnField && !gameField[j][i].isMine) {
win();
}
}
package com.codegym.games.minesweeper;
public class GameObject {
public int x;
public int y;
public boolean isMine;
public boolean isFlag;
public int countMineNeighbors;
public boolean isOpen;
public GameObject(int x, int y, boolean isMine) {
this.x = x;
this.y = y;
this.isMine = isMine;
}
}