本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}