still doesnt work idk

This commit is contained in:
hugomanipoud2 2025-05-20 16:17:59 +02:00
parent 37b2bb2a2f
commit 28e5ec34af
2 changed files with 29 additions and 8 deletions

View File

@ -13,7 +13,7 @@ public class Main {
Board testBoard = new Board(8, 8);
testBoard.populateBoard();
System.out.println(testBoard.toString());
System.out.println(testBoard.setSelectXY(3,3));
System.out.println(testBoard.getPiece(1,1));
// launches graphical interface :
MyInterface mjf = new MyInterface();

View File

@ -184,20 +184,41 @@ public class Board {
/* The following methods require more work ! */
public boolean isHighlighted(int x, int y) {
Piece myPiece = getPiece(x,y);
boolean isAPieceHere = false ; // final return boolean value
PieceType type = null;
boolean color = false;
PieceType type = null; // type of piece variable that we will get trough a loop, this will determine the pattern of highlights on the board
boolean color = false ; //color of the piece for pawns that can only go in -y for black and +Y for white
if(myPiece != null) {
type = getPiece(x,y).getType(); // type of piece variable that we will get trough a loop, this will determine the pattern of highlights on the board
color = getPiece(x,y).isWhite(); //color of the piece for pawns that can only go in -y for black and +Y for white
for(int i = 1; i < 2;i++)
type = myPiece.getType();
color = myPiece.isWhite();
}
if(type == PieceType.Pawn && color == true) {
for(int i = 1; i < 3;i++) {
if(selectX == x && selectY == y+i) {
isAPieceHere = true;
break;
}
}
}else if (type == PieceType.Pawn && color == false) {
for(int i = 1; i < 3;i++) {
if(selectX == x && selectY == y-i) {
isAPieceHere = true;
break;
}
}
}else {
for(int i = 1; i < 5;i++) {
if(selectX == x && selectY == y+i) {
isAPieceHere = true;
break;
}
}
}
}
return isAPieceHere;
}