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