/// <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 >= 2)
            {
                foreach (Card card1 in SeenCards)
                {
                    foreach (Card card2 in SeenCards)
                    {
                        if (!card1.Equals(card2))
                        {
                            if (card1.Weight == card2.Weight)
                            {
                                // Pair reached
                                CombinationCards.Add(card1);
                                CombinationCards.Add(card2);
                                result = true;
                                break;
                            }
                        }
                    }
                    if (result)
                    {
                        break;
                    }
                }
            }
            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);
        }
示例#3
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)
            {
                // List cards by families
                Dictionary <CardFamilies, List <Card> > cards = new Dictionary <CardFamilies, List <Card> >();
                foreach (Card card in SeenCards)
                {
                    if (!cards.ContainsKey(card.Family))
                    {
                        // First card of this family
                        cards.Add(card.Family, new List <Card>());
                    }
                    cards[card.Family].Add(card);
                }
                // Look for 5 or more cards of the same family
                foreach (CardFamilies cardFamily in cards.Keys)
                {
                    if (cards[cardFamily].Count >= 5)
                    {
                        // Flush reached
                        for (int i = 0; i < 5; i++)
                        {
                            // Get the 5 greater for the flush
                            CombinationCards.Add(cards[cardFamily][cards[cardFamily].Count - 1 - i]);
                        }
                        result = true;
                        break;
                    }
                }
            }
            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);
        }
示例#5
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)
            {
                SortedList <byte, Card> sortedCards = new SortedList <byte, Card>();
                foreach (Card card in SeenCards)
                {
                    // Get the list of ordered weights
                    if (!sortedCards.ContainsKey(card.Weight))
                    {
                        sortedCards.Add(card.Weight, card);
                        if (card.Weight == 0)
                        {
                            // If card is an ace, consider it as the minimum and max weight
                            sortedCards.Add(CardSet.CardsPerFamilyCount, card);
                        }
                    }
                }
                if (sortedCards.Count >= 5)
                {
                    // Look for 5 following weights
                    int  followingWeight = 1;
                    byte previousWeight  = sortedCards.Keys[0];
                    for (int i = sortedCards.Keys.Count - 1; i >= 0; i--)
                    {
                        if (sortedCards.Keys[i] == previousWeight - 1)
                        {
                            followingWeight++;
                            if (followingWeight >= 5)
                            {
                                // Straight reached
                                for (int j = 0; j < 5; j++)
                                {
                                    // Get the 5 better weight
                                    CombinationCards.Add(sortedCards.Values[(byte)(i + j)]);
                                }
                                result = true;
                                break;
                            }
                        }
                        else
                        {
                            followingWeight = 1;
                        }
                        previousWeight = sortedCards.Keys[i];
                    }
                }
            }
            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);
        }