当前位置: 首页>>代码示例>>C#>>正文


C# CardCollection.Contains方法代码示例

本文整理汇总了C#中CardCollection.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# CardCollection.Contains方法的具体用法?C# CardCollection.Contains怎么用?C# CardCollection.Contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CardCollection的用法示例。


在下文中一共展示了CardCollection.Contains方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CloneShouldReturnExactSameCollectionOfCards

 public void CloneShouldReturnExactSameCollectionOfCards()
 {
     var collection = new CardCollection
                          {
                              new Card(CardSuit.Club, CardType.Ace), // 1
                              new Card(CardSuit.Spade, CardType.King), // 52
                              new Card(CardSuit.Heart, CardType.Ten),
                              new Card(CardSuit.Diamond, CardType.Queen),
                              new Card(CardSuit.Club, CardType.Jack),
                              new Card(CardSuit.Heart, CardType.Nine),
                          };
     var clonedCollection = collection.DeepClone();
     Assert.IsNotNull(clonedCollection);
     Assert.AreEqual(collection.Count, clonedCollection.Count);
     foreach (var card in clonedCollection)
     {
         Assert.IsTrue(collection.Contains(card));
     }
 }
开发者ID:NotDemons,项目名称:NotDemonsRepo,代码行数:19,代码来源:CardCollectionTests.cs

示例2: ContainsShouldReturnTrueForAllCardsAfterAddingThem

        public void ContainsShouldReturnTrueForAllCardsAfterAddingThem()
        {
            var collection = new CardCollection();
            foreach (CardSuit cardSuitValue in Enum.GetValues(typeof(CardSuit)))
            {
                foreach (CardType cardTypeValue in Enum.GetValues(typeof(CardType)))
                {
                    var card = new Card(cardSuitValue, cardTypeValue);
                    collection.Add(card);
                }
            }

            foreach (CardSuit cardSuitValue in Enum.GetValues(typeof(CardSuit)))
            {
                foreach (CardType cardTypeValue in Enum.GetValues(typeof(CardType)))
                {
                    var card = new Card(cardSuitValue, cardTypeValue);
                    Assert.IsTrue(collection.Contains(card));
                }
            }
        }
开发者ID:NotDemons,项目名称:NotDemonsRepo,代码行数:21,代码来源:CardCollectionTests.cs

示例3: MoveToTrashStart

		private CardCollection MoveToTrashStart(DeckLocation location, CardCollection cards)
		{
			CardCollection cardsMoved = null;
			switch (location)
			{
				case DeckLocation.Hand:
					cardsMoved = _Hand.Retrieve(this, c => cards.Contains(c));
					break;

				case DeckLocation.Revealed:
					cardsMoved = _Revealed.Retrieve(this, c => cards.Contains(c));
					break;

				case DeckLocation.Discard:
					cardsMoved = _DiscardPile.Retrieve(this, c => cards.Contains(c));
					break;

				case DeckLocation.InPlay:
					cardsMoved = _InPlay.Retrieve(this, c => cards.Contains(c));
					break;

				case DeckLocation.SetAside:
					cardsMoved = _SetAside.Retrieve(this, c => cards.Contains(c));
					break;

				case DeckLocation.Private:
					cardsMoved = _Private.Retrieve(this, c => cards.Contains(c));
					break;

				default:
					throw new Exception("Cannot move card to trash from this location");
			}
			_Game.Table.Trash.AddRange(cardsMoved);
			return cardsMoved;
		}
开发者ID:micahpaul,项目名称:dominion_net_multi,代码行数:35,代码来源:Player.cs

示例4: RetrieveCardsFrom

		internal CardCollection RetrieveCardsFrom(DeckLocation location, CardCollection cards)
		{
			//return new CardCollection(RetrieveCardsFrom(location, DeckPosition.Automatic, c => cards.Any(card => card.CardType == c.CardType), cards.Count).OrderBy(c => cards.IndexOf(c)));
			return new CardCollection(RetrieveCardsFrom(location, DeckPosition.Automatic, c => cards.Contains(c), -1).OrderBy(c => cards.IndexOf(c)));
		}
开发者ID:micahpaul,项目名称:dominion_net_multi,代码行数:5,代码来源:Player.cs

示例5: FindBestCardsToTrash

		protected IEnumerable<Card> FindBestCardsToTrash(IEnumerable<Card> cards, int count, Boolean onlyReturnTrashables)
		{
			// choose the worse card in hand in this order
			// 1) curse
			// 2) any ruins
			// 3) Sea Hag if there are no curses left
			// 4) Loan if we have fewer than 3 Coppers left
			// 5) Copper if we've got a lot of better Treasure
			// 6) Fortress
			// (If onlyReturnTrashables is false):
			// 7) lowest value from ComputeValueInDeck

			CardCollection cardsToTrash = new CardCollection();
			cardsToTrash.AddRange(cards.Where(c => c.Category == Category.Curse).Take(count));
			if (cardsToTrash.Count >= count)
				return cardsToTrash;

			cardsToTrash.AddRange(cards.Where(c => (c.Category & Category.Ruins) == Category.Ruins).Take(count - cardsToTrash.Count));
			if (cardsToTrash.Count >= count)
				return cardsToTrash;

			if (this.RealThis._Game.Table.Curse.Count <= 1)
			{
				cardsToTrash.AddRange(cards.Where(c => c.CardType == Cards.Seaside.TypeClass.SeaHag).Take(count - cardsToTrash.Count));
				if (cardsToTrash.Count >= count)
					return cardsToTrash;
			}

			cardsToTrash.AddRange(cards.Where(c => c.CardType == Cards.DarkAges.TypeClass.OvergrownEstate).Take(count - cardsToTrash.Count));
			if (cardsToTrash.Count >= count)
				return cardsToTrash;

			cardsToTrash.AddRange(cards.Where(c => c.CardType == Cards.DarkAges.TypeClass.Hovel).Take(count - cardsToTrash.Count));
			if (cardsToTrash.Count >= count)
				return cardsToTrash;

			if (this.RealThis.CountAll(this.RealThis, c => (c.Category & Category.Treasure) == Category.Treasure && (c.Benefit.Currency.Coin > 1 || c.CardType == Cards.Prosperity.TypeClass.Bank)) >=
				this.RealThis.CountAll(this.RealThis, c => c.CardType == Cards.Universal.TypeClass.Copper))
			{
				cardsToTrash.AddRange(cards.Where(c => c.CardType == Cards.Universal.TypeClass.Copper).Take(count - cardsToTrash.Count));
				if (cardsToTrash.Count >= count)
					return cardsToTrash;
			}

			if (this.RealThis.CountAll(this.RealThis, c => c.CardType == Cards.Universal.TypeClass.Copper) < 3)
			{
				cardsToTrash.AddRange(cards.Where(c => c.CardType == Cards.Prosperity.TypeClass.Loan).Take(count - cardsToTrash.Count));
				if (cardsToTrash.Count >= count)
					return cardsToTrash;
			}

			cardsToTrash.AddRange(cards.Where(c => c.CardType == Cards.DarkAges.TypeClass.Fortress).Take(count - cardsToTrash.Count));
			if (cardsToTrash.Count >= count)
				return cardsToTrash;

			if (!onlyReturnTrashables)
				cardsToTrash.AddRange(cards.OrderBy(c => ComputeValueInDeck(c)).ThenBy(c => c.Name).Where(c => !cardsToTrash.Contains(c)).Take(count - cardsToTrash.Count));

			return cardsToTrash;
		}
开发者ID:micahpaul,项目名称:dominion_net_multi,代码行数:60,代码来源:Standard.cs

示例6: CheckHighestPairConfiguration

        public bool CheckHighestPairConfiguration(out Hand hand)
        {
            checkCardList();

            // make a copy
            //List<Card> cardList = new List<Card>(_cardList);
            CardCollection cardList = new CardCollection(_cardList);
            cardList.Sort();

            // this is a list of cards that match the key value
            Dictionary<int, CardCollection> matches = new Dictionary<int, CardCollection>();

            int numPairs = 0;
            int numThrees = 0;
            int numFours = 0;

            // Construct the dictionary
            foreach (Card card in cardList)
            {
                if (matches.ContainsKey(card.Value))
                    matches[card.Value].Add(card);
                else
                    matches.Add(card.Value, new CardCollection(new Card[] { card }));
                    //matches.Add(card.Value, new List<Card>(new Card[] { card }));
            }

            // Determine the number of pairs, threes, and fours
            //foreach (List<Card> cardPairs in matches.Values)
            foreach (CardCollection cardPairs in matches.Values)
            {
                if (cardPairs.Count == 2)
                    numPairs++;

                if (cardPairs.Count == 3)
                    numThrees++;

                if (cardPairs.Count == 4)
                    numFours++;
            }

            //List<Card> resultCards = new List<Card>();
            CardCollection resultCards = new CardCollection();

            // Okay, here comes the real logic
            // One Pair and One Pair Only
            if (numPairs == 1 && numThrees == 0 && numFours == 0)
            {
                // Continue with the assumption that we'll only find one pair
                foreach (int cardValue in matches.Keys)
                {
                    if (matches[cardValue].Count == 2) // this is our pair
                    {
                        resultCards.AddRange(matches[cardValue]);
                        break;
                    }
                }

                // Also add the next highest card
                for (int highCard = cardList.Count - 1; highCard >= 0; highCard--)
                {
                    if (!resultCards.Contains(cardList[highCard]))
                    {
                        // Add the next highest card from the sorted list and break
                        resultCards.Add(cardList[highCard]);
                        break;
                    }
                }

                // Construct the Best Hand for one pair and return true
                //hand = new BestHand(resultCards, HandType.OnePair);
                hand = new Hand(resultCards, Combination.OnePair);
                return true;
            }

            // Two Pair and two pair only
            else if (numPairs >= 2 && numThrees == 0 && numFours == 0)
            {
                int numPairsFound = 0;

                // Continue with the assumption that we'll only find two pairs
                foreach (int cardValue in new Stack<int>(matches.Keys))
                {
                    if (matches[cardValue].Count == 2) // this is our pair
                    {
                        resultCards.AddRange(matches[cardValue]);
                        numPairs++;
                        if (numPairsFound >= 2)
                            break;
                    }
                }

                // Also add the next highest card
                for (int highCard = cardList.Count - 1; highCard >= 0; highCard--)
                {
                    if (!resultCards.Contains(cardList[highCard]))
                    {
                        // Add the next highest card from the sorted list and break
                        resultCards.Add(cardList[highCard]);
                        break;
                    }
//.........这里部分代码省略.........
开发者ID:bberak,项目名称:PokerDotNet,代码行数:101,代码来源:HandEvaluator.cs

示例7: FindBestCardsToTrash

		protected override IEnumerable<Card> FindBestCardsToTrash(IEnumerable<Card> cards, int count)
		{
			// choose the worse card in hand in this order
			// 1) curse
			// 2) cheapest card left

			CardCollection cardsToTrash = new CardCollection();
			cardsToTrash.AddRange(cards.Where(c => c.Category == Category.Curse).Take(count));
			if (cardsToTrash.Count >= count)
				return cardsToTrash;

			cardsToTrash.AddRange(cards.OrderBy(c => c.BaseCost).ThenBy(c => c.Name).Where(c => !cardsToTrash.Contains(c)).Take(count - cardsToTrash.Count));

			return cardsToTrash;
		}
开发者ID:micahpaul,项目名称:dominion_net_multi,代码行数:15,代码来源:jatill.cs


注:本文中的CardCollection.Contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。