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


C# Deck.Draw方法代码示例

本文整理汇总了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>();
        }
开发者ID:benasradzevicius9404,项目名称:opp-poker,代码行数:10,代码来源:StandartDeckTests.cs

示例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]);
        }
开发者ID:benasradzevicius9404,项目名称:opp-poker,代码行数:10,代码来源:StandartDeckTests.cs

示例3: Play

 public void Play(Deck gameDeck)
 {
     if (!this.HasBlackJack() && !this.IsBusted() && Hand.GetTotal() < 17)
     {
         gameDeck.Draw(this);
     }
 }
开发者ID:genecyber,项目名称:TDD-BlackJack,代码行数:7,代码来源:Dealer.cs

示例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);
 }
开发者ID:Calneideck,项目名称:Blackjack,代码行数:8,代码来源:TestCard.cs

示例5: InitialDraw

 private IEnumerator InitialDraw(Deck deck)
 {
     for(int i=0; i < drawCount; i ++)
     {
         deck.Draw();
         yield return new WaitForSeconds(drawDelay);
     }
 }
开发者ID:sdomenici009,项目名称:Cards,代码行数:8,代码来源:GameStateManager.cs

示例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();
 }
开发者ID:lawrencewade,项目名称:cs440,代码行数:12,代码来源:Game.cs

示例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);
 }
开发者ID:Calneideck,项目名称:Blackjack,代码行数:8,代码来源:TestCard.cs

示例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);
            }
        }
开发者ID:jbfp,项目名称:Sequence_old,代码行数:22,代码来源:DeckTests.cs

示例9: DrawCardFromDeck

 private Card DrawCardFromDeck(Deck deck)
 {
     var card = deck.Draw();
     Player.Game.SendUpdateDeck(deck);
     return card;
 }
开发者ID:Slugburn,项目名称:Thunderstone,代码行数:6,代码来源:TopOfDeckSource.cs

示例10: ShowCard

 public Card ShowCard(Deck deck)
 {
     return deck.Draw();
 }
开发者ID:vadim183,项目名称:CodeValueCollege,代码行数:4,代码来源:Player.cs

示例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 ();
    }
开发者ID:hbons,项目名称:Deal,代码行数:26,代码来源:Deal.cs

示例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 ();
    }
开发者ID:hbons,项目名称:Deal,代码行数:57,代码来源:Deal.cs

示例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);
     }
 }
开发者ID:ischyrus,项目名称:coloretto_old,代码行数:17,代码来源:ColorettoDeckProviderTest.cs

示例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;
        }
开发者ID:ischyrus,项目名称:coloretto_old,代码行数:24,代码来源:StandardDeckProviderTest.cs

示例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;
 }
开发者ID:ischyrus,项目名称:coloretto_old,代码行数:16,代码来源:StandardDeckProviderTest.cs


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