HasPotionCard() private méthode

private HasPotionCard ( ) : bool
Résultat bool
Exemple #1
0
        public PickByPriorityDescription AddCardInBestLocation(Card card)
        {
            var resultDescriptions = new CardAcceptanceDescription[this.descriptions.Length + 1];

            int currentReadLocation  = 0;
            int currentWriteLocation = 0;

            while (currentReadLocation < this.descriptions.Length)
            {
                if (this.descriptions[currentReadLocation].card.DefaultCoinCost <= card.DefaultCoinCost &&
                    this.descriptions[currentReadLocation].IsConditionedOnlyOnSelfOwnership())
                {
                    break;
                }
                resultDescriptions[currentWriteLocation++] = this.descriptions[currentReadLocation++];
            }

            resultDescriptions[currentWriteLocation++] = new CardAcceptanceDescription(card, new MatchDescription(CountSource.CountAllOwned, card, Comparison.LessThan, 1));

            while (currentReadLocation < this.descriptions.Length)
            {
                resultDescriptions[currentWriteLocation++] = this.descriptions[currentReadLocation++];
            }

            var result = new PickByPriorityDescription(resultDescriptions);

            if (card.potionCost > 0 && !result.HasPotionCard())
            {
                return(result.AddCardInBestLocation(Cards.Potion));
            }

            return(result);
        }
        public PickByPriorityDescription AddCardInBestLocation(Card card, int count)
        {
            var resultDescriptions = new CardAcceptanceDescription[this.descriptions.Length+1];

            int currentReadLocation = 0;
            int currentWriteLocation = 0;

            while (currentReadLocation < this.descriptions.Length)
            {
                if (this.descriptions[currentReadLocation].card.DefaultCoinCost <= card.DefaultCoinCost &&
                    this.descriptions[currentReadLocation].IsConditionedOnlyOnSelfOwnership())
                    break;
                resultDescriptions[currentWriteLocation++] = this.descriptions[currentReadLocation++];
            }

            resultDescriptions[currentWriteLocation++] = new CardAcceptanceDescription(card, new MatchDescription(CountSource.CountAllOwned, card, Comparison.LessThan, count));

            while (currentReadLocation < this.descriptions.Length)
            {
                resultDescriptions[currentWriteLocation++] = this.descriptions[currentReadLocation++];
            }

            var result = new PickByPriorityDescription(resultDescriptions);
            if (card.potionCost > 0 && !result.HasPotionCard())
            {
                return result.AddCardInBestLocation(Cards.Potion, 1);
            }

            return result;
        }