update des classes
Tour.java: Méthode deplaçable Echiquier, Roi, main, Piece: mise en page
This commit is contained in:
@ -3,6 +3,7 @@ package piecesEchiquier;
|
||||
import joueurs.Joueur;
|
||||
|
||||
public class Echiquier {
|
||||
|
||||
private String[][] codes =
|
||||
{
|
||||
{"A8","B8","C8","D8","E8","F8","G8","H8"},
|
||||
@ -67,9 +68,8 @@ public class Echiquier {
|
||||
};
|
||||
|
||||
|
||||
public Echiquier()
|
||||
{
|
||||
|
||||
public Echiquier() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -139,18 +139,8 @@ public class Echiquier {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}while(( (getCodes()[i][j].equals(A)) == false) && (j+1 < codes.length));
|
||||
|
||||
}while((getCodes()[i][j].equals(A) == false) && (i+1 < codes.length));
|
||||
if (i == 9)
|
||||
{
|
||||
System.out.println("Code de la pi<70>ce a d<>placer invalide. Recommencez.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
for (k = 0; k < codes.length;k++)
|
||||
{
|
||||
@ -163,11 +153,11 @@ public class Echiquier {
|
||||
return false;
|
||||
}else if (this.getEchiquier()[i][j].deplacable(this.getEchiquier()[k][l]) == false)
|
||||
{
|
||||
System.out.println("D<EFBFBD>placement impossible. Recommencez.");
|
||||
System.out.println("D<EFBFBD>placement impossible. Recommencez.");
|
||||
return false;
|
||||
}else
|
||||
{
|
||||
System.out.println("Choix valid<EFBFBD>s. D<EFBFBD>placement en cours.");
|
||||
System.out.println("Choix validés. déplacement en cours.");
|
||||
this.getEchiquier()[k][l] = this.getEchiquier()[i][j];
|
||||
this.getEchiquier()[i][j] = new Piece(new Position(i,j));
|
||||
return true;
|
||||
@ -179,4 +169,13 @@ public class Echiquier {
|
||||
System.out.println("Un de vos codes est faux. Recommencez.");
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean estVide(Position position) {
|
||||
int x = position.getX();
|
||||
int y = position.getY();
|
||||
if(this.echiquier[x][y].getLettre()=="..") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
package piecesEchiquier;
|
||||
|
||||
public class Piece {
|
||||
@ -35,7 +34,7 @@ public class Piece {
|
||||
|
||||
}
|
||||
|
||||
/* //vérifie une éventuelle collision a chaque case
|
||||
/* //verifie une eventuelle collision a chaque case
|
||||
public boolean collision(Case caseArrivee){
|
||||
return caseArrivee.estVide();
|
||||
}*/
|
||||
|
@ -18,7 +18,7 @@ public class Roi extends Piece {
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
public boolean aBouge()
|
||||
{
|
||||
if(this.getIni() != this.getPosition())
|
||||
|
@ -21,19 +21,19 @@ public class Tour extends Piece {
|
||||
return verif;
|
||||
}
|
||||
|
||||
public boolean[][] deplacementsPossibles() {
|
||||
boolean[][] deplacementsPossibles = new boolean[8][8];
|
||||
public boolean[][] deplacable(Echiquier e,Piece p) {
|
||||
boolean[][] deplacementsInherentsPiece = new boolean[8][8];
|
||||
Position position = this.getPosition();
|
||||
int x = position.getX();
|
||||
int y = position.getY();
|
||||
|
||||
for(int i=x; i<8; i++) {
|
||||
//if(echiquier.estVide(position))
|
||||
deplacementsPossibles[i][y]=true;
|
||||
deplacementsInherentsPiece[i][y]=true;
|
||||
}
|
||||
for(int j=0; j<8; j++) {
|
||||
deplacementsPossibles[x][j]=true;
|
||||
deplacementsInherentsPiece[x][j]=true;
|
||||
}
|
||||
deplacementsPossibles[x][y]=false;
|
||||
return deplacementsPossibles;
|
||||
deplacementsInherentsPiece[x][y]=false;
|
||||
return deplacementsInherentsPiece;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user