Exemplo n.º 1
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;
 }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
        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;
        }
        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;
        }
Exemplo n.º 5
0
        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;
            }
        }
        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;
        }
Exemplo n.º 7
0
        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;
            }
        }
Exemplo n.º 8
0
 public bool DoHit(model.Player a_dealer)
 {
     if (a_dealer.CalcScore() == g_hitLimit)
     {
         return DealerHasAce(a_dealer.GetHand());
     }
     return a_dealer.CalcScore() < g_hitLimit;
 }
Exemplo n.º 9
0
 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;
 }
        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));
        }
Exemplo n.º 11
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;
        }
Exemplo n.º 12
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 - 11) == 6){
                        score -= 10;
                    }
                }
                return score < g_hitLimit;
            }
            else if(score < g_hitLimit){
                return true;
            }
            return false;
        }
Exemplo n.º 13
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;
        }
Exemplo n.º 14
0
        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;
        }
Exemplo n.º 15
0
        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;
        }
Exemplo n.º 16
0
        public bool DoHit(model.Player a_dealer)
        {
            IEnumerable<Card> cardList = a_dealer.GetHand();
            if (a_dealer.CalcScore() < g_hitLimit)
            {
                return true;
            }

            if (a_dealer.CalcScore() == g_hitLimit)
            {
                foreach (Card card in cardList)
                {
                    if (card.GetValue() == Card.Value.Ace)
                    {
                        return true;
                    }
                }
            }
            return false;
        }
Exemplo n.º 17
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;
 }
Exemplo n.º 18
0
        public bool DoHit(model.Player a_dealer)
        {
            var hand = a_dealer.GetHand();
            int score = a_dealer.CalcScore();

            // If the dealer has 17.
            if (score == g_hitLimit)
            {
                foreach (var card in hand)
                {
                    // In a comibination of Ace and 6.
                    if (card.GetValue() == Card.Value.Ace && score - 11 == 6)
                    {
                        // The dealer does another hit.
                        return true;
                    }
                }
            }

            return score < g_hitLimit;
        }
Exemplo n.º 19
0
 public bool DoHit(model.Player a_dealer)
 {
     if (a_dealer.CalcScore() == g_hitLimit && aceHit == false)
     {
         foreach (Card c in a_dealer.GetHand())
         {
             if (c.GetValue() == Card.Value.Ace && a_dealer.CalcScore() == g_hitLimit)
             {
                 aceHit = true;
                 return true;
             }
         }
     }
     if (a_dealer.CalcScore() < g_hitLimit)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
        public bool DoHit(model.Player a_dealer)
        {
            int score = 0;

            if (a_dealer.CalcScore() == 17)
            {
                foreach (Card c in a_dealer.GetHand())
                {
                    score += (int)c.GetValue();

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

                if(score == 6){
                    return true;
                }
            }

            return a_dealer.CalcScore() < g_hitLimit;
        }
Exemplo n.º 21
0
        /*Detta är vår tolkning på problembeskrvningen utav soft17
         * (Ändring kan ske vid kontakt med "kunden"). */
        public bool DoHit(model.Player a_dealer)
        {
            int score = a_dealer.CalcScore();

            if (score == 17)
            {
                foreach (Card c in a_dealer.GetHand())
                {
                    if (!once)
                    {
                        if (c.GetValue() == Card.Value.Ace)
                        {

                            score -= 10;
                            once = true;

                        }
                    }
                }
            }

            return score < g_hitLimit;
        }
Exemplo n.º 22
0
 public bool DoHit(model.Player a_dealer)
 {
     return (a_dealer.GetHand().Any(w => w.GetValue() == Card.Value.Ace) && a_dealer.CalcScore() == g_hitLimit) || a_dealer.CalcScore() < g_hitLimit;
 }