private void DrawBestCard(Deck deck, Card availableCard, bool cheat = false)
        {
            var bestSuit = CalculateBestSuit();

            if (availableCard.suit == bestSuit)
            {
                AddCard(availableCard);
            }
            else if (cheat == false)
            {
                DrawCard(deck);
            }
            else
            {
                AddCard(deck.SelectCardOfSpecificSuit(bestSuit));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Draws a card from the deck based on what is best for the player's current hand.
        /// </summary>
        /// <param name="deck">A reference to the deck in use for the game.</param>
        /// <param name="availableCard">A reference to the card available on the discard pile.</param>
        /// <param name="cheat">Indicates whether the computer player is cheating.</param>
        private void DrawBestCard(Deck deck, Card availableCard, bool cheat = false)
        {
            var bestSuit = CalculateBestSuit();

            if (availableCard.suit == bestSuit)
            {
                // The card on the discard pile belongs to the most desireable suit for the
                // current hand, so take it.
                AddCard(availableCard);
            }
            else if (cheat == false)
            {
                // The card on the discard pile isn't very useful, so draw the next available
                // card from the deck.
                DrawCard(deck);
            }
            else
            {
                // The computer is cheating, so attempt to draw a card of the desired suit.
                AddCard(deck.SelectCardOfSpecificSuit(bestSuit));
            }
        }