GetSupplyPile() public method

public GetSupplyPile ( Dominion.Card cardType ) : PileOfCards
cardType Dominion.Card
return PileOfCards
コード例 #1
0
        private static bool CountOfPileLessthanEqual(Card cardType, GameState gameState, int count)
        {
            if (gameState.GetSupplyPile(cardType) == null)
                return true;

            return CountOfPile(cardType, gameState) <= count;
        }
コード例 #2
0
        internal Card RequestPlayerGainCardFromSupply(GameState gameState, PlayerState playerGainingCard, CardPredicate acceptableCard, string description, bool isOptional = false, DeckPlacement defaultLocation = DeckPlacement.Discard)
        {
            PileOfCards exampleCard = gameState.supplyPiles.Where(cardPile => !cardPile.IsEmpty && acceptableCard(cardPile.TopCard())).FirstOrDefault();
            bool hasCardOfCost = exampleCard != null;
            if (!hasCardOfCost)
            {
                return null;
            }

            CardPredicate cardPredicate = card => gameState.GetSupplyPile(card) != null && acceptableCard(card);
            // how do you know which player you are gaining for?
            Card cardType = this.actions.GetCardFromSupplyToGain(gameState, cardPredicate, isOptional);
            if (cardType == null)
            {
                if (isOptional)
                {
                    return null;
                }
                throw new Exception("Must gain a card where " + description);
            }

            Card gainedCard = gameState.PlayerGainCardFromSupply(cardType, playerGainingCard, defaultLocation);
            if (gainedCard == null)
            {
                throw new Exception("Card specified can not be gained");
            }

            if (!acceptableCard(gainedCard))
            {
                throw new Exception("Card does not meet constraint: " + description);
            }

            return gainedCard;
        }
コード例 #3
0
        internal Card RequestPlayerChooseCardFromSupplyToPlay(GameState gameState, CardPredicate acceptableCard)
        {
            if (!gameState.supplyPiles.Where(pile => acceptableCard(pile.ProtoTypeCard)).Any())
                return null;

            Card cardType = this.actions.GetCardFromSupplyToPlay(gameState, delegate(Card c)
            {
                if (!acceptableCard(c))
                    return false;

                PileOfCards pile = gameState.GetSupplyPile(c);
                if (pile == null || pile.Count == 0)
                {
                    return false;
                }

                return true;
            });

            if (!acceptableCard(cardType))
            {
                throw new Exception("Card did not meet constraint");
            }

            PileOfCards foundPile = gameState.GetSupplyPile(cardType);
            if (foundPile == null || foundPile.Count == 0)
            {
                throw new Exception("Must choose pile from supply");
            }

            return cardType;
        }