ajout java doc + Makefile + mariadb.jar
This commit is contained in:
@@ -1,11 +1,24 @@
|
||||
// src/main/java/model/Tile.java
|
||||
package model;
|
||||
|
||||
/**
|
||||
* La classe <code>Tile</code> représente une tuile dans le jeu, qui peut contenir un ou deux types de terrains.
|
||||
* Chaque tuile a un identifiant unique, un tableau de types de terrains, et gère sa rotation.
|
||||
*/
|
||||
public class Tile {
|
||||
private int id; // ID de la tuile
|
||||
private TerrainType[] terrains; // Tableau contenant deux types de terrains (ex. MER, FORET)
|
||||
private int segmentsForTerrain1; // Nombre de segments pour le premier terrain
|
||||
private int rotation; // Rotation de la tuile (en multiple de 60 degrés)
|
||||
|
||||
/**
|
||||
* Constructeur pour créer une nouvelle tuile avec deux types de terrains.
|
||||
*
|
||||
* @param id L'identifiant de la tuile.
|
||||
* @param terrain1 Le premier type de terrain.
|
||||
* @param terrain2 Le deuxième type de terrain.
|
||||
* @param segmentsForTerrain1 Le nombre de segments pour le premier terrain.
|
||||
*/
|
||||
public Tile(int id, TerrainType terrain1, TerrainType terrain2, int segmentsForTerrain1) {
|
||||
this.id = id;
|
||||
this.terrains = new TerrainType[]{terrain1, terrain2};
|
||||
@@ -13,7 +26,12 @@ public class Tile {
|
||||
this.rotation = 0; // Initialisation de la rotation à 0
|
||||
}
|
||||
|
||||
// Renvoie le terrain pour l'index donné (0 ou 1)
|
||||
/**
|
||||
* Renvoie le terrain pour l'index donné (0 ou 1).
|
||||
*
|
||||
* @param index L'index du terrain à récupérer.
|
||||
* @return Le type de terrain à l'index spécifié, ou null si l'index est invalide.
|
||||
*/
|
||||
public TerrainType getTerrain(int index) {
|
||||
if (index >= 0 && index < terrains.length) {
|
||||
return terrains[index];
|
||||
@@ -21,7 +39,12 @@ public class Tile {
|
||||
return null; // Retourne null si l'index est invalide
|
||||
}
|
||||
|
||||
// Méthode pour obtenir le terrain associé à un segment spécifique (prend en compte la rotation)
|
||||
/**
|
||||
* Méthode pour obtenir le terrain associé à un segment spécifique (prend en compte la rotation).
|
||||
*
|
||||
* @param segmentIndex L'index du segment.
|
||||
* @return Le type de terrain associé au segment spécifié.
|
||||
*/
|
||||
public TerrainType getTerrainForSegment(int segmentIndex) {
|
||||
int adjustedIndex = (segmentIndex - rotation + 6) % 6;
|
||||
if (adjustedIndex < segmentsForTerrain1) {
|
||||
@@ -31,18 +54,34 @@ public class Tile {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fait tourner la tuile dans le sens horaire.
|
||||
*/
|
||||
public void rotateClockwise() {
|
||||
rotation = (rotation + 1) % 6;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fait tourner la tuile dans le sens antihoraire.
|
||||
*/
|
||||
public void rotateCounterClockwise() {
|
||||
rotation = (rotation + 5) % 6; // Tourner dans le sens inverse
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoie la rotation actuelle de la tuile.
|
||||
*
|
||||
* @return La rotation de la tuile en multiples de 60 degrés.
|
||||
*/
|
||||
public int getRotation() {
|
||||
return rotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoie l'identifiant de la tuile.
|
||||
*
|
||||
* @return L'identifiant de la tuile.
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
Reference in New Issue
Block a user