Pawn.java
package Pieces;
import Game.*;
public class Pawn extends BoardSquare {
public Pawn(){
this.hasMoved = false;
horiz = false;
vert = true;
diag = false;
bidirectional = false;
limit = 1;
symbol = 'P';
imagename = "Pawn.png";
}
public Pawn(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) {
//Pawns can not capture directly ahead:
if (destSquare.owner != Player.NONE)
return SpecialMoveReturn.INVALID;
if (!startSquare.hasMoved && moveType.distance == 2 && !gameBoard.findPieces(startSquare, destSquare, Math.abs(moveType.distance)))
return SpecialMoveReturn.VALID;
//diagonal pawn capture
} else if(moveType.direction == MoveType.Direction.DIAG && moveType.distance == 1) {
if (destSquare.owner != Player.NONE)
return SpecialMoveReturn.VALID;
return SpecialMoveReturn.INVALID;
}
return SpecialMoveReturn.NONEXISTANT;
}
}