MCPcopy Create free account
hub / github.com/coding-parrot/chess-engine / xRay

Method xRay

src/main/java/pieces/King.java:165–179  ·  view source on GitHub ↗
(Move move, Board board, Piece king)

Source from the content-addressed store, hash-verified

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}

Callers 1

filterIllegalMovesMethod · 0.95

Calls 4

withinBoardLimitsMethod · 0.95
sameTypeMethod · 0.95
isEmptyMethod · 0.80
getPieceMethod · 0.80

Tested by

no test coverage detected