2024-10-21 13:21:22 +02:00
|
|
|
package model;
|
|
|
|
|
|
|
|
public class Tile {
|
2024-10-26 22:31:34 +02:00
|
|
|
private int id; // Ajoute l'attribut id
|
2024-10-25 00:59:58 +02:00
|
|
|
private TerrainType[] terrains; // 2 terrains maximum par tuile
|
2024-10-26 22:31:34 +02:00
|
|
|
private int segmentsForTerrain1;
|
2024-10-25 22:22:11 +02:00
|
|
|
private int rotation;
|
2024-10-21 13:21:22 +02:00
|
|
|
|
2024-10-26 22:31:34 +02:00
|
|
|
// Constructeur modifié pour inclure l'ID
|
|
|
|
public Tile(int id, TerrainType terrain1, TerrainType terrain2, int segmentsForTerrain1) {
|
|
|
|
this.id = id;
|
|
|
|
this.terrains = new TerrainType[]{terrain1, terrain2};
|
|
|
|
this.segmentsForTerrain1 = segmentsForTerrain1;
|
|
|
|
this.rotation = 0;
|
2024-10-25 22:22:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void rotateClockwise() {
|
2024-10-26 22:31:34 +02:00
|
|
|
rotation = (rotation + 1) % 6;
|
2024-10-25 22:22:11 +02:00
|
|
|
}
|
|
|
|
|
2024-10-26 22:31:34 +02:00
|
|
|
public void rotateCounterClockwise() {
|
|
|
|
rotation = (rotation + 5) % 6; // Tourner dans le sens inverse, équivalent à -1 dans un modulo 6
|
2024-10-21 13:21:22 +02:00
|
|
|
}
|
2024-10-26 22:31:34 +02:00
|
|
|
|
2024-10-21 13:21:22 +02:00
|
|
|
|
2024-10-26 22:31:34 +02:00
|
|
|
public int getRotation() {
|
|
|
|
return rotation;
|
2024-10-25 00:59:58 +02:00
|
|
|
}
|
|
|
|
|
2024-10-26 22:31:34 +02:00
|
|
|
public int getId() {
|
|
|
|
return id;
|
2024-10-21 13:21:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public TerrainType getTerrain(int index) {
|
2024-10-26 22:31:34 +02:00
|
|
|
return index >= 0 && index < 2 ? terrains[index] : null;
|
2024-10-21 13:21:22 +02:00
|
|
|
}
|
|
|
|
|
2024-10-25 00:59:58 +02:00
|
|
|
public int getSegmentsForTerrain(int index) {
|
2024-10-26 22:31:34 +02:00
|
|
|
return index == 0 ? segmentsForTerrain1 : 6 - segmentsForTerrain1;
|
2024-10-21 13:21:22 +02:00
|
|
|
}
|
|
|
|
}
|