package Pieces;
import Game.*;
/**
* http://en.wikipedia.org/wiki/Berolina_chess
*
* The Berolina pawn moves, without capturing, one square diagonally forward. It captures one square straight forward. (So, it is the converse of a standard chess pawn, which moves straight forward and captures diagonally forward.)
*
* Like a standard pawn, the Berolina has the option to step two squares forward on its first move (so for the Berolina, two squares diagonally forward). En passant is possible as well (see diagram). As in standard chess, the Berolina pawn promotes when it reaches the last rank.
*
*/
public class BerolinaPawn extends BoardSquare {
public BerolinaPawn(){
this.hasMoved = false;
horiz = false;
vert = false;
diag = true;
bidirectional = false;
limit = 1;
symbol = 'P';
imagename = "BerolinaPawn.png";
}
public BerolinaPawn(int x, int y, Player player){
this();
this.x = x;
this.y = y;
this.owner = player;
}
public SpecialMoveReturn SpecialMove(BoardSquare startSquare, BoardSquare destSquare, MoveType moveType, Board gameBoard){
if(moveType.direction == MoveType.Direction.VERT) {
//pawn capture
if (moveType.distance == 1 && destSquare.owner != Player.NONE)
return SpecialMoveReturn.VALID;
return SpecialMoveReturn.INVALID;
} else if(moveType.direction == MoveType.Direction.DIAG ) {
//first move, allowed to move two spaces.
if (!startSquare.hasMoved && moveType.distance == 2 && !gameBoard.findPieces(startSquare, destSquare, Math.abs(moveType.distance)))
return SpecialMoveReturn.VALID;
//BerolinaPawns can not capture diagonally:
if (destSquare.owner != Player.NONE)
return SpecialMoveReturn.INVALID;
}
return SpecialMoveReturn.NONEXISTANT;
}
}