possibleMovements method
override
Implementation
@override
List<List<int>> possibleMovements(int x, int y, List<List<Piece>> board,
bool reversedBoard, List<List<int>> lastMovement) {
List<List<int>> movements = [];
for (int i = y + 1; i < 8; i++) {
if (board[i][x].isEmpty()) {
movements.add([i, x]);
} else {
if (board[i][x].isWhite != isWhite) {
movements.add([i, x]);
}
break;
}
}
for (int i = y - 1; i >= 0; i--) {
if (board[i][x].isEmpty()) {
movements.add([i, x]);
} else {
if (board[i][x].isWhite != isWhite) {
movements.add([i, x]);
}
break;
}
}
for (int i = x + 1; i < 8; i++) {
if (board[y][i].isEmpty()) {
movements.add([y, i]);
} else {
if (board[y][i].isWhite != isWhite) {
movements.add([y, i]);
}
break;
}
}
for (int i = x - 1; i >= 0; i--) {
if (board[y][i].isEmpty()) {
movements.add([y, i]);
} else {
if (board[y][i].isWhite != isWhite) {
movements.add([y, i]);
}
break;
}
}
return movements;
}