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


C# Deck.Pop方法代码示例

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


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

示例1: TestDeck

 public static void TestDeck()
 {
     Console.ForegroundColor = ConsoleColor.Cyan;
     var d = new Deck();
     d.Shuffle();
     for (var i = 0; i < 52; i += 4)
         Console.WriteLine($"{i + 1}: {d.Pop()}   {i + 2}: {d.Pop()}   {i + 3}: {d.Pop()}   {i + 4}: {d.Pop()}");
 }
开发者ID:Anders-H,项目名称:GenericPokerFormationChecker,代码行数:8,代码来源:Program.cs

示例2: ReturnCards_ReturnsEnumerableOfCardsAndClearsHand

        public void ReturnCards_ReturnsEnumerableOfCardsAndClearsHand()
        {
            Deck deck = new Deck();
            PokerPlayer player = new PokerPlayer("RobA2345");
            player.ReceiveCard(deck.Pop());
            player.ReceiveCard(deck.Pop());

            Assert.AreEqual(2, player.ShowHand().Count());

            IEnumerable<Card> cards = player.ReturnCards();
            Assert.AreEqual(2, cards.Count());
            Assert.AreEqual(0, player.ShowHand().Count());
        }
开发者ID:GrimeyCoder,项目名称:CommonGames,代码行数:13,代码来源:PokerPlayerTests.cs

示例3: WhenADeckIsShuffled_TheCardsAreNotInExactlyTheSameOrderAsBefore

        public void WhenADeckIsShuffled_TheCardsAreNotInExactlyTheSameOrderAsBefore()
        {
            var deck = new Deck();
            var expectedCardString = string.Empty;

            // Add Cards to Deck
            for (var i = 1; i <= 9; i++)
            {
                var card = deck.Push(new Cards.Number(i, CardColour.Blue));
                expectedCardString += string.Format("{0}{1}", card.Colour, card.Value);
            }

            // Shuffle the Deck
            deck.Shuffle();

            // Remove Cards from Deck
            var cards = new List<ICard>();
            while (deck.NumberOfCardsInDeck > 0)
            {
                cards.Add(deck.Pop());
            }

            // Build Compare Strings in reverse order because the Deck is a Stack (LIFO).  (I understand due to the way shuffling occurs that in theory the decks could be identical in some universe)
            var actualCardString = string.Empty;
            for (var i = cards.Count - 1; i >= 0; i--)
            {
                actualCardString += string.Format("{0}{1}", cards[i].Colour, cards[i].Value);
            }

            Assert.AreNotEqual(actualCardString, expectedCardString);
        }
开发者ID:robisoft,项目名称:Uno,代码行数:31,代码来源:DeckTests.cs

示例4: WhenADeckIsFlipped_TheCardsAreInExactlyTheReverseOrder

        public void WhenADeckIsFlipped_TheCardsAreInExactlyTheReverseOrder()
        {
            var deck = new Deck();
            var expectedCardString = string.Empty;

            // Add Cards to Deck
            for (var i = 1; i <= 9; i++)
            {
                var card = deck.Push(new Cards.Number(i, CardColour.Blue));
                expectedCardString += string.Format("{0}{1}{2}", card.GetType(), card.Colour, card.Value);
            }

            // Flip the Deck
            deck.Flip();

            // Remove Cards from Deck
            var cards = new List<ICard>();
            while (deck.NumberOfCardsInDeck > 0)
            {
                cards.Add(deck.Pop());
            }

            // Build Compare Strings in reverse order because the Deck is a Stack (LIFO).  (I understand due to the way shuffling occurs that in theory the decks could be identical in some universe)
            var actualCardString = cards.Aggregate(string.Empty,
                                                   (current, t) =>
                                                   current + string.Format("{0}{1}{2}", t.GetType(), t.Colour, t.Value));

            Assert.AreEqual(actualCardString, expectedCardString);
        }
开发者ID:robisoft,项目名称:Uno,代码行数:29,代码来源:DeckTests.cs

示例5: ReceiveCard_AddsCardToHand

 public void ReceiveCard_AddsCardToHand()
 {
     Deck deck = new Deck();
     PokerPlayer player = new PokerPlayer("RobA2345");
     player.ReceiveCard(deck.Pop());
     Assert.AreEqual(1, player.ShowHand().Count());
 }
开发者ID:GrimeyCoder,项目名称:CommonGames,代码行数:7,代码来源:PokerPlayerTests.cs

示例6: AddCommunityCard_AddsCardToCommunityCards

 public void AddCommunityCard_AddsCardToCommunityCards()
 {
     Game game = new Game();
     Deck deck = new Deck();
     game.AddCommunityCard(deck.Pop());
     Assert.AreEqual(51, deck.Count);
     Assert.AreEqual(1, game.CommunityCards.Count());
 }
开发者ID:GrimeyCoder,项目名称:CommonGames,代码行数:8,代码来源:GameTests.cs

示例7: WhenACardIsAddedToADeck_TheNextCardOffTheDeckIsTheLastCardAdded

        public void WhenACardIsAddedToADeck_TheNextCardOffTheDeckIsTheLastCardAdded()
        {
            var deck = new Deck();

            var card = new Cards.Number(1, CardColour.Blue);

            deck.Push(card);

            Assert.AreEqual(deck.Pop(), card);
        }
开发者ID:robisoft,项目名称:Uno,代码行数:10,代码来源:DeckTests.cs

示例8: WhenADeckHasNoCards_PoppingACardReturnsNull

        public void WhenADeckHasNoCards_PoppingACardReturnsNull()
        {
            var deck = new Deck();

            Assert.IsNull(deck.Pop());
        }
开发者ID:robisoft,项目名称:Uno,代码行数:6,代码来源:DeckTests.cs


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