(Map.Entry<Piece, Piece> pinnedEntry)
| 242 | } |
| 243 | |
| 244 | private List<Move> getMovesWithinPin(Map.Entry<Piece, Piece> pinnedEntry) { |
| 245 | final Piece pinnedPiece = pinnedEntry.getKey(); |
| 246 | final Piece attacker = pinnedEntry.getValue(); |
| 247 | final Piece king = getKing(pinnedPiece.color); |
| 248 | final Set<Move> moves = getMoveList(pinnedPiece); |
| 249 | final Line line = new Line(pinnedPiece.position, attacker.position); |
| 250 | final Line inverse = new Line(pinnedPiece.position, king.position); |
| 251 | if (line.isStraight) { |
| 252 | return moves.stream().filter(move -> { |
| 253 | final Line otherLine = new Line(move.piece.position, move.target); |
| 254 | final boolean towardsAttacker = otherLine.isStraight && otherLine.rowDiff == line.rowDiff && otherLine.colDiff == line.colDiff; |
| 255 | final boolean towardsKing = otherLine.isStraight && otherLine.rowDiff == inverse.rowDiff && otherLine.colDiff == inverse.colDiff; |
| 256 | return towardsAttacker || towardsKing; |
| 257 | }).collect(Collectors.toList()); |
| 258 | } |
| 259 | return new ArrayList<>(); |
| 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) { |
nothing calls this directly
no test coverage detected