processCastling function
Function that simulates the castling move.
Implementation
void processCastling(int auxY, int auxX, int y, int x) {
BoardData board = BoardData();
if (board.currentBoard[auxY][auxX] is King) {
(board.currentBoard[auxY][auxX] as King).alreadyMoved = true;
} else if (board.currentBoard[auxY][auxX] is Rook) {
(board.currentBoard[auxY][auxX] as Rook).alreadyMoved = true;
}
if (board.currentBoard[auxY][auxX] is King && (auxX - x).abs() > 1) {
if (x == 6) {
board.currentBoard[y][5] = board.currentBoard[y][7];
board.currentBoard[y][7] = Empty(isWhite: false);
(board.squares[y * 8 + 5] as SquareState).actualizarEstado();
(board.squares[y * 8 + 7] as SquareState).actualizarEstado();
} else if (x == 2) {
board.currentBoard[y][3] = board.currentBoard[y][0];
board.currentBoard[y][0] = Empty(isWhite: false);
(board.squares[y * 8 + 0] as SquareState).actualizarEstado();
(board.squares[y * 8 + 3] as SquareState).actualizarEstado();
} else if (x == 1) {
board.currentBoard[y][2] = board.currentBoard[y][0];
board.currentBoard[y][0] = Empty(isWhite: false);
(board.squares[y * 8 + 0] as SquareState).actualizarEstado();
(board.squares[y * 8 + 2] as SquareState).actualizarEstado();
} else if (x == 5) {
board.currentBoard[y][4] = board.currentBoard[y][7];
board.currentBoard[y][7] = Empty(isWhite: false);
(board.squares[y * 8 + 4] as SquareState).actualizarEstado();
(board.squares[y * 8 + 7] as SquareState).actualizarEstado();
}
}
}