예제 #1
0
        /// <summary>
        /// Draws a card then adds the value of the card.
        /// </summary>
        /// <param name="deck"></param>
        /// <returns>A PlayingCard object</returns>
        public PlayingCard Hit()
        {
            if (IsBust)
            {
                return(null);
            }

            PlayingCard card = deck.DrawFirstCard();

            CalcValueOfHand(card);
            CalcIfBust();
            return(card);
        }
예제 #2
0
        /// <summary>
        /// Calculates the value of a certain card and adds that number.
        /// </summary>
        /// <param name="card"></param>
        /// <returns>The value of the card</returns>
        private int CalcValueOfHand(PlayingCard playingCard)
        {
            cardsInHand.Add(playingCard);

            if (CalcIfHandBust(playingCard.value))
            {
                PlayingCard card = cardsInHand.Find(c => c.value == 11);
                if (card != null)
                {
                    card.value = 1;
                }
            }

            return(Value = cardsInHand.Sum(c => c.value));
        }