Files
SAE31_2024/src/main/java/model/Tile.java

42 lines
1.1 KiB
Java
Raw Normal View History

2024-10-21 13:21:22 +02:00
package model;
public class Tile {
private int id; // Ajoute l'attribut id
2024-10-25 00:59:58 +02:00
private TerrainType[] terrains; // 2 terrains maximum par tuile
private int segmentsForTerrain1;
private int rotation;
2024-10-21 13:21:22 +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;
}
public void rotateClockwise() {
rotation = (rotation + 1) % 6;
}
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-21 13:21:22 +02:00
public int getRotation() {
return rotation;
2024-10-25 00:59:58 +02:00
}
public int getId() {
return id;
2024-10-21 13:21:22 +02:00
}
public TerrainType getTerrain(int index) {
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) {
return index == 0 ? segmentsForTerrain1 : 6 - segmentsForTerrain1;
2024-10-21 13:21:22 +02:00
}
}