loadMovement function
Function that given a movement coords loads it in the current game before showing the game.
Is called before the start to load previous movements.
Implementation
void loadMovement(List<List<int>> movements) {
BoardData b = BoardData();
int auxY = movements[0][0];
int auxX = movements[0][1];
int y = movements[1][0];
int x = movements[1][1];
processCastling(auxY, auxX, y, x);
procesarComerAlPaso(auxY, auxX, y, x);
b.lastMovement = movements;
b.currentBoard[y][x] = b.currentBoard[auxY][auxX];
if (b.prom != "") {
switch (b.prom) {
case "q":
b.currentBoard[y][x] = Queen(isWhite: b.whiteTurn);
break;
case "r":
b.currentBoard[y][x] = Rook(isWhite: b.whiteTurn);
break;
case "b":
b.currentBoard[y][x] = Bishop(isWhite: b.whiteTurn);
break;
case "n":
b.currentBoard[y][x] = Knight(isWhite: b.whiteTurn);
break;
}
}
b.prom = "";
b.currentBoard[auxY][auxX] = Empty(isWhite: false);
b.selectedSquare = [-1, -1];
b.whiteTurn = !b.whiteTurn;
}