I think i implemented the score correctly, a won game always ends up around 370~390 (405-5per mine).
i have tried to put setScore(score+=5) but it didnt like that either.
i have also tried to call setScore(score) at the end of openTile(); didnt count that;
I am kind of out of ideas, does anyone have other insights?
i have since refactored the openTile method to:
private void openTile(int x, int y){
GameObject cell = gameField[y][x];
if (cell.isMine && !isGameStopped && !cell.isFlag && !cell.isOpen) {
setCellValueEx(x,y,Color.RED,MINE);
gameOver();
} else if (!isGameStopped && !cell.isFlag && !cell.isOpen){
cell.isOpen = true;
setScore(score+=5);
countClosedTiles--;
setCellColor(x,y,Color.GREEN);
if (cell.countMineNeighbors==0){
setCellValue(x,y,"");
for(GameObject stuff : getNeighbors(cell)){
if(!stuff.isOpen && !stuff.isMine ){
openTile(stuff.x,stuff.y);
}
}
} else {
setCellNumber(x,y,cell.countMineNeighbors);
}
}
if(countClosedTiles == countMinesOnField){
win();
}
}
but still no validationpackage com.codegym.games.minesweeper;
import com.codegym.engine.cell.*;
public class GameObject {
public int x;
public int y;
public boolean isMine;
public int countMineNeighbors = 0;
public boolean isOpen = false;
public boolean isFlag = false;
public GameObject(int x, int y, boolean isMine){
this.x = x;
this.y = y;
this.isMine = isMine;
}
}