2025-11-23 17:29:28 +01:00
|
|
|
package fr.iut_fbleau.Avalam;
|
|
|
|
|
|
|
|
|
|
import fr.iut_fbleau.GameAPI.AbstractPly;
|
|
|
|
|
import fr.iut_fbleau.GameAPI.Player;
|
|
|
|
|
|
|
|
|
|
/**
|
2025-11-25 16:02:23 -05:00
|
|
|
* Représente un coup (ply) dans le jeu Avalam.
|
|
|
|
|
*
|
|
|
|
|
* Un coup est défini par :
|
|
|
|
|
* <ul>
|
|
|
|
|
* <li>un joueur (PLAYER1 ou PLAYER2)</li>
|
|
|
|
|
* <li>une position source (xFrom, yFrom)</li>
|
|
|
|
|
* <li>une position destination (xTo, yTo)</li>
|
|
|
|
|
* </ul>
|
|
|
|
|
*
|
|
|
|
|
* Ces coordonnées seront utilisées par <code>AvalamBoard</code> pour :
|
|
|
|
|
* <ul>
|
|
|
|
|
* <li>vérifier la légalité du coup</li>
|
|
|
|
|
* <li>fusionner les tours concernées</li>
|
|
|
|
|
* <li>mettre à jour la grille</li>
|
|
|
|
|
* </ul>
|
|
|
|
|
*
|
|
|
|
|
* Cette classe ne contient aucune logique de vérification : tout est délégué
|
|
|
|
|
* à <code>AvalamBoard.isLegal()</code> et <code>AvalamBoard.doPly()</code>.
|
2025-11-23 17:29:28 +01:00
|
|
|
*/
|
|
|
|
|
public class AvalamPly extends AbstractPly {
|
|
|
|
|
|
2025-11-25 16:02:23 -05:00
|
|
|
/** Coordonnées source */
|
|
|
|
|
private final int xFrom;
|
|
|
|
|
private final int yFrom;
|
|
|
|
|
|
|
|
|
|
/** Coordonnées destination */
|
|
|
|
|
private final int xTo;
|
|
|
|
|
private final int yTo;
|
2025-11-23 17:29:28 +01:00
|
|
|
|
|
|
|
|
/**
|
2025-11-25 16:02:23 -05:00
|
|
|
* Constructeur principal.
|
|
|
|
|
*
|
|
|
|
|
* @param player joueur qui joue le coup
|
|
|
|
|
* @param xFrom ligne d'origine
|
|
|
|
|
* @param yFrom colonne d'origine
|
|
|
|
|
* @param xTo ligne de destination
|
|
|
|
|
* @param yTo colonne de destination
|
2025-11-23 17:29:28 +01:00
|
|
|
*/
|
2025-11-25 16:02:23 -05:00
|
|
|
public AvalamPly(Player player, int xFrom, int yFrom, int xTo, int yTo) {
|
|
|
|
|
super(player);
|
2025-11-23 17:29:28 +01:00
|
|
|
this.xFrom = xFrom;
|
|
|
|
|
this.yFrom = yFrom;
|
|
|
|
|
this.xTo = xTo;
|
|
|
|
|
this.yTo = yTo;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-25 16:02:23 -05:00
|
|
|
/** Ligne d'origine */
|
2025-11-23 17:29:28 +01:00
|
|
|
public int getXFrom() {
|
|
|
|
|
return xFrom;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-25 16:02:23 -05:00
|
|
|
/** Colonne d'origine */
|
2025-11-23 17:29:28 +01:00
|
|
|
public int getYFrom() {
|
|
|
|
|
return yFrom;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-25 16:02:23 -05:00
|
|
|
/** Ligne de destination */
|
2025-11-23 17:29:28 +01:00
|
|
|
public int getXTo() {
|
|
|
|
|
return xTo;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-25 16:02:23 -05:00
|
|
|
/** Colonne de destination */
|
2025-11-23 17:29:28 +01:00
|
|
|
public int getYTo() {
|
|
|
|
|
return yTo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String toString() {
|
|
|
|
|
return "AvalamPly{" +
|
2025-11-25 16:02:23 -05:00
|
|
|
"player=" + getPlayer() +
|
|
|
|
|
", (" + xFrom + "," + yFrom + ") -> (" + xTo + "," + yTo + ")" +
|
2025-11-23 17:29:28 +01:00
|
|
|
'}';
|
|
|
|
|
}
|
|
|
|
|
}
|