to the logic of the getLegalMoves() method.
*/
BataanMoves[] getValidJumps(int player, int row, int col) {
if (player != American) {
return null;
}
ArrayList moves = new ArrayList();
if (myBoard[row][col] == player) {
if(row%2 == col%2){
if (pieceCanJump(player, row, col, row + 1, col + 1, row + 2, col + 2)) {
moves.add(new BataanMoves(row, col, row + 2, col + 2));
}
if (pieceCanJump(player, row, col, row - 1, col + 1, row - 2, col + 2)) {
moves.add(new BataanMoves(row, col, row - 2, col + 2));
}
if (pieceCanJump(player, row, col, row + 1, col - 1, row + 2, col - 2)) {
moves.add(new BataanMoves(row, col, row + 2, col - 2));
}
if (pieceCanJump(player, row, col, row - 1, col - 1, row - 2, col - 2)) {
moves.add(new BataanMoves(row, col, row - 2, col - 2));
}
if (pieceCanJump(player, row, col, row, col - 1, row, col - 2)) {
moves.add(new BataanMoves(row, col, row, col - 2));
}
if (pieceCanJump(player, row, col, row, col + 1, row, col + 2)) {
moves.add(new BataanMoves(row, col, row, col + 2));
}
if (pieceCanJump(player, row, col, row - 1, col, row - 2, col)) {
moves.add(new BataanMoves(row, col, row - 2, col));
}
if (pieceCanJump(player, row, col, row + 1, col, row + 2, col)) {
moves.add(new BataanMoves(row, col, row + 2, col));
}
}else{
if (pieceCanJump(player, row, col, row-1, col, row-2, col)) {
moves.add(new BataanMoves(row, col, row, col - 2));
}
if (pieceCanJump(player, row, col, row, col - 1, row, col - 2)) {
moves.add(new BataanMoves(row, col, row, col - 2));
}
if (pieceCanJump(player, row, col, row, col + 1, row, col + 2)) {
moves.add(new BataanMoves(row, col, row, col + 2));
}
if (pieceCanJump(player, row, col, row + 1, col, row + 2, col)) {
moves.add(new BataanMoves(row, col, row + 2, col));
}
}
}
if (moves.isEmpty()) {
return null;
} else {
BataanMoves[] movesArray = new BataanMoves[moves.size()];
for (int i = 0; i < moves.size(); i++) {
movesArray[i] = moves.get(i);
}
return movesArray;
}
}
}
}