Ejemplo n.º 1
0
        /// <summary>
        /// Deals cards to both hands
        /// </sumary>
        public void Deal()
        {
            // player gave up current game
            if (inPlay)
            {
                score--;
            }

            // return cards from hands to the deck
            while (dealerHand.NumberOfCards > 0)
            {
                Card card = dealerHand.Remove();
                deck.ReturnCard(card);
            }
            while (playerHand.NumberOfCards > 0)
            {
                Card card = playerHand.Remove();
                deck.ReturnCard(card);
            }

            // Prepares the deck for the game and deals two cards to each player
            deck.Shuffle();
            int cutNumber = rand.Next(1, 50);

            deck.Cut(cutNumber);
            playerHand.AddCard(deck.TakeTopCard());
            dealerHand.AddCard(deck.TakeTopCard());
            playerHand.AddCard(deck.TakeTopCard());
            dealerHand.AddCard(deck.TakeTopCard());
            inPlay  = true;
            outcome = "Game is in progress...";
            status  = "Hit or stand?";
        }