Skip to content
Snippets Groups Projects
Commit 06b99736 authored by BELHACHEMI Mehdi's avatar BELHACHEMI Mehdi
Browse files

improving cloud class so that it extinguises neighbours

parent 2b08df44
Branches
No related tags found
No related merge requests found
Pipeline #41091 passed
...@@ -30,6 +30,11 @@ public class Cloud extends Extinguisher { ...@@ -30,6 +30,11 @@ public class Cloud extends Extinguisher {
extinguish(firefighterBoard,newPosition); extinguish(firefighterBoard,newPosition);
for (Position neighbor : this.neighbour.getNeighbors().get(newPosition)) {
extinguish(firefighterBoard,neighbor);
modifiedPositions.add(neighbor);
}
return modifiedPositions; return modifiedPositions;
} }
......
...@@ -10,11 +10,12 @@ import util.TargetStrategy; ...@@ -10,11 +10,12 @@ import util.TargetStrategy;
import java.util.List; import java.util.List;
public abstract class Extinguisher implements model.Elements.element { public abstract class Extinguisher implements model.Elements.element {
protected final TargetStrategy targetStrategy = new TargetStrategy(); protected final TargetStrategy targetStrategy = new TargetStrategy();
protected Neighbour neighbour; protected Neighbour neighbour;
protected Position position; protected Position position;
protected ModelElement element; protected ModelElement element;
public Extinguisher(Position position){ public Extinguisher(Position position){
this.position = position; this.position = position;
} }
...@@ -35,7 +36,6 @@ public abstract class Extinguisher implements model.Elements.element { ...@@ -35,7 +36,6 @@ public abstract class Extinguisher implements model.Elements.element {
if (board.getFires().containsKey(position)) { if (board.getFires().containsKey(position)) {
board.getFires().remove(position); board.getFires().remove(position);
} }
} }
public abstract List<Position> update(Board<List<ModelElement>> firefighterBoard); public abstract List<Position> update(Board<List<ModelElement>> firefighterBoard);
......
...@@ -60,7 +60,7 @@ public class Fire implements element { ...@@ -60,7 +60,7 @@ public class Fire implements element {
return modifiedPositions; return modifiedPositions;
} }
public List<Position>removeMountainAndRoads(Board<List<ModelElement>> firefighterBoard,Position position){ private List<Position>removeMountainAndRoads(Board<List<ModelElement>> firefighterBoard,Position position){
List<Position>neighboursAvailable; List<Position>neighboursAvailable;
neighboursAvailable = this.neighbour.getNeighbors().get(position); neighboursAvailable = this.neighbour.getNeighbors().get(position);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment