ChessDotNet.Pieces.Queen.GetValidMoves C# (CSharp) Method

GetValidMoves() public method

public GetValidMoves ( Position from, bool returnIfAny, ChessGame game, bool>.Func gameMoveValidator ) : ReadOnlyCollection
from Position
returnIfAny bool
game ChessGame
gameMoveValidator bool>.Func
return ReadOnlyCollection
        public override ReadOnlyCollection<Move> GetValidMoves(Position from, bool returnIfAny, ChessGame game, Func<Move, bool> gameMoveValidator)
        {
            ChessUtilities.ThrowIfNull(from, "from");
            ReadOnlyCollection<Move> horizontalVerticalMoves = new Rook(Owner).GetValidMoves(from, returnIfAny, game, gameMoveValidator);
            if (returnIfAny && horizontalVerticalMoves.Count > 0)
                return horizontalVerticalMoves;
            ReadOnlyCollection<Move> diagonalMoves = new Bishop(Owner).GetValidMoves(from, returnIfAny, game, gameMoveValidator);
            return new ReadOnlyCollection<Move>(horizontalVerticalMoves.Concat(diagonalMoves).ToList());
        }
    }