Example #1
0
        // Get cover for a piece.
        public static List <Tuple <uint, uint> > getCover(Board board, Piece piece)
        {
            if (piece is Pawn)
            {
                return(PawnRules.getCover(board, piece));
            }
            else if (piece is Rook)
            {
                return(RookRules.getCover(board, piece));
            }
            else if (piece is Knight)
            {
                return(KnightRules.getCover(board, piece));
            }
            else if (piece is Bishop)
            {
                return(BishopRules.getCover(board, piece));
            }
            else if (piece is Queen)
            {
                return(QueenRules.getCover(board, piece));
            }
            else if (piece is King)
            {
                return(KingRules.getCover(board, piece));
            }

            // Should not get here!
            return(new List <Tuple <uint, uint> >());
        }
Example #2
0
        // Check if a move is possible on a specific board.
        public static bool movePossible(Board board, Move move, string activePlayer)
        {
            // Check if piece at move.from
            Piece p = board.getPieceAt(move.FromX, move.FromY);

            if (p == null)
            {
                return(false);
            }

            // Check if correct colour
            if (p.getColour() != activePlayer)
            {
                return(false);
            }

            // Check if move is possible
            if (p is Pawn)
            {
                return(PawnRules.movePossible(board, p, move));
            }
            else if (p is Rook)
            {
                return(RookRules.movePossible(board, p, move));
            }
            else if (p is Knight)
            {
                return(KnightRules.movePossible(board, p, move));
            }
            else if (p is Bishop)
            {
                return(BishopRules.movePossible(board, p, move));
            }
            else if (p is Queen)
            {
                return(QueenRules.movePossible(board, p, move));
            }
            else if (p is King)
            {
                return(KingRules.movePossible(board, p, move));
            }

            // Should not get here ever...
            return(false);
        }