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


C# CardCollection.Remove方法代码示例

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


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

示例1: GetOpponentCards

        public ICollection<Card> GetOpponentCards(ICollection<Card> myCards, ICollection<Card> playedCards, Card activeTrumpCard, CardSuit suit)
        {
            var playerCards = new CardCollection
                                  {
                                      new Card(suit, CardType.Nine),
                                      new Card(suit, CardType.Jack),
                                      new Card(suit, CardType.Queen),
                                      new Card(suit, CardType.King),
                                      new Card(suit, CardType.Ten),
                                      new Card(suit, CardType.Ace),
                                  };

            foreach (var card in myCards.Where(x => x.Suit == suit))
            {
                playerCards.Remove(card);
            }

            foreach (var card in playedCards.Where(x => x.Suit == suit))
            {
                playerCards.Remove(card);
            }

            if (activeTrumpCard != null)
            {
                playerCards.Remove(activeTrumpCard);
            }

            return playerCards;
        }
开发者ID:NotDemons,项目名称:NotDemonsRepo,代码行数:29,代码来源:OpponentSuitCardsProvider.cs

示例2: SetupDeckAs

		internal void SetupDeckAs(Player player)
		{
			CardCollection cards = new CardCollection(this.RetrieveCardsFrom(DeckLocation.Hand).Union(this.RetrieveCardsFrom(DeckLocation.Deck)));
			foreach (Card sourceCard in player.Hand)
			{
				Card myFoundCard = cards.First(c => c.CardType == sourceCard.CardType);
				cards.Remove(myFoundCard);
				this.AddCardInto(DeckLocation.Hand, myFoundCard);
			}
			this.AddCardsInto(DeckLocation.Deck, cards);
		}
开发者ID:micahpaul,项目名称:dominion_net_multi,代码行数:11,代码来源:Player.cs

示例3: CardCollection_RemoveTest

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

            target = target.Remove(card2);

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

示例4: GetListOfWinning

        public Queue<Card> GetListOfWinning(IList<Card> currentHand, CardSuit suit, Queue<Card> q)
        {
            var currentSuitCards = new CardCollection
                                  {
                                      new Card(suit, CardType.Nine),
                                      new Card(suit, CardType.Jack),
                                      new Card(suit, CardType.Queen),
                                      new Card(suit, CardType.King),
                                      new Card(suit, CardType.Ten),
                                      new Card(suit, CardType.Ace),
                                  };
            var cards = this.playedCardsInCurrentContext.Where(x => x.Suit == suit).ToList();
            foreach (var card in cards)
            {
                currentSuitCards.Remove(card);
            }

            currentSuitCards.OrderByDescending(x => x.GetValue()).ToList();
            if (currentSuitCards.Count() > 0)
            {
                if (currentHand.Contains(currentSuitCards.ElementAt(0)))
                {
                    q.Enqueue(currentSuitCards.First());
                }
            }

            return q;
        }
开发者ID:mimirerelala,项目名称:ElRumDrinkingCapitan,代码行数:28,代码来源:GameSimulation.cs

示例5: GetAllCards

        public ICollection<Card> GetAllCards(ICollection<Card> myCards, ICollection<Card> playedCardsInCurrentContext, Card activeTrumpCard)
        {
            var allCards = new CardCollection
                                  {
                                      new Card(CardSuit.Spade, CardType.Nine),
                                      new Card(CardSuit.Spade, CardType.Jack),
                                      new Card(CardSuit.Spade, CardType.Queen),
                                      new Card(CardSuit.Spade, CardType.King),
                                      new Card(CardSuit.Spade, CardType.Ten),
                                      new Card(CardSuit.Spade, CardType.Ace),
                                      new Card(CardSuit.Diamond, CardType.Nine),
                                      new Card(CardSuit.Diamond, CardType.Jack),
                                      new Card(CardSuit.Diamond, CardType.Queen),
                                      new Card(CardSuit.Diamond, CardType.King),
                                      new Card(CardSuit.Diamond, CardType.Ten),
                                      new Card(CardSuit.Diamond, CardType.Ace),
                                      new Card(CardSuit.Club, CardType.Nine),
                                      new Card(CardSuit.Club, CardType.Jack),
                                      new Card(CardSuit.Club, CardType.Queen),
                                      new Card(CardSuit.Club, CardType.King),
                                      new Card(CardSuit.Club, CardType.Ten),
                                      new Card(CardSuit.Club, CardType.Ace),
                                      new Card(CardSuit.Heart, CardType.Nine),
                                      new Card(CardSuit.Heart, CardType.Jack),
                                      new Card(CardSuit.Heart, CardType.Queen),
                                      new Card(CardSuit.Heart, CardType.King),
                                      new Card(CardSuit.Heart, CardType.Ten),
                                      new Card(CardSuit.Heart, CardType.Ace),
                                  };

            foreach (var card in myCards)
            {
                allCards.Remove(card);
            }

            foreach (var card in playedCardsInCurrentContext)
            {
                allCards.Remove(card);
            }

            return allCards;
        }
开发者ID:mimirerelala,项目名称:ElRumDrinkingCapitan,代码行数:42,代码来源:GameSimulation.cs

示例6: IsStraight

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

            // Get a copy of the card list
            CardCollection cardList = new CardCollection(_cardList);

            winningCards = new CardCollection();

            // Sort the cards by value
            cardList.Sort();

            // if there is an ace in the deck, it got moved to the end by the sort
            // so we need to insert a new "ace" in the sorted deck (with a value of 1) in the beginning position
            foreach (Card card in cardList)
            {
                if (card.Value == (int)Rank.Ace)
                {
                    cardList.Insert(0, new Card(card.Rank, card.Suit));
                    break;
                }
            }

            int cardsInARow = 1;

            // Check each card and the next one
            for (int i = 0; i < cardList.Count; i++)
            {
                // Add the current card to the winning cards index, just in case it's part of a straight
                winningCards.Add(cardList[i]);

                // If this is the last card, check to see if it is part of a straight
                if (i == cardList.Count - 1)
                {
                    if (cardList[i].IsOneGreaterThan(cardList[i - 1]))
                    {
                        cardsInARow++;
                    }
                    else
                        winningCards.Clear();
                }
                else
                {
                    // If this card is the same as the next one, ignore it
                    if (cardList[i].Value == cardList[i + 1].Value)
                    {
                        // remove the card we just added
                        winningCards.Remove(cardList[i]);
                        continue;
                    }

                    // Check to see if this card is exactly one less than the next card
                    if (cardList[i].IsOneLessThan(cardList[i + 1]))
                    {
                        cardsInARow++;
                    }
                    else
                    {
                        // if we already have a straight (5 cards) stop checking for more straights
                        if (cardsInARow >= 5)
                            break;
                        else
                        {
                            cardsInARow = 1;
                            winningCards.Clear();
                        }
                    }
                }
            }

            // Trim off any excess cards that are not the highest straight, and return true
            // Example: if you have A 2 3 4 5 6, the ace will be cut off and 2 3 4 5 6 will be preserved
            if (winningCards.Count >= 5)
            {
                if (winningCards.Count > 5)
                    winningCards.RemoveRange(0, winningCards.Count - 5);

                return true;
            }

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

示例7: RemoveShouldWorkProperly

 public void RemoveShouldWorkProperly()
 {
     var card1 = new Card(CardSuit.Club, CardType.Ace); // 1
     var card2 = new Card(CardSuit.Spade, CardType.King); // 52
     var collection = new CardCollection { card1, card2 };
     collection.Remove(card1);
     collection.Remove(card2);
     Assert.AreEqual(0, collection.Count);
 }
开发者ID:NotDemons,项目名称:NotDemonsRepo,代码行数:9,代码来源:CardCollectionTests.cs

示例8: RemoveNonExistingCardsShouldNotRemoveThem

 public void RemoveNonExistingCardsShouldNotRemoveThem()
 {
     var collection = new CardCollection { new Card(CardSuit.Spade, CardType.Ace) };
     collection.Remove(new Card(CardSuit.Club, CardType.Ace));
     Assert.AreEqual(1, collection.Count);
 }
开发者ID:NotDemons,项目名称:NotDemonsRepo,代码行数:6,代码来源:CardCollectionTests.cs

示例9: CountShouldReturn1WhenOneCardIsAddedAndThenRemoved

 public void CountShouldReturn1WhenOneCardIsAddedAndThenRemoved()
 {
     var collection = new CardCollection();
     var card = new Card(CardSuit.Club, CardType.Ace);
     collection.Add(card);
     collection.Remove(card);
     Assert.AreEqual(0, collection.Count);
 }
开发者ID:NotDemons,项目名称:NotDemonsRepo,代码行数:8,代码来源:CardCollectionTests.cs


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