本文整理汇总了C#中Deck.Draw方法的典型用法代码示例。如果您正苦于以下问题:C# Deck.Draw方法的具体用法?C# Deck.Draw怎么用?C# Deck.Draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Deck
的用法示例。
在下文中一共展示了Deck.Draw方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw_ShouldThrowException_IfDeckIsEmpty
public void Draw_ShouldThrowException_IfDeckIsEmpty()
{
var deck = new Deck<StandartCard>(OpositeOrderShufflerMock().Object, new[] { new StandartCard(Suit.Clubs, Rank.Ace) });
deck.Draw();
var act = new Action(() => deck.Draw());
act.ShouldThrow<InvalidOperationException>();
}
示例2: Draw_ShouldDrawCardSuccessfully
public void Draw_ShouldDrawCardSuccessfully()
{
var cards = RandomStandartCards();
var deck = new Deck<StandartCard>(OpositeOrderShufflerMock().Object, cards);
deck.Draw().Should().Be(cards[0]);
deck.Draw().Should().Be(cards[1]);
deck.Draw().Should().Be(cards[2]);
deck.Draw().Should().Be(cards[3]);
}
示例3: Play
public void Play(Deck gameDeck)
{
if (!this.HasBlackJack() && !this.IsBusted() && Hand.GetTotal() < 17)
{
gameDeck.Draw(this);
}
}
示例4: TestDealCard
public void TestDealCard()
{
Deck deck = new Deck();
Player hand = new Player();
Assert.IsTrue(deck.CardsLeft() == 52);
deck.Draw();
Assert.IsTrue(deck.CardsLeft() == 51);
}
示例5: InitialDraw
private IEnumerator InitialDraw(Deck deck)
{
for(int i=0; i < drawCount; i ++)
{
deck.Draw();
yield return new WaitForSeconds(drawDelay);
}
}
示例6: Game
public Game(Player Master, List<Player> Learners, Random Random)
{
_Random = Random;
_Deck = new Deck();
_Deck.Shuffle(_Random);
_Return = new Deck(true);
_Master = Master;
_Learners = Learners;
_MasterHand = new Hand(10, _Deck);
foreach(Player L in _Learners) _LearnerHands.Add(new Hand(10, _Deck));
_DownCard = _Deck.Draw();
}
示例7: TestPlayerTotal
public void TestPlayerTotal()
{
Deck deck = new Deck();
Player hand = new Player();
Assert.IsTrue(hand.Cards.Count == 0);
hand.AddCard(deck.Draw());
Assert.IsTrue(hand.Cards.Count == 1);
}
示例8: DrawHands_draws_the_top_cards_from_the_stack
public void DrawHands_draws_the_top_cards_from_the_stack()
{
// Arrange.
var seed = Environment.TickCount;
var sut = new Deck();
var controlDeck = new Deck();
sut.Shuffle(seed);
controlDeck.Shuffle(seed);
// Act.
var hands = sut.DrawHands(2);
var controlHands = hands.Select(hand => hand.Select(card => controlDeck.Draw())).ToList();
// Assert.
for (int i = 0; i < hands.Count; i++)
{
var hand = hands[i];
var controlHand = controlHands[i];
ActualValueDelegate<bool> test = () => hand.SequenceEqual(controlHand);
Assert.That(test, Is.True);
}
}
示例9: DrawCardFromDeck
private Card DrawCardFromDeck(Deck deck)
{
var card = deck.Draw();
Player.Game.SendUpdateDeck(deck);
return card;
}
示例10: ShowCard
public Card ShowCard(Deck deck)
{
return deck.Draw();
}
示例11: NewGame
static void NewGame(object o, ButtonPressEventArgs args)
{
Bet = 0;
DealButton.Opacity = 0;
BetButton.Opacity = 255;
BetButton.Reactive = true;
BetButton.Show ();
StepButton.HoldState ();
StepButton.Show ();
// Needs to be replaced with "return to deck" animation
for (int i = 0; i < 5; i++) {
PlayerHand.GetCard (i).Hide ();
OpponentHand.GetCard (i).Hide ();
}
Deck = new Deck ();
PlayerHand = new Hand (Deck.Draw (), Deck.Draw (), Deck.Draw (), Deck.Draw (), Deck.Draw ());
OpponentHand = new Hand (Deck.Draw (), Deck.Draw (), Deck.Draw (), Deck.Draw (), Deck.Draw ());
SetupAnimation ();
}
示例12: Main
static void Main()
{
Clutter.Application.Init ();
Stage = new Stage ();
Stage.Title = "Deal!";
Stage.Add (new Texture ("Pixmaps/Table.png"));
Stage.SetSize (800, 480);
Stage.KeyPressEvent += HandleKeyPress;
Texture C = new Texture ("Pixmaps/Coin.png");
C.SetSize (50, 50);
C.SetPosition (35, 405);
Stage.Add (C);
Bet = 0;
BetButton = new BetButton ();
BetButton.ButtonPressEvent += IncreaseBet;
Stage.Add (BetButton);
DealButton = new DealButton ();
DealButton.ButtonPressEvent += NewGame;
Stage.Add (DealButton);
StepButton = new StepButton ();
StepButton.ButtonPressEvent += NextStep;
Stage.Add (StepButton);
Stack = new Stack ();
Stack.Decrease (20);
ScoreText = new Text ("Droid Sans Bold 21", "" + Stack.GetAmount());
ScoreText.SetColor (new Clutter.Color (0xff, 0xff, 0xff, 0xff));
ScoreText.SetPosition (100, 413);
Stage.Add (ScoreText);
Coins = new Coin [5];
Coins [0] = new Coin ();
Coins [1] = new Coin ();
Coins [2] = new Coin ();
Coins [3] = new Coin ();
Coins [4] = new Coin ();
for (int i = 0; i < 5; i++) {
Coins [i].SetPosition (35, 405);
Stage.Add (Coins [i]);
}
Deck = new Deck ();
PlayerHand = new Hand (Deck.Draw (), Deck.Draw (), Deck.Draw (), Deck.Draw (), Deck.Draw ());
OpponentHand = new Hand (Deck.Draw (), Deck.Draw (), Deck.Draw (), Deck.Draw (), Deck.Draw ());
SetupAnimation ();
Stage.ShowAll();
Clutter.Application.Run ();
}
示例13: DeckEnumeration
/// <summary>
/// Enumerate through a deck
/// </summary>
/// <param name="deck"></param>
/// <returns></returns>
private static IEnumerable<ColorettoCard> DeckEnumeration(Deck<ColorettoCard> deck)
{
if (deck != null && !deck.IsEmpty)
{
do
{
ColorettoCard card = null;
deck = deck.Draw(out card);
yield return card;
} while (!deck.IsEmpty);
}
}
示例14: IsValid_CollatedDuplication
/// <summary>
/// Verifies that expectedContent is a subset of deck and each card in expectedContent exists sequentually numberOfDups times.
/// </summary>
/// <param name="expectedContent"></param>
/// <param name="deck"></param>
/// <param name="numberOfDups"></param>
/// <returns></returns>
private static bool IsValid_CollatedDuplication(List<StandardCard> expectedContent, Deck<StandardCard> deck, int numberOfDups)
{
for (int i = 0; i < expectedContent.Count; i++)
{
for (int j = 0; j < numberOfDups; j++)
{
StandardCard card;
deck = deck.Draw(out card);
if (expectedContent[i].Equals(card) == false)
{
return false;
}
}
}
return true;
}
示例15: ConvertDeckToList
/// <summary>
/// Takes a deck and converts it into a list by drawing cards.
/// </summary>
/// <param name="deck"></param>
/// <returns></returns>
private static List<StandardCard> ConvertDeckToList(Deck<StandardCard> deck)
{
List<StandardCard> list = new List<StandardCard>(deck.OriginalSize);
for (int i = 0; i < deck.OriginalSize; i++)
{
StandardCard card = null;
deck = deck.Draw(out card);
list.Add(card);
}
return list;
}