|
|
|
@ -13,8 +13,10 @@ public class Pawn extends Piece {
|
|
|
|
|
ArrayList<Move> possibleMoves = new ArrayList<>();
|
|
|
|
|
if (this.black) {
|
|
|
|
|
if (board.get(position.x, position.y + 1) == null) {
|
|
|
|
|
possibleMoves.add(new Move(position, new BoardCoordinate(position.x, position.y + 1)));
|
|
|
|
|
if (!moved) {
|
|
|
|
|
Move oneForward = new Move(position, new BoardCoordinate(position.x, position.y + 1));
|
|
|
|
|
oneForward.isPromotion = position.y + 1 == Board.BOARD_SIZE - 1;
|
|
|
|
|
possibleMoves.add(oneForward);
|
|
|
|
|
if (!moved && board.get(position.x, position.y + 2) == null) {
|
|
|
|
|
possibleMoves.add(new Move(position, new BoardCoordinate(position.x, position.y + 2)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -27,8 +29,10 @@ public class Pawn extends Piece {
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
if (board.get(position.x, position.y - 1) == null) {
|
|
|
|
|
possibleMoves.add(new Move(position, new BoardCoordinate(position.x, position.y - 1)));
|
|
|
|
|
if (!moved) {
|
|
|
|
|
Move oneForward = new Move(position, new BoardCoordinate(position.x, position.y - 1));
|
|
|
|
|
oneForward.isPromotion = position.y - 1 == 0;
|
|
|
|
|
possibleMoves.add(oneForward);
|
|
|
|
|
if (!moved && board.get(position.x, position.y - 2) == null) {
|
|
|
|
|
possibleMoves.add(new Move(position, new BoardCoordinate(position.x, position.y - 2)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|