本文整理汇总了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()}");
}
示例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());
}
示例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);
}
示例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);
}
示例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());
}
示例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());
}
示例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);
}
示例8: WhenADeckHasNoCards_PoppingACardReturnsNull
public void WhenADeckHasNoCards_PoppingACardReturnsNull()
{
var deck = new Deck();
Assert.IsNull(deck.Pop());
}