Dominion.PlayerState.RevealCardsFromDiscard C# (CSharp) Method

RevealCardsFromDiscard() private method

private RevealCardsFromDiscard ( int cardCount, CardPredicate cardPredicate ) : void
cardCount int
cardPredicate CardPredicate
return void
        internal void RevealCardsFromDiscard(int cardCount, CardPredicate cardPredicate)
        {
            for (int i = 0; i < cardCount; ++i)
            {
                // warning, n^2 algorithm here.
                Card card = this.discard.RemoveCard(cardPredicate);
                if (card == null)
                {
                    throw new System.Exception("Could not reveal needed number of cards from discard");
                }
                RevealCard(card, DeckPlacement.Discard);
                this.cardsBeingRevealed.AddCard(card);
            }
        }

Usage Example

Example #1
0
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            int maxCoppers = currentPlayer.discard.CountWhere(card => card == Cards.Copper);
            int cardsToPutInHand = currentPlayer.actions.GetNumberOfCoppersToPutInHandForCountingHouse(gameState, maxCoppers);

            if (cardsToPutInHand < 0 || cardsToPutInHand > maxCoppers)
            {
                throw new Exception("Requested number of cards to reveal is out of range");
            }

            if (cardsToPutInHand > 0)
            {
                currentPlayer.RevealCardsFromDiscard(cardsToPutInHand, card => card == Cards.Copper);
                currentPlayer.MoveAllRevealedCardsToHand();
            }
        }
PlayerState