コード例 #1
0
        /// <summary>
        /// Compute outs to reach the combination.
        /// </summary>
        /// <returns>Outs to reach the combination.</returns>
        protected override int ComputeOuts()
        {
            int result = 0;
            DoublePairsCombination doublePairs = new DoublePairsCombination();

            doublePairs.Compute(SeenCards, true);
            if (doublePairs.Reached)
            {
                // Two pairs
                result = 4;
                List <Card> seenCardsClone = new List <Card>(SeenCards);
                foreach (Card card in doublePairs.CombinationCards)
                {
                    seenCardsClone.Remove(card);
                }
                PairCombination pair = new PairCombination();
                pair.Compute(seenCardsClone);
                if (pair.Reached)
                {
                    // Three pairs
                    result += 2;
                }
            }
            else
            {
                PairCombination pair = new PairCombination();
                pair.Compute(SeenCards, true);
                if (pair.Reached)
                {
                    // Already a pair, missing one card
                    result = 2;
                }
            }
            return(result);
        }
コード例 #2
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 >= 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);
        }
コード例 #3
0
        /// <summary>
        /// Compute outs to reach the combination.
        /// </summary>
        /// <returns>Outs to reach the combination.</returns>
        protected override int ComputeOuts()
        {
            int result = 0;
            TripletsCombination triplets = new TripletsCombination();

            triplets.Compute(SeenCards, true);
            if (triplets.Reached)
            {
                // Already a triples, need a pair
                result = 3 * (SeenCards.Count - 3);
            }
            else
            {
                DoublePairsCombination doublePairs = new DoublePairsCombination();
                doublePairs.Compute(SeenCards, true);
                if (doublePairs.Reached)
                {
                    // Two pairs, need a triplet
                    result = 4;
                }
            }
            return(result);
        }