Compare commits

...

6 Commits

3 changed files with 56 additions and 4 deletions

View File

@ -393,4 +393,41 @@ public class Board {
return kingInCheck && !hasEscape;
}
private void enPassant(Board board, List<Move> moves) {
int x = this.x;
int y = this.y;
if (isWhite() == true && this.y == 3) {
if(isEnPassant(board, new Piece(x - 1, y)))
moves.add(new Move(this, new Piece(x - 1, y - 1),
board.getPieceAt(new Piece(x - 1, y))));
if(canCaptureEnPassant(board, new Piece(x + 1, y)))
moves.add(new Move(this, new Piece(x + 1, y - 1),
board.getPieceAt(new Piece(x + 1, y))));
}
if (isWhite() == false && this.y == 4) {
if(isEnPassant(board, new Piece(x - 1, y)))
moves.add(new Move(this, new Piece(x - 1, y + 1),
board.getPieceAt(new Piece(x - 1, y))));
if(canCaptureEnPassant(board, new Piece(x + 1, y)))
moves.add(new Move(this, new Piece(x + 1, y + 1),
board.getPieceAt(new Piece(x + 1, y))));
}
}
/**
* Checks if the pawn can capture another pawn by en passant
* @param pt location of the other pawn
* @return true if can be captured
*/
private boolean isEnPassant(Board board, Point pt) {
Piece temp = board.getPieceAt(pt);
if(temp != null)
if (temp instanceof Pawn && temp.getColor() != this.color)
if (((Pawn)temp).enPassantOk)
return true;
return false;
}
}

View File

@ -1,6 +1,12 @@
/*package backend;
public class SpecialMoves {
<<<<<<< HEAD
private Piece piece;
private Board board;
private Piece piece;
private Board board;
private int x = piece.getX();
@ -21,12 +27,17 @@ public class SpecialMoves {
int[][] offsets = {{1, 2}, {-1, 2}};
}*/
<<<<<<< HEAD
public boolean checkCoordinates(int x, int y, PieceType type, boolean isWhite) {
if (type == PieceType.Pawn && isWhite == true && y == 3) {
=======
/* public boolean checkCoordinates(int x, int y, PieceType type, boolean isWhite) {
if (type == PieceType.Pawn || isWhite == true || y == 3) {
>>>>>>> branch 'master' of https://gitarero.ecam.fr/louise.berteloot/OOP_2A5_Project.git
int[][] offsets = {{1, 0}, {-1, 0}};
}
if (type == PieceType.Pawn || isWhite == false || y == 4) {
if (type == PieceType.Pawn && isWhite == false && y == 4) {
int[][] offsets = {{1, 0}, {-1, 0}};
}
@ -36,11 +47,15 @@ public class SpecialMoves {
public boolean isEnpassant() {
boolean isWhite = piece.isWhite();
<<<<<<< HEAD
if (boolean isWhite == true && PieceType getType() == PieceType.Pawn) { //no idea honestly
=======
if (isWhite == true || PieceType getType() == PieceType.Pawn) { //no idea honestly
>>>>>>> branch 'master' of https://gitarero.ecam.fr/louise.berteloot/OOP_2A5_Project.git
if ()
}
if (boolean isWhite == false|| //PieceType type == Pawn) {
if (boolean isWhite == false && //PieceType type == Pawn) {
if ()
}
}