public ulong GetMoves(int rank, int file) { DisplayCheck = false; if (!IsRightColor(rank, file)) { return(0); } int selected = rank * 8 + file; char piece = _myboard[rank, file]; switch (piece) { case 'r': return(ClipCheck(Moves.GetRookMoves(rank, file, chessboard.AllPieces, chessboard.AllBlack), selected)); case 'n': return(ClipCheck(Moves.GetKnightMoves(rank, file, chessboard.AllBlack), selected)); case 'b': return(ClipCheck(Moves.GetBishopMoves(rank, file, chessboard.AllPieces, chessboard.AllBlack), selected)); case 'q': return(ClipCheck(Moves.GetQueenMoves(rank, file, chessboard.AllPieces, chessboard.AllBlack), selected)); case 'k': ulong bkmoves = Moves.GetKingMoves(rank, file, chessboard.AllBlack) | Moves.GetBlackCastleMoves(rank, file, chessboard.AllBlack, this, chessboard); return(ClipCheck(bkmoves, selected)); case 'p': return(ClipCheck(Moves.GetBlackPawnMoves(rank, file, chessboard.AllPieces, chessboard.AllWhite, chessboard.Enpassant), selected)); case 'R': return(ClipCheck(Moves.GetRookMoves(rank, file, chessboard.AllPieces, chessboard.AllWhite), selected)); case 'N': return(ClipCheck(Moves.GetKnightMoves(rank, file, chessboard.AllWhite), selected)); case 'B': return(ClipCheck(Moves.GetBishopMoves(rank, file, chessboard.AllPieces, chessboard.AllWhite), selected)); case 'Q': return(ClipCheck(Moves.GetQueenMoves(rank, file, chessboard.AllPieces, chessboard.AllWhite), selected)); case 'K': ulong wkmoves = Moves.GetKingMoves(rank, file, chessboard.AllWhite) | Moves.GetWhiteCastleMoves(rank, file, chessboard.AllWhite, this, chessboard); return(ClipCheck(wkmoves, selected)); case 'P': return(ClipCheck(Moves.GetWhitePawnMoves(rank, file, chessboard.AllPieces, chessboard.AllBlack, chessboard.Enpassant), selected)); default: return(0); } }
private List <int[]> GetPawnMoves(List <int> indexes, Game.PieceColor color) { List <int[]> moves = new List <int[]>(); foreach (int ind in indexes) { int rank = ind / 8; int file = ind % 8; if (color == Game.PieceColor.White) { List <int[]> thesemoves = ConvertMove(board.ClipCheck(Moves.GetWhitePawnMoves(rank, file, chessboard.AllPieces, chessboard.AllBlack, chessboard.Enpassant), ind), ind); moves.AddRange(thesemoves); } else { List <int[]> thesemoves = ConvertMove(board.ClipCheck(Moves.GetBlackPawnMoves(rank, file, chessboard.AllPieces, chessboard.AllWhite, chessboard.Enpassant), ind), ind); moves.AddRange(thesemoves); } } return(moves); }