internal Card RequestPlayerTopDeckCardFromPlay(GameState gameState, CardPredicate acceptableCard, bool isOptional)
{
if (!this.cardsPlayed.HasCard(acceptableCard))
{
return null;
}
Card cardTypeToTopDeck = this.actions.GetCardFromPlayToTopDeckDuringCleanup(gameState, acceptableCard, isOptional);
if (cardTypeToTopDeck == null)
{
if (isOptional)
{
return null;
}
else
{
throw new Exception("Player must choose a card to top deck");
}
}
Card cardToTopDeck = this.cardsPlayed.RemoveCard(cardTypeToTopDeck);
if (cardToTopDeck == null)
{
throw new Exception("Could not remove Card From Hand");
}
if (!acceptableCard(cardToTopDeck))
{
throw new Exception("Card does not meet constraint for top deck");
}
this.gameLog.PlayerTopDeckedCard(this, cardToTopDeck);
this.deck.AddCardToTop(cardToTopDeck);
return cardToTopDeck;
}