Castling is fully functional, i needed to split long and short, idk it
works so thats a win
This commit is contained in:
parent
ee44342e4f
commit
248fdbda92
|
|
@ -20,24 +20,20 @@ public class Move {
|
|||
//helper function to change the coordinates of a piece
|
||||
public void movePiece(int selectX, int selectY, int toX, int toY) {
|
||||
Piece movingPiece = null ; // initializing variable to work with and store it
|
||||
PieceType type = null;
|
||||
boolean color = true;
|
||||
int turnNb = board.getTurnNumber(); // Increment turn number and change turn color; // Increment turn number and change turn color
|
||||
|
||||
for (Piece piece : pieces) { // iterate trough all pieces
|
||||
|
||||
if(piece.getX() == selectX && piece.getY() == selectY) { // if the coordinates selected and the coordinate of a piece on the board matches, the loop will activate
|
||||
movingPiece = piece; //storing in memory the piece
|
||||
type = movingPiece.getType();
|
||||
color = movingPiece.isWhite();
|
||||
|
||||
movingPiece = piece; //storing in memory the piece
|
||||
if (board.isHighlighted(toX, toY)) { // only allow the value of cases that are set to true as isHghlighted is a bool function
|
||||
|
||||
if (board.isAPieceThere(toX, toY)){//checking if a piece is at the arrival coordinates
|
||||
needPieceDeletion(toX, toY); //if a piece is at arrival coord, remove the piece
|
||||
}
|
||||
specialMoves.pawnPromotion(movingPiece, toY);
|
||||
specialMoves.castling(movingPiece, toX, toY);
|
||||
specialMoves.castlingShort(movingPiece, toX, toY);
|
||||
specialMoves.castlingLong(movingPiece, toX, toY);
|
||||
movingPiece.setX(toX); // change coordinates to the new coordinate
|
||||
movingPiece.setY(toY);
|
||||
board.setTurnNb(turnNb + 1);
|
||||
|
|
|
|||
Loading…
Reference in New Issue