Skip to content
Snippets Groups Projects
Commit a3ddf1f3 authored by MEHDI's avatar MEHDI
Browse files

mehdi : added Mountain class

parent dfa26fe2
No related branches found
No related tags found
No related merge requests found
...@@ -94,6 +94,9 @@ public class Controller { ...@@ -94,6 +94,9 @@ public class Controller {
if (squareState.contains(ModelElement.ROAD)) { if (squareState.contains(ModelElement.ROAD)) {
return ViewElement.ROAD; return ViewElement.ROAD;
} }
if (squareState.contains(ModelElement.MOUNTAIN)) {
return ViewElement.MOUNTAIN;
}
return ViewElement.EMPTY; return ViewElement.EMPTY;
} }
......
...@@ -6,6 +6,7 @@ import util.TargetStrategy; ...@@ -6,6 +6,7 @@ import util.TargetStrategy;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.List; import java.util.List;
...@@ -29,17 +30,26 @@ public class FireFighter extends Extinguisher { ...@@ -29,17 +30,26 @@ public class FireFighter extends Extinguisher {
Position currentPosition = this.getPosition(); Position currentPosition = this.getPosition();
Position newPosition = targetStrategy.neighborClosestToFire(currentPosition, firefighterBoard.getFires().keySet(), this.neighbour.getNeighbors()); Position newPosition = targetStrategy.neighborClosestToFire(currentPosition, firefighterBoard.getFires().keySet(), this.neighbour.getNeighbors());
this.setPosition(newPosition); this.setPosition(newPosition);
modifiedPositions.add(currentPosition); modifiedPositions.add(currentPosition);
modifiedPositions.add(newPosition); modifiedPositions.add(newPosition);
extinguish(firefighterBoard,newPosition); extinguish(firefighterBoard,newPosition);
for (Position neighbor : this.neighbour.getNeighbors().get(newPosition)) { for (Position neighbor : this.neighbour.getNeighbors().get(newPosition)) {
extinguish(firefighterBoard,neighbor); extinguish(firefighterBoard,neighbor);
modifiedPositions.add(neighbor); modifiedPositions.add(neighbor);
} }
for(Obstacle obstacle : firefighterBoard.getObstacles().values()){
if(obstacle instanceof Montain){
modifiedPositions.remove(obstacle.getPosition());
}
}
return modifiedPositions; return modifiedPositions;
} }
......
...@@ -10,7 +10,8 @@ public enum ModelElement { ...@@ -10,7 +10,8 @@ public enum ModelElement {
FIREFIGHTER(10), FIREFIGHTER(10),
FIRE(10), FIRE(10),
CLOUD(10), CLOUD(10),
ROAD(5); ROAD(5),
MOUNTAIN(5);
private final int initialNumber; private final int initialNumber;
...@@ -30,6 +31,7 @@ public enum ModelElement { ...@@ -30,6 +31,7 @@ public enum ModelElement {
case ROAD -> new Road(position); case ROAD -> new Road(position);
case FIREFIGHTER -> new FireFighter(position); case FIREFIGHTER -> new FireFighter(position);
case CLOUD -> new Cloud(position); case CLOUD -> new Cloud(position);
case MOUNTAIN -> new Montain(position);
default -> throw new IllegalArgumentException("Unknown ModelElement: " + this); default -> throw new IllegalArgumentException("Unknown ModelElement: " + this);
}; };
......
package model;
import util.Position;
public class Montain extends Obstacle{
public Montain(Position position) {
super(position);
element = ModelElement.MOUNTAIN;
}
}
...@@ -3,7 +3,7 @@ package view; ...@@ -3,7 +3,7 @@ package view;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
public enum ViewElement { public enum ViewElement {
FIREFIGHTER(Color.BLUE), FIRE(Color.RED),CLOUD(Color.LIGHTSKYBLUE),ROAD(Color.GRAY), EMPTY(Color.WHITE); FIREFIGHTER(Color.BLUE), FIRE(Color.RED),CLOUD(Color.LIGHTSKYBLUE),ROAD(Color.GRAY),MOUNTAIN(Color.BROWN), EMPTY(Color.WHITE);
final Color color; final Color color;
ViewElement(Color color) { ViewElement(Color color) {
this.color = color; this.color = color;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment