Пример #1
0
        public bool DoHit(model.Player a_dealer)
        {
            int[] cardScores = new int[(int)model.Card.Value.Count] {
                2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11
            };
            int score = 0;

            foreach (Card c in a_dealer.GetHand())
            {
                if (c.GetValue() != Card.Value.Hidden)
                {
                    score += cardScores[(int)c.GetValue()];
                }
            }

            if (score == 17 || score > 21)
            {
                foreach (Card c in a_dealer.GetHand())
                {
                    if (c.GetValue() == Card.Value.Ace && (score == 17 || score > 21))
                    {
                        score -= 10;
                    }
                }
            }
            return(score <= 17);
        }
Пример #2
0
        public bool DoHit(model.Player a_dealer)
        {
            // Om äss, och summan av handen är 17
            bool isSoft17 = a_dealer.CalcScore() == 17 && a_dealer.GetHand().Any(card => card.GetValue() == Card.Value.Ace);

            return(isSoft17 || a_dealer.CalcScore() < 17);
        }
Пример #3
0
        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);
        }
Пример #4
0
 public void RedrawAndShowHand(model.Dealer a_dealer, model.Player a_player)
 {
     System.Threading.Thread.Sleep(2000);
     DisplayWelcomeMessage();
     DisplayDealerHand(a_dealer.GetHand(), a_dealer.CalcScore());
     DisplayPlayerHand(a_player.GetHand(), a_player.CalcScore());
 }
Пример #5
0
        public bool DoHit(model.Player a_dealer)
        {
            int dealerScoreAceLowered    = a_dealer.CalcScore();
            int dealerScoreAceNotLowered = 0;

            int[] cardScores = new int[(int)model.Card.Value.Count]
            {
                2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11
            };

            foreach (Card c in a_dealer.GetHand())
            {
                if (c.GetValue() != Card.Value.Hidden)
                {
                    dealerScoreAceNotLowered += cardScores[(int)c.GetValue()];
                }

                if (dealerScoreAceNotLowered == 17 && c.GetValue() == Card.Value.Ace)
                {
                    return(dealerScoreAceNotLowered < g_softHitLimit);
                }
            }

            return(dealerScoreAceLowered < g_hardHitLimit);
        }
 public bool DoHit(model.Player a_dealer)
 {
     foreach (Card c in a_dealer.GetHand())
     {
         if (c.GetValue() == Card.Value.Ace && a_dealer.CalcScore() == g_hitLimit)
         {
             return(true);
         }
     }
     return(a_dealer.CalcScore() < g_hitLimit);
 }
        private bool HasAnAce(model.Player a_dealer)
        {
            foreach (Card card in a_dealer.GetHand())
            {
                if (card.GetValue() == Card.Value.Ace)
                {
                    return(true);
                }
            }

            return(false);
        }
 public bool DoHit(model.Player a_dealer)
 {
     if (a_dealer.CalcScore() < g_hitLimit)
     {
         return(true);
     }
     if (a_dealer.CalcScore() == g_hitLimit)
     {
         return(a_dealer.GetHand().Any(c => c.GetValue() == Card.Value.Ace));
     }
     return(false);
 }
Пример #9
0
        public bool DoHit(model.Player a_dealer)
        {
            foreach (Card c in a_dealer.GetHand())
            {
                if (c.GetValue().ToString() == "Ace")
                {
                    g_hitLimit = 18;
                }
            }

            return(a_dealer.CalcScore() < g_hitLimit);
        }
Пример #10
0
 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);
 }
Пример #11
0
        public bool DoHit(model.Player a_dealer)
        {
            IEnumerable <Card> cards = a_dealer.GetHand();

            foreach (Card card in cards)
            {
                if (card.GetValue() == Card.Value.Ace && a_dealer.CalcScore() == g_hitLimit)
                {
                    return(true);
                }
            }
            return(a_dealer.CalcScore() < g_hitLimit);
        }
Пример #12
0
        public bool DoHit(model.Player a_dealer)
        {
            List <Card> list = (List <Card>)a_dealer.GetHand();

            if (a_dealer.CalcScore() == g_hitLimit)
            {
                return(list.Exists(x => x.GetValue() == Card.Value.Ace));
            }
            else
            {
                return(a_dealer.CalcScore() < g_hitLimit);
            }
        }
Пример #13
0
        public bool DoHit(model.Player a_dealer)
        {
            int hitLimit = 17;

            foreach (Card c in a_dealer.GetHand())
            {
                if (c.GetValue() == Card.Value.Ace)
                {
                    hitLimit = 18;
                }
            }

            return(a_dealer.CalcScore() < hitLimit);
        }
Пример #14
0
        private bool isSoftHand(model.Player a_dealer)
        {
            bool isASoftHand = false;
            IEnumerable <BlackJack.model.Card> cards = a_dealer.GetHand();

            foreach (Card card in cards)
            {
                if (card.GetValue() == Card.Value.Ace)
                {
                    return(true);
                }
            }

            return(isASoftHand);
        }
        public bool DoHit(model.Player a_dealer)
        {
            if (a_dealer.CalcScore() == 17)
            {
                foreach (Card c in a_dealer.GetHand())
                {
                    if (c.GetValue() == Card.Value.Ace)
                    {
                        return(true);
                    }
                }
            }

            return(base.DoHit(a_dealer));
        }
Пример #16
0
        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 -= 10;
                    }
                }
            }
            return(score <= g_hitLimit);
        }
Пример #17
0
        public bool DoHit(model.Player a_dealer)
        {
            IEnumerable <Card> hand = a_dealer.GetHand();

            if (a_dealer.CalcScore() == 17)
            {
                foreach (var card in hand)
                {
                    if (card.GetValue() == Card.Value.Ace)
                    {
                        return(true);
                    }
                }
            }
            return(a_dealer.CalcScore() < g_hitLimit);
        }
Пример #18
0
        //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);
        }
Пример #19
0
        // return true if score is 17 and dealer has an Ace,
        // else return true/false depending on if dealer has
        // a score lower than the hit limit.
        public bool DoHit(model.Player a_dealer)
        {
            IEnumerable <Card> cards = a_dealer.GetHand();

            if (a_dealer.CalcScore() == g_hitLimit)
            {
                foreach (var c in cards)
                {
                    if (c.GetValue() == Card.Value.Ace)
                    {
                        return(false);
                    }
                }
            }

            return(a_dealer.CalcScore() < g_hitLimit);
        }
Пример #20
0
        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);
        }
Пример #21
0
        public bool DoHit(model.Player a_dealer)
        {
            int aces = 0;

            foreach (Card c in a_dealer.GetHand())
            {
                if (c.GetValue() == Card.Value.Ace && a_dealer.CalcScore() == g_hitLimit)
                {
                    aces++;
                }
            }
            if (aces == 1)
            {
                return(true);
            }
            else
            {
                return(a_dealer.CalcScore() < g_hitLimit);
            }
        }
Пример #22
0
 public bool DoHit(model.Player a_dealer)
 {
     if (a_dealer.CalcScore() == g_hitLimit)
     {
         var hand = a_dealer.GetHand();
         foreach (var card in hand)
         {
             if (card.GetValue() == Card.Value.Ace)
             {
                 var remainder = a_dealer.CalcScore() - valueOfAce;
                 return(IsEqualToTarget(remainder));
             }
         }
         return(false);
     }
     else
     {
         return(a_dealer.CalcScore() < g_hitLimit);
     }
 }
Пример #23
0
 public bool DoHit(model.Player a_dealer)
 {
     var cards = a_dealer.GetHand();
     var score = a_dealer.CalcScore();
     if (score < g_hitLimit)
     {
         return true;
     }
     else if (score == g_hitLimit)
     {
         foreach (var card in cards)
         {
             if (card.GetValue() == Card.Value.Ace && score - 11 == 6)
             {
                 score -= 10;
             }
             return score < g_hitLimit;
         }
     }            
     return false;            
 }
Пример #24
0
        public bool DoHit(model.Player a_dealer)
        {
            if (a_dealer.CalcScore() == g_hitLimit)
            {
                List <Card> handOfCards  = (List <Card>)a_dealer.GetHand();
                bool        dealerHasAce = false;

                handOfCards.ForEach(card => {
                    if (card.GetValue() == Card.Value.Ace)
                    {
                        dealerHasAce = true;
                    }
                });

                if (dealerHasAce)
                {
                    return(true);
                }
            }
            return(a_dealer.CalcScore() < g_hitLimit);
        }
        public bool DoHit(model.Player a_dealer)
        {
            if (a_dealer.CalcScore() > g_hitLimit)
            {
                int score = a_dealer.CalcScore();

                foreach (var card in a_dealer.GetHand())
                {
                    if (card.GetValue() == Card.Value.Ace)
                    {
                        score = score - 13;

                        if (score < g_hitLimit)
                        {
                            break;
                        }
                    }
                }
            }

            return(a_dealer.CalcScore() < g_hitLimit);
        }
Пример #26
0
        public bool DoHit(model.Player a_dealer)
        {
            int score = a_dealer.CalcBasicScore();
            IEnumerable <Card> hand = a_dealer.GetHand();

            if (score == g_hitLimit)
            {
                foreach (Card card in hand)
                {
                    if (card.GetValue() == Card.Value.Ace)
                    {
                        score -= 10;
                    }
                }
            }

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

            return(score < g_hitLimit);
        }
Пример #27
0
        public bool ValidateSoft17()
        {
            int[] cardScores = new int[(int)model.Card.Value.Count] {
                2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11
            };
            int score = 0;

            int acesAmount = 0;

            foreach (Card c in this.a_dealer.GetHand())
            {
                if (c.GetValue() == Card.Value.Ace)
                {
                    acesAmount++;
                }

                if (c.GetValue() != Card.Value.Hidden)
                {
                    score += cardScores[(int)c.GetValue()];
                }
            }

            if (score > 21 || score == g_hitLimit)
            {
                foreach (Card c in a_dealer.GetHand())
                {
                    if (c.GetValue() == Card.Value.Ace && acesAmount > 0)
                    {
                        score -= 10;
                        acesAmount--;
                    }
                }
            }

            return(score < g_hitLimit);
        }
Пример #28
0
 public IEnumerable <Card> GetPlayerHand()
 {
     return(m_player.GetHand());
 }