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


C# CardCollection.Add方法代码示例

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


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

示例1: CardCollection_AdditionTest

        public void CardCollection_AdditionTest()
        {
            CardCollection left = new CardCollection();

            ColorettoCard card1 = new ColorettoCard(ColorettoCardColors.Blue);
            ColorettoCard card2 = new ColorettoCard(ColorettoCardColors.Brown);
            ColorettoCard card3 = new ColorettoCard(ColorettoCardColors.Gray);

            left = left.Add(card1);
            left = left.Add(card2);
            left = left.Add(card3);

            CardCollection right = new CardCollection();

            card1 = new ColorettoCard(ColorettoCardColors.Blue);
            card2 = new ColorettoCard(ColorettoCardColors.Brown);
            card3 = new ColorettoCard(ColorettoCardColors.Gray);

            right = right.Add(card1);
            right = right.Add(card2);
            right = right.Add(card3);

            CardCollection added = left + right;
            Assert.AreEqual<int>(6, added.Count);
            Assert.AreEqual<int>(9, added.Score);
        }
开发者ID:ischyrus,项目名称:coloretto_old,代码行数:26,代码来源:CardCollectionTest.cs

示例2: Test_DetermineWinners_FullHouse_TwoWinners

        public void Test_DetermineWinners_FullHouse_TwoWinners()
        {
            Player winner1 = new Player("Winner1", 1000);
            winner1.Cards.Add(new Card(Rank.Two, Suit.Spades));
            winner1.Cards.Add(new Card(Rank.Two, Suit.Hearts));

            Player winner2 = new Player("Winner2", 1000);
            winner2.Cards.Add(new Card(Rank.Two, Suit.Diamonds));
            winner2.Cards.Add(new Card(Rank.Two, Suit.Clubs));

            CardCollection communityCards = new CardCollection();
            communityCards.Add(new Card(Rank.Three, Suit.Hearts));
            communityCards.Add(new Card(Rank.Six, Suit.Clubs));
            communityCards.Add(new Card(Rank.King, Suit.Hearts));
            communityCards.Add(new Card(Rank.King, Suit.Spades));
            communityCards.Add(new Card(Rank.King, Suit.Diamonds));

            HandEvaluator eval = new HandEvaluator();

            Hand hand1 = eval.GetBestHand(winner1.Cards + communityCards);

            Hand hand2 = eval.GetBestHand(winner2.Cards + communityCards);

            Assert.AreEqual(0, HandEvaluator.Compare(hand1, hand2));
        }
开发者ID:bberak,项目名称:PokerDotNet,代码行数:25,代码来源:HandEvaluatorTest.cs

示例3: AddTest

        public void AddTest()
        {
            var cc = new CardCollection();

            cc.Add(new Card("TEST1", "Test1"));
            cc.Add("TEST2", new Card("TEST2", "Test2"));

            // Test add with existing keyword
        }
开发者ID:skyquery,项目名称:sharpfitsio,代码行数:9,代码来源:CardCollectionTest.cs

示例4: CardCollection

        public static CardCollection operator +(Card c1, Card c2)
        {
            CardCollection summCollection = new CardCollection();

            if (c1 != null)
                summCollection.Add(c1);

            if (c2 != null)
                summCollection.Add(c2);

            return summCollection;
        }
开发者ID:bberak,项目名称:PokerDotNet,代码行数:12,代码来源:Card.cs

示例5: TestUpdateLocation

		public void TestUpdateLocation( )
		{
			CardCollection coll = new CardCollection( );

			coll.Add( new Card( Suit.Clubs, 10, true, null ) );
			coll.Add( new Card( Suit.Diamonds, 11, true, null ) );
			coll.Add( new Card( Suit.Diamonds, 7, true, null ) );

			coll.UpdateLocation( 10, 7 );

			// This test does in fact rely on the fact that a card
			// will by default initialize its location to 0,0. 
			Assert.AreEqual( coll[ 0 ].Location.X, 10 );
		}
开发者ID:VictorGressier,项目名称:skul,代码行数:14,代码来源:CardCollectionTest.cs

示例6: CardCollection_AddTest

        public void CardCollection_AddTest()
        {
            CardCollection target = new CardCollection();

            ColorettoCard card1 = new ColorettoCard(ColorettoCardColors.Blue);
            ColorettoCard card2 = new ColorettoCard(ColorettoCardColors.Brown);
            ColorettoCard card3 = new ColorettoCard(ColorettoCardColors.Gray);

            target = target.Add(card1);
            target = target.Add(card2);
            target = target.Add(card3);

            Assert.AreEqual<ColorettoCard>(card1, target[0]);
            Assert.AreEqual<ColorettoCard>(card2, target[1]);
            Assert.AreEqual<ColorettoCard>(card3, target[2]);
        }
开发者ID:ischyrus,项目名称:coloretto_old,代码行数:16,代码来源:CardCollectionTest.cs

示例7: TestAlternatingColors

		public void TestAlternatingColors( )
		{
			CardCollection coll = new CardCollection( );

			// An empty one is also alternating:
			Assert.AreEqual( coll.IsAlternatingColors( ), true );
			coll.Add( new Card( Suit.Clubs, 10, true, null ) );

			// So is a collection of only one element:
			Assert.AreEqual( coll.IsAlternatingColors( ), true );

			// Then, add a few cards of alternating colors:
			coll.Add( new Card( Suit.Diamonds, 11, true, null ) );
			coll.Add( new Card( Suit.Clubs, 7, true, null ) );
			coll.Add( new Card( Suit.Diamonds, 11, true, null ) );
			coll.Add( new Card( Suit.Spades, 7, true, null ) );
			coll.Add( new Card( Suit.Hearts, 11, true, null ) );
			coll.Add( new Card( Suit.Clubs, 7, true, null ) );

			// This should hold:
			Assert.AreEqual( coll.IsAlternatingColors( ), true );

			// Finally, remove a card in the middle:

			coll.RemoveAt( 2 );

			// ... which should make it no longer alternating:
			Assert.AreEqual( coll.IsAlternatingColors( ), false );
		}
开发者ID:VictorGressier,项目名称:skul,代码行数:29,代码来源:CardCollectionTest.cs

示例8: CreateEnemyCollection

 public static CardCollection CreateEnemyCollection()
 {
     // Create enemy deck collection and return
     CardCollection enemyDeck = new CardCollection();
     foreach (string c in EnemyDeck1)
     {
         enemyDeck.Add(CardData.CreateCardFromName(c));
     }
     return enemyDeck;
 }
开发者ID:sgastudio,项目名称:Yugioh,代码行数:10,代码来源:EnemyDecks.cs

示例9: BitsToCardCollection

        internal static CardCollection BitsToCardCollection(int source)
        {
            var result = new CardCollection();

            for (int i = 0; i < 32; i++)
            {
                int card = (1 << i);
                if ((source & card) != 0)
                    result.Add(BitsToCard(card));
            }

            return result;
        }
开发者ID:DVorobyev,项目名称:Preference,代码行数:13,代码来源:BitwiseCardHelper.cs

示例10: 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

示例11: CardCollection_TooManyPiles

        public void CardCollection_TooManyPiles()
        {
            CardCollection target = new CardCollection();

            ColorettoCard card1 = new ColorettoCard(ColorettoCardColors.Blue);
            ColorettoCard card2 = new ColorettoCard(ColorettoCardColors.Brown);
            ColorettoCard card3 = new ColorettoCard(ColorettoCardColors.Gray);
            ColorettoCard card4 = new ColorettoCard(ColorettoCardColors.Green);
            ColorettoCard card5 = new ColorettoCard(ColorettoCardColors.Orange);

            ColorettoCard wild = new ColorettoCard(ColorettoCardTypes.Wild);

            target = target.Add(card1);
            target = target.Add((ColorettoCard)card1.Clone());
            target = target.Add((ColorettoCard)card1.Clone());
            target = target.Add(wild);

            target = target.Add(card2);
            target = target.Add((ColorettoCard)card2.Clone());
            target = target.Add((ColorettoCard)card2.Clone());

            target = target.Add(card3);
            target = target.Add(card4);

            Assert.AreEqual<int>(16, target.Score);
        }
开发者ID:ischyrus,项目名称:coloretto_old,代码行数:26,代码来源:CardCollectionTest.cs

示例12: Recognize

        /// <summary>
        /// Detects and recognizes cards from source image
        /// </summary>
        /// <param name="source">Source image to be scanned</param>
        /// <returns>Recognized Cards</returns>
        public CardCollection Recognize(Bitmap source, string filePath, int id,
            int minSize, Rectangle suitRect, Rectangle rankRect
            )
        {
            CardCollection collection = new CardCollection();  //Collection that will hold cards
            Bitmap temp = source.Clone() as Bitmap; //Clone image to keep original image

            FiltersSequence seq = new FiltersSequence();
            seq.Add(Grayscale.CommonAlgorithms.BT709);  //First add  grayScaling filter
            seq.Add(new OtsuThreshold()); //Then add binarization(thresholding) filter
            temp = seq.Apply(source); // Apply filters on source image

            //if (!string.IsNullOrEmpty(fileName))
            //{
            //    temp.Save(fileName, ImageFormat.Bmp);
            //}
            //Extract blobs from image whose size width and height larger than 150
            BlobCounter extractor = new BlobCounter();
            extractor.FilterBlobs = true;
            extractor.MinWidth = extractor.MinHeight = minSize;//TODO card size
            //extractor.MaxWidth = extractor.MaxHeight = 70;//TODO card size
            extractor.ProcessImage(temp);

            //Will be used transform(extract) cards on source image
            //QuadrilateralTransformation quadTransformer = new QuadrilateralTransformation();

            foreach (Blob blob in extractor.GetObjectsInformation())
            {
                var cardImg = source.Clone(blob.Rectangle, PixelFormat.DontCare);

                Card card = new Card(cardImg); //Create Card Object

                Bitmap suitBmp = card.GetPart(suitRect);
                char color = ScanColor(suitBmp); //Scan color

                seq.Clear();

                seq.Add(Grayscale.CommonAlgorithms.BT709);
                seq.Add(new OtsuThreshold());
                suitBmp = seq.Apply(suitBmp);

                card.Suit = ScanSuit(suitBmp, color); //Scan suit of face card

                Bitmap rankBmp = card.GetPart(rankRect);
                seq.Clear();

                seq.Add(Grayscale.CommonAlgorithms.BT709);
                seq.Add(new OtsuThreshold());
                rankBmp = seq.Apply(rankBmp);

                //var ext = new BlobsFiltering(0, 0, 40, 40);
                //ext.ApplyInPlace(rankBmp);
                card.Rank = ScanRank(rankBmp); //Scan Rank of non-face card

                //if (card.Rank == Rank.NOT_RECOGNIZED)
                //{
                //    if (!string.IsNullOrEmpty(filePath))
                //    {
                //        while (File.Exists(filePath + id + ".bmp"))
                //            id++;
                //        top.Save(filePath + id + ".bmp", ImageFormat.Bmp);
                //    }
                //}

                if(card.Rank != Rank.NOT_RECOGNIZED && card.Suit != Suit.NOT_RECOGNIZED)
                    collection.Add(card); //Add card to collection
            }

            collection.SortByRank();
            return collection;
        }
开发者ID:ramonliu,项目名称:poker-miranda,代码行数:76,代码来源:CardRecognizer.cs

示例13: IsFlush

        public bool IsFlush(out CardCollection winningCards)
        {
            checkCardList();

            CardCollection cardList = new CardCollection(_cardList);

            CardCollection clubs = new CardCollection();
            CardCollection diamonds = new CardCollection();
            CardCollection hearts = new CardCollection();
            CardCollection spades = new CardCollection();

            foreach (Card card in cardList)
            {
                switch (card.Suit)
                {
                    case Suit.Clubs:
                        clubs.Add(card);
                        break;
                    case Suit.Diamonds:
                        diamonds.Add(card);
                        break;
                    case Suit.Hearts:
                        hearts.Add(card);
                        break;
                    case Suit.Spades:
                        spades.Add(card);
                        break;
                    default:
                        break;
                }
            }

            if (clubs.Count >= 5)
            {
                winningCards = clubs;
                winningCards.Sort();
                return true;
            }

            if (diamonds.Count >= 5)
            {
                winningCards = diamonds;
                winningCards.Sort();
                return true;
            }

            if (hearts.Count >= 5)
            {
                winningCards = hearts;
                winningCards.Sort();
                return true;
            }

            if (spades.Count >= 5)
            {
                winningCards = spades;
                winningCards.Sort();
                return true;
            }

            winningCards = null;
            return false;
        }
开发者ID:bberak,项目名称:PokerDotNet,代码行数:63,代码来源:HandEvaluator.cs

示例14: GetEnumeratorShouldReturnAllElementsInCollection

        public void GetEnumeratorShouldReturnAllElementsInCollection()
        {
            var cards = new List<Card>
                            {
                                new Card(CardSuit.Club, CardType.Ace),
                                new Card(CardSuit.Spade, CardType.Ace),
                                new Card(CardSuit.Diamond, CardType.Ten),
                                new Card(CardSuit.Heart, CardType.Jack),
                                new Card(CardSuit.Club, CardType.Nine),
                                new Card(CardSuit.Spade, CardType.Nine)
                            };

            var collection = new CardCollection();
            foreach (var card in cards)
            {
                collection.Add(card);
            }

            foreach (var card in collection)
            {
                Assert.IsTrue(cards.Contains(card), $"Card {card} not found in collection!");
            }

            // Second enumeration
            var count = 0;
            foreach (var card in collection)
            {
                Assert.IsTrue(cards.Contains(card), $"Card {card} not found in collection!");
                count++;
            }

            Assert.AreEqual(cards.Count, count);
        }
开发者ID:NotDemons,项目名称:NotDemonsRepo,代码行数:33,代码来源:CardCollectionTests.cs

示例15: CountShouldReturnCorrectValueAfterAddingAllCards

        public void CountShouldReturnCorrectValueAfterAddingAllCards()
        {
            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);
                }
            }

            Assert.AreEqual(24, collection.Count);
        }
开发者ID:NotDemons,项目名称:NotDemonsRepo,代码行数:14,代码来源:CardCollectionTests.cs


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