(final Move move, final Piece king)
| 260 | } |
| 261 | |
| 262 | private boolean illegalEnPassant(final Move move, final Piece king) { |
| 263 | if (move.piece.sameType(PieceType.PAWN) && move.captureMove && move.captureCell != move.target) { |
| 264 | //does not expose an attack on the king. |
| 265 | //The king is not discovered with the capture |
| 266 | //ignore the captured and capturing pawn, and then check if the ray is a check. |
| 267 | final Set<Piece> ignorePawns = new HashSet<>(); |
| 268 | ignorePawns.add(move.piece); |
| 269 | ignorePawns.add(getPiece(move.captureCell.row, move.captureCell.col)); |
| 270 | final Line line = new Line(move.captureCell, king.position); |
| 271 | if (line.isStraight) { |
| 272 | for (int row = king.position.row + line.rowDiff, col = king.position.col + line.colDiff; Utils.withinBoardLimits(row, col); row = row + line.rowDiff, col = col + line.colDiff) { |
| 273 | if (!isEmpty(row, col) && !ignorePawns.contains(getPiece(row, col))) { |
| 274 | final Piece piece = getPiece(row, col); |
| 275 | return piece.color != king.color && (piece.sameType(line.minorPieceType) || piece.sameType(PieceType.QUEEN)); |
| 276 | } else if (move.target.equals(Cell.get(row, col))) { |
| 277 | break; |
| 278 | } |
| 279 | } |
| 280 | } |
| 281 | } |
| 282 | return false; |
| 283 | } |
| 284 | |
| 285 | private Set<Cell> rayOfCheck(Piece king, Piece attacker) { |
| 286 | final Set<Cell> stopCheck = new HashSet<>(); |
no test coverage detected