36 lines
944 B
Java
36 lines
944 B
Java
|
package dev.kske.chess.board;
|
||
|
|
||
|
/**
|
||
|
* Project: <strong>Chess</strong><br>
|
||
|
* File: <strong>EnPassant.java</strong><br>
|
||
|
* Created: <strong>2 Nov 2019</strong><br>
|
||
|
*
|
||
|
* @since Chess v0.5-alpha
|
||
|
* @author Kai S. K. Engelbart
|
||
|
*/
|
||
|
public class EnPassant extends Move {
|
||
|
|
||
|
private final Position capturePos;
|
||
|
|
||
|
public EnPassant(Position pos, Position dest) {
|
||
|
super(pos, dest);
|
||
|
capturePos = new Position(dest.x, dest.y - ySign);
|
||
|
}
|
||
|
|
||
|
public EnPassant(int xPos, int yPos, int xDest, int yDest) { this(new Position(xPos, yPos), new Position(xDest, yDest)); }
|
||
|
|
||
|
@Override
|
||
|
public void execute(Board board) {
|
||
|
super.execute(board);
|
||
|
board.set(capturePos, null);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void revert(Board board, Piece capturedPiece) {
|
||
|
super.revert(board, capturedPiece);
|
||
|
board.set(capturePos, new Pawn(board.get(pos).getColor().opposite(), board));
|
||
|
}
|
||
|
|
||
|
public Position getCapturePos() { return capturePos; }
|
||
|
}
|