Пример #1
0
        /// <summary>
        /// Override method that returns a list of positions that the queen can make
        /// </summary>
        /// <param name="pieces">All pieces, white and black, to see if moves are obstructed</param>
        /// <returns>list of positions that the queen can make</returns>
        public override List <Position> GetMoves(List <Chesspiece> pieces)
        {
            // The queen uses the same moves as a bishop AND a rook, so you can simply use their moves
            Bishop tempBishop = new Bishop(Pos, IsWhite);       // Create a temporary bishop on the same position
            Rook   tempRook   = new Rook(Pos, IsWhite);         // Create a temporary rook on the same position

            // Create the moves list to later return filled with moves
            List <Position> moves = tempBishop.GetMoves(pieces).ToList(); // Give it the bishops moves

            moves.AddRange(tempRook.GetMoves(pieces));                    // Add the rooks moves to the list of moves

            return(moves);                                                // Return the list of the queens moves (bishop and rooks moves)
        }
Пример #2
0
        public override List <Point> GetMoves()
        {
            //Since a Queen's moves are just a rooks moves + a bishop's moves,
            //      moves location of tempBish/tempRook to current position
            tempBish.SetLoc(this.loc);
            tempRook.SetLoc(this.loc);

            //Adds moveset of bishop and rook to one list
            List <Point> moves = tempRook.GetMoves();

            moves.AddRange(tempBish.GetMoves());

            //returns list
            return(moves);
        }