Compare commits
6 Commits
20edcf124b
...
6e8de19a29
| Author | SHA1 | Date |
|---|---|---|
|
|
6e8de19a29 | |
|
|
1a828a991b | |
|
|
5b1afad49e | |
|
|
3193c81cba | |
|
|
134532c5c8 | |
|
|
3c77607556 |
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package backend;
|
||||
package backend;
|
||||
|
||||
public class Piece {
|
||||
private int x;
|
||||
|
|
|
|||
|
|
@ -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 ()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue