Dominion.PlayerState.RequestPlayerTrashCardFromHandButDontTrash C# (CSharp) Method

RequestPlayerTrashCardFromHandButDontTrash() private method

private RequestPlayerTrashCardFromHandButDontTrash ( GameState gameState, CardPredicate acceptableCardsToTrash, bool isOptional, CollectionCards cardsTrashedSoFar = null ) : Dominion.Card
gameState GameState
acceptableCardsToTrash CardPredicate
isOptional bool
cardsTrashedSoFar CollectionCards
return Dominion.Card
        internal Card RequestPlayerTrashCardFromHandButDontTrash(GameState gameState, CardPredicate acceptableCardsToTrash, bool isOptional, CollectionCards cardsTrashedSoFar = null)
        {
            if (!this.hand.HasCard(acceptableCardsToTrash))
            {
                return null;
            }

            if (cardsTrashedSoFar == null)
                cardsTrashedSoFar = gameState.emptyCardCollection;

            Card cardTypeToTrash = this.actions.GetCardFromHandToTrash(gameState, acceptableCardsToTrash, isOptional, cardsTrashedSoFar);
            if (cardTypeToTrash == null)
            {
                if (isOptional)
                {
                    return null;
                }
                else
                {
                    throw new Exception("Player must choose a card to trash");
                }
            }

            if (!acceptableCardsToTrash(cardTypeToTrash))
            {
                throw new Exception("Tried to trash a card that didn't match the constraint");
            }

            return cardTypeToTrash;
        }
PlayerState