You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
1.6 KiB
74 lines
1.6 KiB
11 months ago
|
|
||
|
public class Square {
|
||
|
//Pawn, knight, bishop, rook, queen, king, blank.
|
||
11 months ago
|
public static final int OUT_OF_BOUNDS = -1;
|
||
|
public static final int EMPTY = 0;
|
||
|
public static final int PAWN = 1;
|
||
|
public static final int KNIGHT = 2;
|
||
|
public static final int BISHOP = 3;
|
||
|
public static final int ROOK = 4;
|
||
|
public static final int QUEEN = 5;
|
||
|
public static final int KING = 6;
|
||
|
|
||
|
private int type; //one of the 8 constants above.
|
||
|
private boolean isWhite;
|
||
11 months ago
|
private boolean hasMoved;
|
||
|
private boolean isEnPassantSquare; //was jumped over by a pawn on the previous move.
|
||
11 months ago
|
|
||
11 months ago
|
//en passant boolean flag (for the square that would be "captured")
|
||
|
//boolean Knowledge of whether or not this piece moved yet (for castling)
|
||
|
//boolean for off-the-board square
|
||
|
|
||
11 months ago
|
public Square(Square s) {
|
||
|
type = s.type;
|
||
|
isWhite = s.isWhite;
|
||
11 months ago
|
hasMoved = s.hasMoved;
|
||
|
isEnPassantSquare = s.isEnPassantSquare;
|
||
11 months ago
|
}
|
||
|
|
||
11 months ago
|
public Square(int type) {
|
||
|
this(type, false);
|
||
|
}
|
||
|
|
||
|
public Square(int type, boolean isWhite) {
|
||
|
this.type = type;
|
||
|
this.isWhite = isWhite;
|
||
11 months ago
|
hasMoved = false;
|
||
|
isEnPassantSquare = false;
|
||
|
}
|
||
|
|
||
|
public void clearEnPassant() {
|
||
|
isEnPassantSquare = false;
|
||
|
}
|
||
|
|
||
|
public boolean isEnPassantSquare() {
|
||
|
return isEnPassantSquare;
|
||
|
}
|
||
|
|
||
|
public void setEnPassantSquare(boolean whiteMovedPawnTwo) {
|
||
|
isEnPassantSquare = true;
|
||
|
isWhite = whiteMovedPawnTwo;
|
||
|
}
|
||
|
|
||
|
public void setHasMoved() {
|
||
|
hasMoved = true;
|
||
|
}
|
||
|
|
||
|
public boolean isMoved() {
|
||
|
return hasMoved;
|
||
11 months ago
|
}
|
||
|
|
||
11 months ago
|
//Positive values for white, negative for black, blank square is 0.
|
||
|
public int getValue() {
|
||
11 months ago
|
return 0; //TODO.
|
||
11 months ago
|
}
|
||
11 months ago
|
|
||
|
public int getType() {
|
||
|
return type;
|
||
|
}
|
||
|
|
||
|
public boolean isWhite() {
|
||
|
return isWhite;
|
||
|
}
|
||
|
|
||
11 months ago
|
}
|