MCPcopy Index your code
hub / github.com/coding-parrot/chess-engine / discoveredCheck

Method discoveredCheck

src/main/java/game/Board.java:804–816  ·  view source on GitHub ↗
(Piece king, Cell coordinate)

Source from the content-addressed store, hash-verified

802 }
803
804 private boolean discoveredCheck(Piece king, Cell coordinate) {
805 //knight and pawn can't give discoveries
806 final Line line = new Line(coordinate, king.position);
807 if (line.isStraight) {
808 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) {
809 if (!isEmpty(row, col)) {
810 final Piece piece = pieces.get(Cell.get(row, col));
811 return piece.color != king.color && (piece.sameType(PieceType.QUEEN) || piece.sameType(line.minorPieceType));
812 }
813 }
814 }
815 return false;
816 }
817
818 @Override
819 public String toString() {

Callers 1

lookForChecksMethod · 0.95

Calls 5

withinBoardLimitsMethod · 0.95
isEmptyMethod · 0.95
getMethod · 0.95
sameTypeMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected