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


C# Player.GetHand方法代码示例

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


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

示例1: CalcWinner

        public bool CalcWinner(Player a_player, Dealer a_dealer)
        {
            int[] cardScores = a_dealer.getCardScoreArray();
            IEnumerable<Card> pHand = a_player.GetHand();
            IEnumerable<Card> dHand = a_dealer.GetHand();

            Card PlayerHighest = getHighestCardInHand(pHand, a_dealer);
            Card DealerHighest = getHighestCardInHand(dHand, a_dealer);

            if (cardScores[(int)PlayerHighest.GetValue()] == cardScores[(int)DealerHighest.GetValue()])
            {
                //if the second parameter is higher value then false is returned, aka player win.
                return isHigherCardColorValue(DealerHighest.GetColor(), PlayerHighest.GetColor());
            }

            if (cardScores[(int)PlayerHighest.GetValue()] > cardScores[(int)DealerHighest.GetValue()])
            {
                //player won
                return false;
            }
            else
            {
                //dealer won.
                return true;
            }
        }
开发者ID:MartinArvidsson,项目名称:UML,代码行数:26,代码来源:Highestcardrule.cs

示例2: DoHit

        public bool DoHit(Player a_dealer)
        {
            IEnumerable<Card> hand = a_dealer.GetHand();

            //if the dealear has 17...
            if (a_dealer.CalcScore() == g_hitLimit)
            {
                foreach (Card c in hand)
                {
                    c.Show(true);

                    if (c.GetValue() == Card.Value.Ace)
                    {
                         /* Since Ace is valued 11, if the
                         *  remainder of the hand equals
                         *  6, it's a soft 17, hit again.
                         */
                        if (a_dealer.CalcScore() - 11 == 6)
                        {
                            return true;
                        }
                    }
                }

            }

            return a_dealer.CalcScore() < g_hitLimit;
        }
开发者ID:henceee,项目名称:1DV607,代码行数:28,代码来源:soft17Strategy.cs

示例3: DoHit

        public bool DoHit(Player a_dealer)
        {
            int dealerScore = a_dealer.CalcScore();
            IEnumerable<Card> dealerCards = a_dealer.GetHand();

            // If dealers score is below 17, take a card
            if (dealerScore < g_hitLimit)
            {
                return true;
            }

            /**
            ** If dealers score is 17, check for an ace and calculate score without ace
            ** If dealer has an ace and a score of 6 without the ace, subtract 10 from score
            ** to let ace represent 1 score instead of 11, and return result
            */
            else if (dealerScore == g_hitLimit)
            {
                foreach (Card c in dealerCards)
                {
                    if ((c.GetValue() == Card.Value.Ace) && (dealerScore - 11 == 6))
                    {
                        dealerScore -= 10;
                    }
                }

                return dealerScore < g_hitLimit;
            }

            // If dealers score is above 17, don't take a card
            else
            {
                return false;
            }
        }
开发者ID:kk222hk,项目名称:1dv607-kk222hk-Portfolio,代码行数:35,代码来源:Soft17HitStrategy.cs

示例4: DoHit

        public bool DoHit(Player a_dealer)
        {
            int score = 0;
            bool hasAce = false;

            IEnumerable<Card> hand = a_dealer.GetHand();

            //if the dealear has 17...
            if (a_dealer.CalcScore() == g_hitLimit)
            {
                foreach (Card c in hand)
                {
                    c.Show(true);
                    //And one of the cards is an ace (normally valued 11)
                    if (c.GetValue() == Card.Value.Ace)
                    {
                        hasAce = true;
                        break;
                    }
                }

            }
            //if hasAce is true,Ace is now valued 1     -otherwise normal value
            score = (hasAce) ? a_dealer.CalcScore() - 10 : a_dealer.CalcScore();
            return score < g_hitLimit;
        }
开发者ID:henceee,项目名称:blackjack_csharp,代码行数:26,代码来源:soft17Strategy.cs

示例5: DoHit

 public bool DoHit(Player a_dealer)
 {
     if (a_dealer.CalcScore() == g_hitLimit)
     {
         return DealerHasAceInHand(a_dealer.GetHand());
     }
     return a_dealer.CalcScore() < g_hitLimit;
 }
开发者ID:ad222kr,项目名称:1dv607,代码行数:8,代码来源:SoftSeventeenHitStrategy.cs

示例6: DoHit

 public bool DoHit(Player dealer)
 {
     int score = dealer.CalcScore();
     if (score == HitLimit)
     {
         foreach (Card c in dealer.GetHand())
         {
             if (c.GetValue() == Card.Value.Ace)
             {
                 return true;
             }
         }
     }
     return score < HitLimit;
 }
开发者ID:dt222cc,项目名称:1dv607-dt222cc,代码行数:15,代码来源:Soft17HitStrategy.cs

示例7: DoHit

        public bool DoHit(Player a_dealer)
        {
            List<Card> hand = a_dealer.GetHand().ToList();

            bool hasAce = hand.Exists(c => c.GetValue() == Card.Value.Ace);

            if (hasAce && (a_dealer.CalcScore() - 11 == 6))
            {
                return true;
            }
            else
            {
                return a_dealer.CalcScore() < g_hitLimit;
            }
        }
开发者ID:mw222rs,项目名称:blackjack_csharp,代码行数:15,代码来源:Soft17HitStrategy.cs

示例8: DoHit

 public bool DoHit(Player a_dealer)
 {
     //Regel för soft17 för dealer
     int d_score = a_dealer.CalcScore();
     if (d_score == g_hitLimit)
     {
         foreach (Card c in a_dealer.GetHand())
         {
             if (c.GetValue() == Card.Value.Ace && d_score >= g_hitLimit)
             {                        
                 d_score -= 10;
             }
         }
     }
     return d_score <= g_hitLimit;
 }
开发者ID:mc22ft,项目名称:Objektorienterad-analys-och-design-med-UML,代码行数:16,代码来源:DealerHitAceSoft17.cs

示例9: DoHit

        public bool DoHit(Player a_dealer)
        {
            int scoreDealer = a_dealer.CalcScore();

            if (scoreDealer == g_hitLimit)
            {
                foreach (Card c in a_dealer.GetHand())
                {
                    if (c.GetValue() == Card.Value.Ace && (scoreDealer - 11) == 6)
                    {
                        scoreDealer -= 10;
                    }
                }
                return scoreDealer < g_hitLimit;
            }
            else if (scoreDealer < g_hitLimit)
            {
                return true;
            }
            return false;
        }
开发者ID:ml223nw,项目名称:1dv607-workshops,代码行数:21,代码来源:Soft17HitStrategy.cs


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