Dominion.Strategy.Description.PickByPriorityDescription.AddCardInBestLocation C# (CSharp) Method

AddCardInBestLocation() public method

public AddCardInBestLocation ( Card card, int count ) : PickByPriorityDescription
card Card
count int
return PickByPriorityDescription
        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;
        }

Usage Example

Esempio n. 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);
        }
All Usage Examples Of Dominion.Strategy.Description.PickByPriorityDescription::AddCardInBestLocation