test pour afficher les tuiles d'une manière différente

This commit is contained in:
2024-11-16 10:12:24 +01:00
parent dd14eaab2e
commit 22cf8adf3f
9 changed files with 238 additions and 14 deletions

View File

@@ -0,0 +1,48 @@
public class Tile {
private Terrain[][] hexMatrix;
// Constructeur pour une tuile avec un seul terrain
public Tile(Terrain terrain) {
hexMatrix = new Terrain[3][3];
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
hexMatrix[i][j] = terrain;
}
}
}
// Constructeur pour une tuile avec deux terrains
public Tile(Terrain terrain1, Terrain terrain2, int configuration) {
hexMatrix = new Terrain[3][3];
switch (configuration) {
case 1:
fillSides(terrain1, terrain2, 1, 5);
break;
case 2:
fillSides(terrain1, terrain2, 2, 4);
break;
case 3:
fillSides(terrain1, terrain2, 3, 3);
break;
default:
throw new IllegalArgumentException("Configuration invalide");
}
}
private void fillSides(Terrain terrain1, Terrain terrain2, int side1, int side2) {
// Exemple simplifié
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if ((i + j) % 2 == 0) { // Terrain1 sur certaines cases
hexMatrix[i][j] = terrain1;
} else {
hexMatrix[i][j] = terrain2;
}
}
}
}
public Terrain[][] getHexMatrix() {
return hexMatrix;
}
}