/// <summary>
        /// Check if the combination is reached.
        /// </summary>
        /// <returns><c>true</c> if combination is reached, <c>false</c> otherwise.</returns>
        protected override bool ComputeReached()
        {
            bool result = false;

            if (SeenCards != null && SeenCards.Count >= 5)
            {
                FlushCombination flush = new FlushCombination();
                flush.Compute(SeenCards, true);
                if (flush.Reached)
                {
                    // A flush is found, check for a straight of the flush family
                    CardFamilies family = flush.CombinationCards[0].Family;
                    // Get all the card of the flush family
                    List <Card> seenCardsClone = new List <Card>();
                    foreach (Card card in SeenCards)
                    {
                        if (card.Family == family)
                        {
                            seenCardsClone.Add(card);
                        }
                    }
                    // Look for a straight in this sub set
                    StraightCombination straight = new StraightCombination();
                    straight.Compute(seenCardsClone, true);
                    if (straight.Reached)
                    {
                        // Straight flush found
                        CombinationCards.AddRange(straight.CombinationCards);
                        result = true;
                    }
                }
            }
            return(result);
        }
        /// <summary>
        /// Check if the combination is reached.
        /// </summary>
        /// <returns><c>true</c> if combination is reached, <c>false</c> otherwise.</returns>
        protected override bool ComputeReached()
        {
            bool result = false;

            if (SeenCards != null && SeenCards.Count >= 4)
            {
                List <Card>     seenCardsClone = new List <Card>(SeenCards);
                PairCombination pair1          = new PairCombination();
                pair1.Compute(seenCardsClone, true);
                if (pair1.Reached)
                {
                    // First pair found, look for a pair in remaining cards
                    // Remove first pair cards
                    foreach (Card card in pair1.CombinationCards)
                    {
                        CombinationCards.Add(card);
                        seenCardsClone.Remove(card);
                    }
                    PairCombination pair2 = new PairCombination();
                    pair2.Compute(seenCardsClone, true);
                    if (pair2.Reached)
                    {
                        // Two pairs reached
                        CombinationCards.AddRange(pair2.CombinationCards);
                        result = true;
                    }
                }
            }
            return(result);
        }
        /// <summary>
        /// Check if the combination is reached.
        /// </summary>
        /// <returns><c>true</c> if combination is reached, <c>false</c> otherwise.</returns>
        protected override bool ComputeReached()
        {
            bool result = false;

            if (SeenCards != null && SeenCards.Count >= 5)
            {
                List <Card>         seenCardsClone = new List <Card>(SeenCards);
                TripletsCombination triplet        = new TripletsCombination();
                triplet.Compute(seenCardsClone, true);
                if (triplet.Reached)
                {
                    // Triplet found, look for a pair in remaining cards
                    // Remove triplet cards
                    foreach (Card card in triplet.CombinationCards)
                    {
                        CombinationCards.Add(card);
                        seenCardsClone.Remove(card);
                    }
                    PairCombination pair = new PairCombination();
                    pair.Compute(seenCardsClone, true);
                    if (pair.Reached)
                    {
                        // Full reached
                        CombinationCards.AddRange(pair.CombinationCards);
                        result = true;
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Check if the combination is reached.
        /// </summary>
        /// <returns><c>true</c> if combination is reached, <c>false</c> otherwise.</returns>
        protected override bool ComputeReached()
        {
            bool result = false;

            if (SeenCards != null && SeenCards.Count >= 5)
            {
                StraightFlushCombination straightFlush = new StraightFlushCombination();
                straightFlush.Compute(SeenCards, true);
                if (straightFlush.Reached)
                {
                    bool aceFound  = false;
                    bool kingFound = false;
                    // Straight flush reached, look for an ace and a king
                    foreach (Card card in straightFlush.CombinationCards)
                    {
                        if (card.Weight == 0)
                        {
                            aceFound = true;
                        }
                        else if (card.Weight == CardSet.CardsPerFamilyCount - 1)
                        {
                            kingFound = true;
                        }
                        if (aceFound && kingFound)
                        {
                            // Royal flush reached
                            CombinationCards.AddRange(straightFlush.CombinationCards);
                            result = true;
                        }
                    }
                }
            }
            return(result);
        }
        /// <summary>
        /// Check if the combination is reached.
        /// </summary>
        /// <returns><c>true</c> if combination is reached, <c>false</c> otherwise.</returns>
        protected override bool ComputeReached()
        {
            bool result = false;

            if (SeenCards != null && SeenCards.Count >= 4)
            {
                List <Card>            seenCardsClone = new List <Card>(SeenCards);
                DoublePairsCombination doublePairs    = new DoublePairsCombination();
                doublePairs.Compute(seenCardsClone, true);
                if (doublePairs.Reached)
                {
                    // Double pair found, check if it is a quads
                    if (doublePairs.CombinationCards[0].Weight == doublePairs.CombinationCards[2].Weight)
                    {
                        // Quads reached
                        CombinationCards.AddRange(doublePairs.CombinationCards);
                        result = true;
                    }
                    else
                    {
                        // Look for a possible third pair
                        foreach (Card card in doublePairs.CombinationCards)
                        {
                            seenCardsClone.Remove(card);
                        }
                        PairCombination pair = new PairCombination();
                        pair.Compute(seenCardsClone, true);
                        if (pair.Reached)
                        {
                            if (pair.CombinationCards[0].Weight == doublePairs.CombinationCards[0].Weight)
                            {
                                // Quads reached
                                CombinationCards.Add(doublePairs.CombinationCards[0]);
                                CombinationCards.Add(doublePairs.CombinationCards[1]);
                                CombinationCards.AddRange(pair.CombinationCards);
                                result = true;
                            }
                            else if (pair.CombinationCards[0].Weight == doublePairs.CombinationCards[2].Weight)
                            {
                                // Quads reached
                                CombinationCards.Add(doublePairs.CombinationCards[2]);
                                CombinationCards.Add(doublePairs.CombinationCards[3]);
                                CombinationCards.AddRange(pair.CombinationCards);
                                result = true;
                            }
                        }
                    }
                }
            }
            return(result);
        }