flooded flagged cells now get substracted from flagsPlaced

This commit is contained in:
LunarAkai 2024-03-24 15:22:20 +01:00
commit 7355c2e0df
3 changed files with 13 additions and 4 deletions

View file

@ -356,6 +356,7 @@ public class MinecleanerArena {
Vector2i pos = floodedCells.get(i).position; Vector2i pos = floodedCells.get(i).position;
setBlockForCellType(pos.x, pos.y, floodedCells.get(i)); setBlockForCellType(pos.x, pos.y, floodedCells.get(i));
} }
flagsPlaced = flagsPlaced - currentMinecleanerGame.getFloodedFlaggedCells();
} }
} }
} }

View file

@ -129,8 +129,6 @@ public class MinecleanerManager {
player.sendMessage(ChatColor.YELLOW + "Game Over! Du konntest das Minecleaner-Feld nicht erfolgreich lösen!"); player.sendMessage(ChatColor.YELLOW + "Game Over! Du konntest das Minecleaner-Feld nicht erfolgreich lösen!");
arena.showMines(); arena.showMines();
if(sg != null) { if(sg != null) {
ps.increaseScore(sg, 1); ps.increaseScore(sg, 1);
} }

View file

@ -17,6 +17,7 @@ public class Game {
private Tilemap tilemap; private Tilemap tilemap;
private ArrayList<Cell> floodedCells; private ArrayList<Cell> floodedCells;
private int floodedFlaggedCellsCounter;
private ArrayList<Cell> explodedCells; private ArrayList<Cell> explodedCells;
public Game(MinecleanerPlugin plugin, int width, int mineCount) { public Game(MinecleanerPlugin plugin, int width, int mineCount) {
@ -27,6 +28,7 @@ public class Game {
this.floodedCells = new ArrayList<>(); this.floodedCells = new ArrayList<>();
this.explodedCells = new ArrayList<>(); this.explodedCells = new ArrayList<>();
floodedFlaggedCellsCounter = 0;
} }
public void start() { public void start() {
@ -150,9 +152,12 @@ public class Game {
break; break;
} }
case Empty: { case Empty: {
if(!floodedCells.isEmpty()) {; if(!floodedCells.isEmpty()) {
floodedCells.clear(); floodedCells.clear();
} }
if(floodedFlaggedCellsCounter != 0) {
floodedFlaggedCellsCounter = 0;
}
flood(cell); flood(cell);
checkWinCondition(); checkWinCondition();
break; break;
@ -174,6 +179,7 @@ public class Game {
if(cell.isFlagged()) { if(cell.isFlagged()) {
cell.setFlaggedState(false); cell.setFlaggedState(false);
floodedFlaggedCellsCounter = floodedFlaggedCellsCounter + 1;
} }
cell.setRevealed(); cell.setRevealed();
@ -272,4 +278,8 @@ public class Game {
public ArrayList<Cell> getExplodedCells() { public ArrayList<Cell> getExplodedCells() {
return explodedCells; return explodedCells;
} }
public int getFloodedFlaggedCells() {
return floodedFlaggedCellsCounter;
}
} }