trying to setup shortcastling
This commit is contained in:
parent
63c51f3d56
commit
d37206f77c
|
|
@ -230,7 +230,7 @@ public class Board {
|
||||||
isAPieceHere = move.isKnightMoveValid(x, y, color, selectX, selectY);
|
isAPieceHere = move.isKnightMoveValid(x, y, color, selectX, selectY);
|
||||||
|
|
||||||
} else if (type == PieceType.King){
|
} else if (type == PieceType.King){
|
||||||
isAPieceHere = move.isKingMoveValid(x, y, color, selectX, selectY);
|
isAPieceHere = move.isKingMoveValid(x, y, color, selectX, selectY, myPiece);
|
||||||
}
|
}
|
||||||
return isAPieceHere;
|
return isAPieceHere;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -324,7 +324,7 @@ public class Move {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isKingMoveValid(int x, int y, boolean color, int selectX, int selectY) {
|
public boolean isKingMoveValid(int x, int y, boolean color, int selectX, int selectY, Piece myPiece) {
|
||||||
|
|
||||||
|
|
||||||
if (selectX == x + 1 && selectY == y + 1) { // check one of the 8 possible cases
|
if (selectX == x + 1 && selectY == y + 1) { // check one of the 8 possible cases
|
||||||
|
|
@ -366,6 +366,12 @@ public boolean isKingMoveValid(int x, int y, boolean color, int selectX, int se
|
||||||
if (selectX == x + 1 && selectY == y) {
|
if (selectX == x + 1 && selectY == y) {
|
||||||
return checkColor(x, y, color);
|
return checkColor(x, y, color);
|
||||||
}
|
}
|
||||||
|
if (color == true) {
|
||||||
|
if ((selectX == x - 3 && selectY == y)) {
|
||||||
|
return specialMoves.shortCastle(myPiece);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -376,11 +382,13 @@ public boolean isKingMoveValid(int x, int y, boolean color, int selectX, int se
|
||||||
return color != board.getPiece(x, y).isWhite(); // no need for additional if statement compared to rook and bishop move methods, its a comparator in between the color of the played piece and the color of the piece at the destination (x,y) , if they are different (so if the comparison is true), it will return true (possibility to eat the piece bc ishighlighted will be true) , if of the same color, return false
|
return color != board.getPiece(x, y).isWhite(); // no need for additional if statement compared to rook and bishop move methods, its a comparator in between the color of the played piece and the color of the piece at the destination (x,y) , if they are different (so if the comparison is true), it will return true (possibility to eat the piece bc ishighlighted will be true) , if of the same color, return false
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue