This commit is contained in:
loveb 2022-05-05 09:38:58 +02:00
parent 57d7f54e6f
commit 6f9f64c214
3 changed files with 12 additions and 5 deletions

View File

@ -21,7 +21,7 @@ public class Board extends JPanel implements MouseListener {
private Point selectedPiece = new Point(); private Point selectedPiece = new Point();
private Color moveableColor = new Color(255, 191, 0); private Color moveableColor = new Color(255, 191, 0);
public boolean developerMode = false; public boolean developerMode = false;
short turnCount = 0; public static short turnCount = 0;
boolean whitesTurn = true; boolean whitesTurn = true;
public Board() throws IOException { public Board() throws IOException {

View File

@ -81,6 +81,14 @@ public class Pawn extends PieceKnownIfMoved {
} }
@Override
public void move(Piece[][] pieces, Point toMove) {
if (Math.abs(toMove.y - this.position.y) == 2) {
othersMayDoEnPassant = true;
}
super.move(pieces, toMove);
}
@Override @Override
protected boolean addMovesIfCan(Point pos, ArrayList movable, Piece[][] pieces, boolean isSelected) { protected boolean addMovesIfCan(Point pos, ArrayList movable, Piece[][] pieces, boolean isSelected) {
if (pos.x < 0 || pos.x > 7 || pos.y < 0 || pos.y > 7) { if (pos.x < 0 || pos.x > 7 || pos.y < 0 || pos.y > 7) {

View File

@ -5,20 +5,19 @@ import java.io.IOException;
public abstract class PieceKnownIfMoved extends Piece { public abstract class PieceKnownIfMoved extends Piece {
protected boolean moved = false;
public PieceKnownIfMoved(boolean isWhite, Point startingPosition) throws IOException { public PieceKnownIfMoved(boolean isWhite, Point startingPosition) throws IOException {
super(isWhite, startingPosition); super(isWhite, startingPosition);
lastTurnMoved = -1;
} }
@Override @Override
public void move(Piece[][] pieces, Point toMove) { public void move(Piece[][] pieces, Point toMove) {
super.move(pieces, toMove); super.move(pieces, toMove);
moved = true; lastTurnMoved++;
} }
public boolean isMoved() { public boolean isMoved() {
return moved; return lastTurnMoved > -1;
} }
} }