(Move move, Board board, Piece king)
| 163 | } |
| 164 | |
| 165 | private static boolean xRay(Move move, Board board, Piece king) { |
| 166 | final Line line = new Line(move.piece.position, move.target); |
| 167 | for (int index = 1; index < 8; index++) { |
| 168 | final int row = move.piece.position.row + index * line.rowDiff, col = move.piece.position.col + index * line.colDiff; |
| 169 | if (Utils.withinBoardLimits(row, col)) { |
| 170 | if (!board.isEmpty(row, col)) { |
| 171 | final Piece piece = board.getPiece(row, col); |
| 172 | return piece.color != king.color && (piece.sameType(line.minorPieceType) || piece.sameType(PieceType.QUEEN)); |
| 173 | } |
| 174 | } else { |
| 175 | break; |
| 176 | } |
| 177 | } |
| 178 | return false; |
| 179 | } |
| 180 | } |
no test coverage detected