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


C# Deck.Push方法代码示例

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


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

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

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

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

示例4: WhenThereAreTwoPlayersInAGameAndBothPlayersDrawACard_TheFirstPlayerHasTheirTurnAgain

        public void WhenThereAreTwoPlayersInAGameAndBothPlayersDrawACard_TheFirstPlayerHasTheirTurnAgain()
        {
            var game = Game.New();
            var firstPlayer = game.Join("Player1");
            var secondPlayer = game.Join("Player2");
            game.Start();

            var drawPile = new Deck();
            drawPile.Push(new Number(1, CardColour.Red));
            drawPile.Push(new Number(2, CardColour.Red));
            drawPile.Push(new Number(3, CardColour.Red));
            drawPile.Push(new Number(4, CardColour.Red));
            ((Game)game).DrawPile = drawPile;

            var discardPile = new DiscardPile();
            discardPile.Push(new Number(5, CardColour.Red));
            ((Game)game).DiscardPile = discardPile;

            ((Game)game).SetupDeckEvents();

            game.PlayCard(firstPlayer, game.DrawCard(firstPlayer));
            game.PlayCard(secondPlayer, game.DrawCard(secondPlayer));

            var currentPlayer = game.GetPlayerTurn();

            Assert.AreEqual(firstPlayer.ID, currentPlayer.ID);
        }
开发者ID:robisoft,项目名称:Uno,代码行数:27,代码来源:GameTests.cs


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