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


C# model.GetHand方法代码示例

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


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

示例1: DoHit

 public bool DoHit(model.Player a_dealer)
 {
     if(a_dealer.CalcScore() < g_hitLimit)
     {
         return true;
     }
         //checks to see if the amount of ace is atleast of half the dealers cards to make sure the dealer doesnt hit at a hard 17. Example ace + 6 + 10
     else if (a_dealer.GetHand().Count(x => x.GetValue() == Card.Value.Ace)*2 >= a_dealer.GetHand().Count() && a_dealer.CalcScore() <= g_hitLimit)
     {
         return true;
     }
     return false;
 }
开发者ID:ss223ck,项目名称:OO_Worksshop_3,代码行数:13,代码来源:AceHitStrategy.cs

示例2: DoHit

        public bool DoHit(model.Player a_dealer)
        {
            if (a_dealer.CalcScore() == g_hitLimit)
            {
                int otherValue = 0;
                bool aceFound = false;
                int[] cardScores = new int[(int)model.Card.Value.Count] { 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11 };

                foreach (Card card in a_dealer.GetHand())
                {
                    if (card.GetValue() == Card.Value.Ace && !aceFound)
                    {
                        aceFound = true;
                    } else {
                        otherValue += cardScores[(int)card.GetValue()];
                        if (otherValue > 6)
                        {
                            return false;
                        }
                    }
                }
                if (otherValue == 6 && aceFound)
                {
                    return true;
                }
            }
            return a_dealer.CalcScore() < g_hitLimit;
        }
开发者ID:dv222bk,项目名称:blackjack_csharp,代码行数:28,代码来源:Soft17HitStrategy.cs

示例3: DoHit

        public bool DoHit(model.Player a_dealer)
        {
            int[] cardScores = a_dealer.getCardScoreArray();
            total = 0;

            if (a_dealer.CalcScore() < 17)
            {
                return true;
            }

            if (a_dealer.CalcScore() == 17){

                foreach (Card c in a_dealer.GetHand())
                {
                    if (c.GetValue() != Card.Value.Ace)
                    {
                        total += cardScores[(int)c.GetValue()];
                    }
                }
                //if this is true a soft 17 is active.
                if (total <= 6)
                {
                    return true;
                }
            }

            return false;
        }
开发者ID:MartinArvidsson,项目名称:UML,代码行数:28,代码来源:Soft17RuleStratergy.cs

示例4: DoHit

        public bool DoHit(model.Player a_dealer)
        {
            int[] cardScores = new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11 };
            var score = 0;
            var cards = a_dealer.GetHand();
            var numberOfAces = 0;
            foreach (var c in cards)
            {
                
                if (c.GetValue() != Card.Value.Hidden)
                {
                    score += cardScores[(int)c.GetValue()];

                    if (c.GetValue() == Card.Value.Ace)
                    {
                        numberOfAces++;
                    }
                }
            }

            while ((score == g_hitLimit || score > 21) && numberOfAces > 0)
            {
                numberOfAces--;
                score -= 10;
            }

            return score < g_hitLimit;
        }
开发者ID:kristofferlind,项目名称:1dv407-ooad,代码行数:28,代码来源:Soft17HitStrategy.cs

示例5: DoHit

        public bool DoHit(model.Player a_dealer)
        {
            var cards = a_dealer.GetHand();

            // Check if limit has reached....
            if (a_dealer.CalcScore() == g_hitLimit)
            {
                foreach (var card in cards)
                {
                    // Must hit if ace in hand. Because score IS 17!
                    //Ace turns into 1 score instead
                    if (card.GetValue() == Card.Value.Ace)
                    {
                        return true;
                    }
                }
            }

            // No special circumstances....
            if (a_dealer.CalcScore() < g_hitLimit)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
开发者ID:AndreasAnemyrLNU,项目名称:1dv607,代码行数:28,代码来源:Soft17Strategy.cs

示例6: DoHit

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

            if (score < g_hitLimit)
            {
                return true;
            }

            if (score == g_hitLimit)
            {
                foreach (Card c in a_dealer.GetHand())
                {
                    //If Ace is in the hand, checks if score without Ace is 6
                    if ((c.GetValue() == Card.Value.Ace) && (score - 11 == 6))
                    {
                        score -= 10;
                    }
                }

                return score < g_hitLimit;
            }

            return false;
        }
开发者ID:jb223cp,项目名称:1dv607Workshop3,代码行数:25,代码来源:SoftSeventeenGameRule.cs

示例7: DoHit

        public bool DoHit(model.Player a_dealer)
        {
            if(a_dealer.CalcScore() == g_hitLimit)
            {
                IEnumerable<Card> aces = a_dealer.GetHand().Where(c => c.GetValue() == Card.Value.Ace);                //get all aces from hand
                IEnumerable<Card> handWithoutAces = a_dealer.GetHand().Where(c => c.GetValue() != Card.Value.Ace);     //get all other cards from hand

                int score = a_dealer.CalcCardsScore(handWithoutAces);          //calc score of hand without aces

                return aces.Count() > 0 && score == 6;                        //return if there is aces and score of other cards is 6
            }

            else
            {
                return a_dealer.CalcScore() < g_hitLimit;
            }
        }
开发者ID:fh222dt,项目名称:OOAD,代码行数:17,代码来源:Soft17HitStrategy.cs

示例8: DoHit

 public bool DoHit(model.Player a_dealer)
 {
     if (a_dealer.CalcScore() == g_hitLimit)
     {
         return DealerHasAce(a_dealer.GetHand());
     }
     return a_dealer.CalcScore() < g_hitLimit;
 }
开发者ID:mj223dg,项目名称:BlackJack,代码行数:8,代码来源:Soft17Strategy.cs

示例9: DoHit

 public bool DoHit(model.Player a_dealer)
 {
     int a = a_dealer.CalcScore();
     if (a == 17)
     {
         foreach (Card c in a_dealer.GetHand())
         {
             if (c.GetValue() == Card.Value.Ace)
             {
                 return true;
             }
         }
     }
     return a_dealer.CalcScore() < g_hitLimit;
 }
开发者ID:henceee,项目名称:1DV607,代码行数:15,代码来源:BasicHitStrategy.cs

示例10: DoHit

        public bool DoHit(model.Player a_dealer)
        {
            bool hasAce = false;
            foreach (Card c in a_dealer.GetHand())
            {
                if (c.GetValue() == Card.Value.Ace)
                {
                    hasAce = true;
                    break;
                }
            }

            int score = a_dealer.CalcScore();
            return (score < g_hitLimit ||
                    (score == g_hitLimit && hasAce));
        }
开发者ID:of222au,项目名称:1DV607-Objektorienterad-analys-och-design-med-UML,代码行数:16,代码来源:Soft17HitStrategy.cs

示例11: DoHit

        public bool DoHit(model.Player a_dealer)
        {
            int score = a_dealer.CalcScore(false);  // parameter false means don't calcScore using Ace as 1 but only 11
            if (score == g_hitLimit)
            {
                foreach (Card c in a_dealer.GetHand())
                {
                    if (c.GetValue() == Card.Value.Ace)
                    {
                        return true;
                    }
                }
            }

            return a_dealer.CalcScore() < g_hitLimit;
        }
开发者ID:ej222ru,项目名称:1DV607_WS3,代码行数:16,代码来源:Soft17HitStrategy.cs

示例12: DoHit

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

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

示例13: DoHit

        //Hit if score is 17 or less
        public bool DoHit(model.Player a_dealer)
        {
            var cards = a_dealer.GetHand();

            if(a_dealer.CalcScore() == g_hitLimit)
            {
                foreach(Card card in cards)
                {
                    if (card.GetValue() == Card.Value.Ace && a_dealer.CalcScore() - 11 == 6)
                    {
                        return true;
                    }
                }
            }

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

示例14: DoHit

        public bool DoHit(model.Player a_dealer)
        {
            int[] cardScore = a_dealer.getCardArrayValues();
            int total = 0;

            if (a_dealer.CalcScore() == g_hitLimit)
            {
                foreach (Card card in a_dealer.GetHand())
                {
                    if (card.GetValue() != Card.Value.Ace)
                    {
                      total += cardScore[(int)card.GetValue()];
                    }
                }
                return total <= 6;
            }

            return a_dealer.CalcScore() < g_hitLimit;
        }
开发者ID:jt222ic,项目名称:Blackjack_jt22ic,代码行数:19,代码来源:Soft17.cs

示例15: PlayGame

        public bool PlayGame(view.Console a_view, model.Dealer a_dealer, model.Player a_player)
        {
            a_view.PresentInstructions();
            a_view.DisplayHands(a_dealer.GetHand(), a_player.GetHand());
            view.Console.Event e;

            e = a_view.GetEvent();
            if (e == view.Console.Event.Quit)
            {
                return false;
            }
            if (e == view.Console.Event.Start)
            {
                a_dealer.StartNewRound(a_player);

            }

            return true;
        }
开发者ID:henceee,项目名称:1dv607_2015,代码行数:19,代码来源:Player.cs


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