possibilité d'ajouté des tuiles sur le plateau mais problème de position des tuiles

This commit is contained in:
2024-11-16 14:12:55 +01:00
parent 25d00a5303
commit 980b9c4aa8
5 changed files with 133 additions and 80 deletions

View File

@@ -1,48 +1,11 @@
public class Tile {
private Terrain[][] hexMatrix;
private Terrain terrain; // Un seul terrain pour toute la tuile
// 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;
}
}
this.terrain = 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;
public Terrain getTerrain() {
return terrain;
}
}