Exemplo n.º 1
0
 public void Stay()
 {
     if (State == GameState.Lost)
     {
         return;
     }
     while (DealersHand.Points().points < 17)
     {
         Card topCard = Deck.Draw();
         DealersHand.AddCard(topCard);
     }
     if (DealersHand.Points().points > 21)
     {
         State = GameState.Won;
     }
     else if (DealersHand.Points().points < PlayersHand.Points().points)
     {
         State = GameState.Won;
     }
     else
     {
         State = GameState.Lost;
     }
 }
Exemplo n.º 2
0
        public int DealersPlay(Deck gameDeck)
        {
            DealersHand.Add(gameDeck.GiveCard());

            Sum += (int)DealersHand[DealersHand.Count - 1];

            if (Sum == 21)
            {
                IsBlackjack = true;
            }

            while (Sum <= 17)
            {
                DealersHand.Add(gameDeck.GiveCard());

                Sum += (int)DealersHand[(DealersHand.Count - 1)];
                if (Sum > 21 && (DealersHand.IndexOf(CardsValue.Ace) >= 0))
                {
                    DealersHand[DealersHand.IndexOf(CardsValue.Ace)] = DealersHand[DealersHand.IndexOf(CardsValue.Ace)] - 10;
                    Sum -= 10;
                }
            }
            return(Sum);
        }