still doesnt work idk
This commit is contained in:
parent
37b2bb2a2f
commit
28e5ec34af
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue