Skip to content
Snippets Groups Projects
Commit 3eb15055 authored by ousseyn01's avatar ousseyn01
Browse files

FirefighterBoard.java is DONE

parent 3b908ed8
No related branches found
No related tags found
No related merge requests found
Pipeline #42818 passed
......@@ -29,8 +29,6 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
private final List<ElementHandler> handlers = new ArrayList<>();
public FirefighterBoard(int columnCount, int rowCount, int initialFireCount, int initialFirefighterCount, int initialCloudCount, int initialMountainCount) {
this.columnCount = columnCount;
this.rowCount = rowCount;
......@@ -51,27 +49,19 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
this.initialFirefighterCount = initialFirefighterCount;
this.initialCloudCount = initialCloudCount;
initializeElements();
nextGenerationUpdater = new NextGenerationUpdater(fire, clouds, firefighters, mountains, neighbors);
terrainElements = new ArrayList<>();
for (int i = 0; i < 5; i++) {
Position position = randomPosition();
terrainElements.add(new Route(position));
}
for (int i = 0; i < 5; i++) {
Position position = randomPosition();
terrainElements.add(new Rocaille(position));
}
handlers.add(new FireHandler(fire));
handlers.add(new FirefighterHandler(firefighters));
handlers.add(new CloudHandler(clouds, neighbors));
handlers.add(new MountainHandler(mountains));
handlers.add(new TerrainHandler(terrainElements, Route.class, ModelElement.ROUTE));
handlers.add(new TerrainHandler(terrainElements, Rocaille.class, ModelElement.ROCAILLE)); }
handlers.add(new TerrainHandler(terrainElements, Rocaille.class, ModelElement.ROCAILLE));
}
/*
Initalisation of elements
*/
public void initializeElements() {
firefighters = new ArrayList<>();
clouds = new ArrayList<>();
......@@ -79,26 +69,20 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
Set<Position> firePositions = new HashSet<>();
terrainElements = new ArrayList<>();
// List<Position> initialFirefighterPositions = new ArrayList<>();
int targetColumn = 9;
for (int row = 0; row < rowCount; row++) {
Position position = new Position(row, targetColumn);
terrainElements.add(new Route(position));
}
for (int index = 0; index < initialCloudCount; index++) {
clouds.add(new Cloud(randomPosition(), neighbors));
}
for (int index = 0; index < initialFireCount; index++)
firePositions.add(randomPosition());
fire = new Fire(firePositions, neighbors);
for (int index = 0; index < initialFirefighterCount; index++) {
firefighters.add(new Firefighter(randomPosition()));
}
for (int index = 0; index < initialCloudCount; index++) {
clouds.add(new Cloud(randomPosition(), neighbors));
}
......@@ -110,11 +94,9 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
}
private boolean isPositionOccupied(Position position) {
// Vérifie si la position est occupée par une montagne
for (Mountain mountain : mountains) {
if (mountain.getPosition().equals(position)) return true;
}
// Vérifie les autres éléments
for (Firefighter firefighter : firefighters) {
if (firefighter.getPosition().equals(position)) return true;
}
......@@ -128,7 +110,6 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
return new Position(randomGenerator.nextInt(rowCount), randomGenerator.nextInt(columnCount));
}
@Override
public int rowCount() {
return rowCount;
......@@ -154,8 +135,8 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
public void reset() {
initializeElements();
nextGenerationUpdater.resetStep();
}
@Override
public List<ModelElement> getState(Position position) {
List<ModelElement> result = new ArrayList<>();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment