question: public static final boolean givesCheck ( Position pos , Move m ) { boolean wtm = pos . whiteMove ; int oKingSq = pos . getKingSq ( ! wtm ) ; int oKing = wtm ? Piece . BKING : Piece . WKING ; int p = Piece . makeWhite ( m . promoteTo == Piece . EMPTY ? pos . getPiece ( m . from ) : m . promoteTo ) ; int d1 = BitBoard . getDirection ( m . to , oKingSq ) ; switch ( d1 ) { case 8 : case - 8 : case 1 : case - 1 : if ( ( p == Piece . WQUEEN ) || ( p == Piece . WROOK ) ) if ( ( d1 != 0 ) && ( MoveGen . nextPiece ( pos , m . to , d1 ) == oKing ) ) return true ; break ; case 9 : case 7 : case - 9 : case - 7 : if ( ( p == Piece . WQUEEN ) || ( p == Piece . WBISHOP ) ) { if ( ( d1 != 0 ) && ( MoveGen . nextPiece ( pos , m . to , d1 ) == oKing ) ) return true ; } else if ( p == Piece . WPAWN ) { if ( ( ( d1 > 0 ) == wtm ) && ( pos . getPiece ( m . to + d1 ) == oKing ) ) return true ; } break ; default : if ( d1 != 0 ) { if ( p == Piece . WKNIGHT ) return true ; } } int d2 = BitBoard . getDirection ( m . from , oKingSq ) ; if ( ( d2 != 0 ) && ( d2 != d1 ) && ( MoveGen . nextPiece ( pos , m . from , d2 ) == oKing ) ) { int p2 = MoveGen . nextPieceSafe ( pos , m . from , - d2 ) ; switch ( d2 ) { case 8 : case - 8 : case 1 : case - 1 : if ( ( p2 == ( wtm ? Piece . WQUEEN : Piece . BQUEEN ) ) || ( p2 == ( wtm ? Piece . WROOK : Piece . BROOK ) ) ) return true ; break ; case 9 : case 7 : case - 9 : case - 7 : if ( ( p2 == ( wtm ? Piece . WQUEEN : Piece . BQUEEN ) ) || ( p2 == ( wtm ? Piece . WBISHOP : Piece . BBISHOP ) ) ) return true ; break ; } } if ( ( m . promoteTo != Piece . EMPTY ) && ( d1 != 0 ) && ( d1 == d2 ) ) { switch ( d1 ) { case 8 : case - 8 : case 1 : case - 1 : if ( ( p == Piece . WQUEEN ) || ( p == Piece . WROOK ) ) if ( ( d1 != 0 ) && ( MoveGen . nextPiece ( pos , m . from , d1 ) == oKing ) ) return true ; break ; case 9 : case 7 : case - 9 : case - 7 : if ( ( p == Piece . WQUEEN ) || ( p == Piece . WBISHOP ) ) { if ( ( d1 != 0 ) && ( MoveGen . nextPiece ( pos , m . from , d1 ) == oKing ) ) return true ; } break ; } } if ( p == Piece . WKING ) { if ( m . to - m . from == 2 ) { if ( MoveGen . nextPieceSafe ( pos , m . from , - 1 ) == oKing ) return true ; if ( MoveGen . nextPieceSafe ( pos , m . from + 1 , wtm ? 8 : - 8 ) == oKing ) return true ; } else if ( m . to - m . from == - 2 ) { if ( MoveGen . nextPieceSafe ( pos , m . from , 1 ) == oKing ) return true ; if ( MoveGen . nextPieceSafe ( pos , m . from - 1 , wtm ? 8 : - 8 ) == oKing ) return true ; } } else if ( p == Piece . WPAWN ) { if ( pos . getPiece ( m . to ) == Piece . EMPTY ) { int dx = Position . getX ( m . to ) - Position . getX ( m . from ) ; if ( dx != 0 ) { int epSq = m . from + dx ; int d3 = BitBoard . getDirection ( epSq , oKingSq ) ; switch ( d3 ) { case 9 : case 7 : case - 9 : case - 7 : if ( MoveGen . nextPiece ( pos , epSq , d3 ) == oKing ) { int p2 = MoveGen . nextPieceSafe ( pos , epSq , - d3 ) ; if ( ( p2 == ( wtm ? Piece . WQUEEN : Piece . BQUEEN ) ) || ( p2 == ( wtm ? Piece . WBISHOP : Piece . BBISHOP ) ) ) return true ; } break ; case 1 : if ( MoveGen . nextPiece ( pos , Math . max ( epSq , m . from ) , d3 ) == oKing ) { int p2 = MoveGen . nextPieceSafe ( pos , Math . min ( epSq , m . from ) , - d3 ) ; if ( ( p2 == ( wtm ? Piece . WQUEEN : Piece . BQUEEN ) ) || ( p2 == ( wtm ? Piece . WROOK : Piece . BROOK ) ) ) return true ; } break ; case - 1 : if ( MoveGen . nextPiece ( pos , Math . min ( epSq , m . from ) , d3 ) == oKing ) { int p2 = MoveGen . nextPieceSafe ( pos , Math . max ( epSq , m . from ) , - d3 ) ; if ( ( p2 == ( wtm ? Piece . WQUEEN : Piece . BQUEEN ) ) || ( p2 == ( wtm ? Piece . WROOK : Piece . BROOK ) ) ) return true ; } break ; } } } } return false ; }
target:  Return true if making a move delivers check to the opponent