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


C# Hand.GetValue方法代码示例

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


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

示例1: GetValue_ShouldReturnCorrectResult_ForTwoCards

        public void GetValue_ShouldReturnCorrectResult_ForTwoCards(Ranks rank1, Ranks rank2, int expectedValue, Hand hand, Suits suit)
        {
            hand.AddCard(rank1.Of(suit));
            hand.AddCard(rank2.Of(suit));

            Assert.Equal(expectedValue, hand.GetValue());
        }
开发者ID:yakimovim,项目名称:Blackjack,代码行数:7,代码来源:HandTest.cs

示例2: Play_ShouldAddCardsUntil17

        public void Play_ShouldAddCardsUntil17(LeveledDealerStrategy dealerStrategy, 
            Hand dealerHand,
            [Frozen(As = typeof(IDeckCreator))] FullDeckCreator deckCreator,
            EndlessCardsProvider cardsProvider)
        {
            dealerStrategy.Play(dealerHand, cardsProvider);

            _outputHelper.WriteLine(string.Join(", ", dealerHand.Cards));

            Assert.True(dealerHand.GetValue() >= 17);
        }
开发者ID:yakimovim,项目名称:Blackjack,代码行数:11,代码来源:LeveledDealerStrategyTest.cs

示例3: GetValue_ShouldReturnCorrectResult_ForOneCard

        public void GetValue_ShouldReturnCorrectResult_ForOneCard(Hand hand, Card card)
        {
            var expectedValue = BlackJack.CardValues[card.Rank];
            if (card.Rank == Ace)
            {
                expectedValue += BlackJack.AceIncrement;
            }

            hand.AddCard(card);

            Assert.Equal(expectedValue, hand.GetValue());
        }
开发者ID:yakimovim,项目名称:Blackjack,代码行数:12,代码来源:HandTest.cs

示例4: Deal

        /// <summary>
        /// Deals cards to the players, then the dealer.
        /// </summary>
        public void Deal()
        {
            _deck.Shuffle();

            // Deal to all of the players.
            foreach (var playerKV in _players)
            {
                var playerID = playerKV.Key;
                var player = playerKV.Value;

                // Deal two cards.
                var hand = new Hand();
                Deal(hand, 2);
                player.Hands.Add(hand);

                // Blackjack! You win! And can't do anything!
                if (hand.GetValue() == 21)
                {
                    hand.State = HandState.Blackjack;
                }

                // Show the player their hand.
                PrintPlayersHands(playerID);
            }

            // Deal to dealer, and hide the hole card.
            _dealerHand = new Hand();
            Deal(_dealerHand, 2);
            PrintDealer(true);

            CheckInsurance();
            ChangeState(State.PlayerTurn);

            // What if everyone playing got a blackjack?!?!
            CheckHands();
        }
开发者ID:bakerj76,项目名称:SteamNerd,代码行数:39,代码来源:Blackjack.cs


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