GetPile() публичный Метод

public GetPile ( Dominion.Card cardType ) : PileOfCards
cardType Dominion.Card
Результат PileOfCards
Пример #1
0
        private static bool PreferMoneyOverDuchy(DefaultPlayerAction playerAction, GameState gameState)
        {
            if (!gameState.GetPile(Dominion.Cards.Duchy).Any)
                return true;

            int minCoin = gameState.Self.ExpectedCoinValueAtEndOfTurn;
            int maxCoin = minCoin + 3;

            Card mostExpensiveCard = playerAction.purchaseOrder.GetPreferredCard(gameState, card => card.CurrentCoinCost(gameState.Self) > minCoin && card.CurrentCoinCost(gameState.Self) <= maxCoin);
            Card thatOrDuchy = playerAction.purchaseOrder.GetPreferredCard(gameState, card => card == Dominion.Cards.Duchy || card == mostExpensiveCard);

            if (mostExpensiveCard != null && thatOrDuchy != Dominion.Cards.Duchy)
                return true;

            return false;
        }
Пример #2
0
            public override void EndGame(GameState gameState)
            {
                lock (this.factory.theLock)
                {
                    if (gameState.GetPile(Cards.Curse).Any)
                        return;

                    int player1Count = CountCurses(gameState, 0);
                    int player2Count = CountCurses(gameState, 1);

                    if (player1Count > player2Count)
                        this.factory.player1Win++;

                    if (player2Count > player1Count)
                        this.factory.player2Win++;

                    this.factory.totalGameCount++;
                }

                if (gameState.WinningPlayers.Count() > 1)
                {
                    int playerIndex = gameState.WinningPlayers[0].PlayerIndex;
                    //winningPlayerWas25++;
                }
            }
Пример #3
0
        internal void ReturnCardToSupply(Card cardToReturn, GameState gameState)
        {
            this.gameLog.PlayerReturnedCardToPile(this, cardToReturn);
            PileOfCards pile = gameState.GetPile(cardToReturn);
            if (pile == null)
                throw new Exception("Could not find supply pile");

            pile.AddCardToTop(cardToReturn);
        }
Пример #4
0
        internal PileOfCards RequestPlayerEmbargoPileFromSupply(GameState gameState)
        {
            Card cardType = this.actions.GetCardFromSupplyToEmbargo(gameState);

            PileOfCards pile = gameState.GetPile(cardType);
            if (pile == null)
            {
                throw new Exception("Must choose pile from supply");
            }

            return pile;
        }
Пример #5
0
        internal bool RequestPlayerDiscardCardFromHand(GameState gameState, CardPredicate acceptableCardsToDiscard, bool isOptional)
        {
            if (!this.hand.HasCard(acceptableCardsToDiscard))
            {
                return false;
            }

            Card cardTypeToDiscard = this.actions.GetCardFromHandToDiscard(gameState, acceptableCardsToDiscard, isOptional);
            if (cardTypeToDiscard == null)
            {
                if (isOptional)
                {
                    return false;
                }
                else
                {
                    throw new Exception("Player must choose a card to discard");
                }
            }
            else
            {
                if (gameState.GetPile(cardTypeToDiscard) != null &&  // TODO: this currently can not find ruins ... rework this method so a card is returned instead of a type.
                    !acceptableCardsToDiscard( cardTypeToDiscard))
                    throw new Exception("Card does not meet constraint: ");
            }

            this.MoveCardFromHandToDiscard(cardTypeToDiscard, gameState);

            return true;
        }
Пример #6
0
        public static int CountOfPile(Card cardType, GameState gameState)
        {
            if (!gameState.CardGameSubset.HasCard(cardType))
                return 0;

            return gameState.GetPile(cardType).Count;
        }
Пример #7
0
        internal bool MoveCardFromPlayToPile(GameState gameState)
        {
            bool wasReturned = false;
            Card cardInPlay = this.cardsBeingPlayed.DrawCardFromTop();
            if (cardInPlay != null)
            {
                PileOfCards pile = gameState.GetPile(cardInPlay);
                pile.AddCardToTop(cardInPlay);
                wasReturned = true;
                this.gameLog.PlayerReturnedCardToPile(this, cardInPlay);
            }

            this.cardsBeingPlayed.AddCardToTop(null);
            return wasReturned;
        }
Пример #8
0
 public static int CountOfPile(Card cardType, GameState gameState)
 {
     return gameState.GetPile(cardType).Count;
 }