floodedflaggedcellscounter now gets resettet at number cells too

This commit is contained in:
LunarAkai 2024-03-24 17:32:41 +01:00
commit cb1dfca31c

View file

@ -155,14 +155,13 @@ public class Game {
if(!floodedCells.isEmpty()) {
floodedCells.clear();
}
if(floodedFlaggedCellsCounter != 0) {
floodedFlaggedCellsCounter = 0;
}
resetFloodedFlaggedCellCounter();
flood(cell);
checkWinCondition();
break;
}
default: {
resetFloodedFlaggedCellCounter();
cell.setRevealed();
state[x][y] = cell;
checkWinCondition();
@ -173,6 +172,12 @@ public class Game {
board.draw(state, tilemap);
}
private void resetFloodedFlaggedCellCounter() {
if(floodedFlaggedCellsCounter > 0) {
floodedFlaggedCellsCounter = 0;
}
}
public void flood(Cell cell) {
if(cell.isRevealed()) return;
if(cell.getType() == Cell.CellType.Mine || cell.getType() == Cell.CellType.Invalid || cell.position == null) return;