Esempio n. 1
0
            /// <summary>
            ///     <para>Initializes an instance of the <see cref="TwoOfAKindHand"/> class.</para>
            /// </summary>
            /// <param name="pair">
            ///		The pair of the hands (two of a kind).
            /// </param>
            /// <param name="highCards">
            ///		The rest of the cards in the hand.
            /// </param>
            /// <param name="family">
            ///		The creating hand family
            /// </param>
            public TwoOfAKindHand(List <Card> pair, IEnumerable <Card> highCards, TwoOfAKindFamily family)
                : base(family)
            {
                this.cards.AddRange(pair);

                cards.AddRange(highCards);
            }
Esempio n. 2
0
            /// <summary>
            ///     <para>Initializes an instance of the <see cref="FullHouseHand"/> class.</para>
            /// </summary>
            /// <param name="threesome">
            ///		The Three of a kind in the full house.
            /// </param>
            /// <param name="pair">
            ///		The Pair in the full house.
            /// </param>
            /// <param name="family">
            ///		The creating hand family.
            /// </param>
            public FullHouseHand(Hand threesome, Hand pair, FullHouseFamily family)
                : base(family)
            {
                cards.AddRange(ThreeOfAKindFamily.GetThreesom(threesome));
                KeyValuePair <Card, Card> pairCards = TwoOfAKindFamily.GetPair(pair);

                cards.Add(pairCards.Key);
                cards.Add(pairCards.Value);
            }
Esempio n. 3
0
            /// <summary>
            ///     <para>Initializes an instance of the <see cref="TwoPairHand"/> class.</para>
            /// </summary>
            /// <param name="firstHand">
            ///		The first pair in the hand.
            /// </param>
            /// <param name="secondHand">
            ///		The second pair in the hand.
            /// </param>
            /// <param name="highCard">
            ///		The remaining high card.
            /// </param>
            /// <param name="family">
            ///		The creating hand family.
            /// </param>
            public TwoPairHand(Hand firstHand, Hand secondHand, Card highCard, TwoPairFamily family)
                : base(family)
            {
                KeyValuePair <Card, Card> firstPair  = TwoOfAKindFamily.GetPair(firstHand);
                KeyValuePair <Card, Card> secondPair = TwoOfAKindFamily.GetPair(secondHand);

                if (firstPair.Key < secondPair.Key)
                {
                    KeyValuePair <Card, Card> swap = secondPair;
                    secondPair = firstPair;
                    firstPair  = swap;
                }

                cards.Add(firstPair.Key);
                cards.Add(firstPair.Value);
                cards.Add(secondPair.Key);
                cards.Add(secondPair.Value);

                cards.Add(highCard);
            }
Esempio n. 4
0
        /// <summary>
        /// Tries to create a Two Pair <see cref="Hand"/> from the given cards.
        /// </summary>
        /// <param name="cards">The cards from which to create the hand.</param>
        /// <returns>
        ///	a <see cref="Hand"/> of the family's type, or null if the provided cards <br/>
        ///	do not contain the specific hand.
        /// </returns>
        protected override Hand GetBestHandOverride(List <Card> cards)
        {
            if (cards.Count < 4)
            {
                return(null);
            }

            List <Card> clone = new List <Card>();

            clone.AddRange(cards);
            Hand firstHand = twoOfAKindHelper.GetBestHand(clone); // gets the first pair in the hand

            if (firstHand != null)
            {
                KeyValuePair <Card, Card> firstPair = TwoOfAKindFamily.GetPair(firstHand);

                RemoveCardValue(clone, firstPair.Key);                 // remove the pair from the cards collection

                Hand secondHand = twoOfAKindHelper.GetBestHand(clone); // get another pair
                if (secondHand != null)
                {
                    firstPair = TwoOfAKindFamily.GetPair(secondHand);

                    RemoveCardValue(clone, firstPair.Key);                // remove the pair from the cards collection

                    Hand helpingHand = highCardHelper.GetBestHand(clone); // get the remaining high card
                    Card highCard    = Card.Empty;
                    if (helpingHand != null)
                    {
                        highCard = HighCardFamily.GetHighCard(helpingHand);
                    }

                    return(new TwoPairHand(firstHand, secondHand, highCard, this));
                }
            }
            return(null);
        }