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;
|
|
|
|
|
|
|
|
|
|
/**
|
2026-01-26 06:39:49 -05:00
|
|
|
* La classe <code>AvalamPly</code>
|
|
|
|
|
*
|
|
|
|
|
* Représente un coup (ply) dans le jeu Avalam.
|
|
|
|
|
* Un coup est défini par :
|
|
|
|
|
* - un joueur (PLAYER1 ou PLAYER2)
|
|
|
|
|
* - une position source (xFrom, yFrom)
|
|
|
|
|
* - une position destination (xTo, yTo)
|
|
|
|
|
*
|
|
|
|
|
* Cette classe ne vérifie pas la légalité : tout est délégué à <code>AvalamBoard</code>.
|
|
|
|
|
*/
|
2025-11-23 17:29:28 +01:00
|
|
|
public class AvalamPly extends AbstractPly {
|
|
|
|
|
|
2026-01-26 06:39:49 -05:00
|
|
|
//Attributs
|
|
|
|
|
|
|
|
|
|
/** Coordonnée ligne de la case source. */
|
2025-11-25 16:02:23 -05:00
|
|
|
private final int xFrom;
|
2026-01-26 06:39:49 -05:00
|
|
|
|
|
|
|
|
/** Coordonnée colonne de la case source. */
|
2025-11-25 16:02:23 -05:00
|
|
|
private final int yFrom;
|
|
|
|
|
|
2026-01-26 06:39:49 -05:00
|
|
|
/** Coordonnée ligne de la case destination. */
|
2025-11-25 16:02:23 -05:00
|
|
|
private final int xTo;
|
2026-01-26 06:39:49 -05:00
|
|
|
|
|
|
|
|
/** Coordonnée colonne de la case destination. */
|
2025-11-25 16:02:23 -05:00
|
|
|
private final int yTo;
|
2025-11-23 17:29:28 +01:00
|
|
|
|
2026-01-26 06:39:49 -05:00
|
|
|
//Constructeur
|
|
|
|
|
|
2025-11-23 17:29:28 +01:00
|
|
|
/**
|
2026-01-26 06:39:49 -05:00
|
|
|
* Construit un coup Avalam.
|
|
|
|
|
*
|
|
|
|
|
* @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-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;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-26 06:39:49 -05:00
|
|
|
//Méthodes
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retourne la ligne d'origine.
|
|
|
|
|
*
|
|
|
|
|
* @return ligne source
|
|
|
|
|
*/
|
2025-11-23 17:29:28 +01:00
|
|
|
public int getXFrom() {
|
|
|
|
|
return xFrom;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-26 06:39:49 -05:00
|
|
|
/**
|
|
|
|
|
* Retourne la colonne d'origine.
|
|
|
|
|
*
|
|
|
|
|
* @return colonne source
|
|
|
|
|
*/
|
2025-11-23 17:29:28 +01:00
|
|
|
public int getYFrom() {
|
|
|
|
|
return yFrom;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-26 06:39:49 -05:00
|
|
|
/**
|
|
|
|
|
* Retourne la ligne de destination.
|
|
|
|
|
*
|
|
|
|
|
* @return ligne destination
|
|
|
|
|
*/
|
2025-11-23 17:29:28 +01:00
|
|
|
public int getXTo() {
|
|
|
|
|
return xTo;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-26 06:39:49 -05:00
|
|
|
/**
|
|
|
|
|
* Retourne la colonne de destination.
|
|
|
|
|
*
|
|
|
|
|
* @return colonne destination
|
|
|
|
|
*/
|
2025-11-23 17:29:28 +01:00
|
|
|
public int getYTo() {
|
|
|
|
|
return yTo;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-26 06:39:49 -05:00
|
|
|
//Affichage
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retourne une représentation textuelle du coup.
|
|
|
|
|
*
|
|
|
|
|
* @return chaîne décrivant le coup
|
|
|
|
|
*/
|
2025-11-23 17:29:28 +01:00
|
|
|
@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
|
|
|
'}';
|
|
|
|
|
}
|
|
|
|
|
}
|