Example #1
0
        /* Take another card or stay on the current value.  This is also
         * called if the player refuses a double down to ensure that the
         * main game loop can advance properly */
        protected bool HitOrStay(CardList hand, int handIndex)
        {
            Console.WriteLine("(H)it or (S)tay on hand " + (handIndex + 1).ToString() + "?");
            char userInput = Console.ReadKey(true).KeyChar.ToString().ToUpper()[0]; //Stores the next key pressed as an uppercase char

            switch (userInput)
            {
            case 'H':
                Console.WriteLine("Hit!");
                hand.AddCard(Deck.DealCard());     //Adds a new card to the current hand
                if (CheckHandScore(hand) >= 21)
                {
                    frozenHands[handIndex] = true;
                }
                return(true);

            case 'S':
                Console.WriteLine("Stay.");
                frozenHands[handIndex] = true;     //Makes sure the hand will be skipped on future iterations
                return(true);

            default:
                break;
            }
            return(false);
        }
Example #2
0
 /* Shuffles the deck and deals the initial 4 cards, 2 to the dealer and 2 to the
  * human player.*/
 public void DealHands()
 {
     Console.WriteLine("Shuffling deck...");
     Deck.ShuffleDeck();
     CasinoDoor.WaitForDisplay();
     Console.WriteLine("Dealing hands...");
     for (int startingCards = 0; startingCards < 2; startingCards++)
     {
         if (playerHands.Count == 0)
         {
             playerHands.Add(new CardList());
             frozenHands.Add(false);
         }
         playerHands[0].AddCard(Deck.DealCard());
         dealerHand.AddCard(Deck.DealCard());
     }
 }