2019-03-20 14:14:08 +01:00
|
|
|
package piecesEchiquier;
|
|
|
|
|
2019-04-23 17:03:08 +02:00
|
|
|
public abstract class Piece {
|
2019-03-20 14:14:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
//variables
|
|
|
|
|
2019-04-02 17:42:22 +02:00
|
|
|
private boolean couleur; /* True = blanc & Flase = noir */
|
2019-04-02 17:38:04 +02:00
|
|
|
private Position emplacement;
|
2019-03-20 14:14:08 +01:00
|
|
|
private char lettre = '.';
|
|
|
|
private boolean enVie = true;
|
2019-04-02 17:38:04 +02:00
|
|
|
private Position depart;
|
2019-03-20 14:14:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//constructeur par defaut qui devrait probablement remplacer vide
|
|
|
|
|
|
|
|
public Piece()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// constructeur
|
|
|
|
|
2019-04-23 17:30:04 +02:00
|
|
|
public Piece(boolean couleur,char l, int x, int y)
|
2019-03-20 14:14:08 +01:00
|
|
|
{
|
2019-04-02 16:54:14 +02:00
|
|
|
this.setCouleur(couleur);
|
|
|
|
this.lettre = l;
|
2019-04-23 17:30:04 +02:00
|
|
|
this.emplacement = new Position (x, y);
|
|
|
|
this.depart = new Position(x, y);
|
2019-03-20 14:14:08 +01:00
|
|
|
}
|
2019-04-23 17:03:08 +02:00
|
|
|
|
|
|
|
//vérifie une éventuelle collision a chaque case
|
|
|
|
public boolean collision(Case caseArrivee){
|
|
|
|
return caseArrivee.estVide();
|
|
|
|
}
|
|
|
|
|
|
|
|
//check si la case est alliee
|
|
|
|
public boolean estAllie(Case caseArrivee) {
|
|
|
|
return possesseur.equals(caseArrivee.getPieceCase().getPossesseur()) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-03-20 14:14:08 +01:00
|
|
|
|
|
|
|
// gets & sets
|
|
|
|
|
|
|
|
|
|
|
|
public char getLettre() {
|
|
|
|
return lettre;
|
|
|
|
}
|
|
|
|
public void setLettre(char lettre) {
|
|
|
|
this.lettre = lettre;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////
|
|
|
|
|
2019-04-23 17:30:04 +02:00
|
|
|
public Position getEmplacement() {
|
2019-03-20 14:14:08 +01:00
|
|
|
return emplacement;
|
|
|
|
}
|
|
|
|
|
2019-04-23 17:30:04 +02:00
|
|
|
public void setEmplacement(Position emplacement) {
|
2019-03-20 14:14:08 +01:00
|
|
|
this.emplacement = emplacement;
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////
|
|
|
|
|
|
|
|
public boolean isEnVie() {
|
|
|
|
return enVie;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setEnVie(boolean enVie) {
|
|
|
|
this.enVie = enVie;
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////
|
|
|
|
|
2019-04-02 16:54:14 +02:00
|
|
|
public boolean isCouleur() {
|
2019-03-20 14:14:08 +01:00
|
|
|
return couleur;
|
|
|
|
}
|
|
|
|
|
2019-04-02 16:54:14 +02:00
|
|
|
public void setCouleur(boolean couleur) {
|
2019-03-20 14:14:08 +01:00
|
|
|
this.couleur = couleur;
|
|
|
|
}
|
|
|
|
|
2019-04-23 17:03:08 +02:00
|
|
|
|
2019-03-20 14:14:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|