Победил рекурсию, теперь валидатор не берёт первый пункт.
Подскажите, в чём дело?
package com.javarush.games.minesweeper;
import com.javarush.engine.cell.*;
import java.util.ArrayList;
public class MinesweeperGame extends Game {
final static private int SIDE = 9;
private GameObject gameField[][] = new GameObject[SIDE][SIDE];
private int countMinesOnField, countFlags;
final static private String MINE = "\uD83D\uDCA3";
final static private String FLAG = "\uD83D\uDEA9";
public void initialize(){
setScreenSize(SIDE,SIDE);
createGame();
}
private void createGame() {
boolean k;
for (int i=0;i<SIDE;i++) {
for(int j=0;j<SIDE;j++) {
k = false;
if (getRandomNumber(10)<1) {
countMinesOnField++;
k = true;
}
gameField[j][i] = new GameObject(i, j, k);
setCellColor(i,j,Color.PURPLE);
if (k) setCellColor(i,j,Color.GOLD);
}
}
countMineNeighbors();
countFlags=countMinesOnField;
}
private void countMineNeighbors() {
for (int i=0;i<SIDE;i++) {
for(int j=0;j<SIDE;j++) {
if (!gameField[j][i].isMine) {
for (GameObject o : getNeighbors(gameField[j][i])) {
if (o.isMine) gameField[j][i].countMineNeighbors++;
}
}
}
}
}
private ArrayList<GameObject> getNeighbors(GameObject o){
ArrayList<GameObject> l = new ArrayList<>();
for (int i=o.x-1;i<o.x+2;i++) {
for (int j=o.y-1;j<o.y+2;j++) {
if ( !(i<0 || j<0 || i>SIDE-1 || j>SIDE-1 || (i==o.x && j==o.y))) l.add(gameField[j][i]);
}
}
return l;
}
private void openTile(int a, int b) {
if (!gameField[b][a].isOpen) {
gameField[b][a].isOpen = true;
if (gameField[b][a].isMine) {
setCellValue(a,b,MINE);
setCellColor(a,b,Color.RED);
} else {
if (gameField[b][a].countMineNeighbors==0) {
setCellColor(a,b,Color.GREEN);
setCellValue(a,b,"");
for (GameObject o : getNeighbors(gameField[b][a])) {
if (!o.isMine&&o.countMineNeighbors==0&&!o.isOpen) openTile(o.x, o.y);
}
} else {
setCellColor(a,b,Color.AQUA);
setCellNumber(a,b,gameField[b][a].countMineNeighbors);
}
}
}
}
public void onMouseLeftClick(int a, int b) {
openTile(a, b);
}
}