/// <summary> /// Returns the cards that are left, in order, after removing the same value cards from the original cards. /// </summary> /// <param name="originalCards">The original cards.</param> /// <param name="someOfAKind">The cards that are of the same value.</param> /// <returns>The cards that remain after the removal of the provided same value cards.</returns> internal static IEnumerable <Card> GetHighCards(IList <Card> originalCards, List <Card> someOfAKind) { List <Card> clone = new List <Card>(); clone.AddRange(originalCards); HandFamily.RemoveCardValue(clone, someOfAKind[0]); Hand bestHighCard = highCardHelper.GetBestHand(clone); int completionCount = 5 - someOfAKind.Count; if (bestHighCard == null) { Card[] result = new Card[completionCount]; for (int i = 0; i < result.Length; ++i) { result[i] = Card.Empty; } return(result); } else { return(HighCardFamily.GetHighCards(bestHighCard, completionCount)); } }
/// <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); }
/// <summary> /// <para>Initializes an instance of the <see cref="HighCardHand"/> class.</para> /// </summary> /// <param name="cards"> /// The cards from which to create the hand. /// </param> /// <param name="highCardFamily"> /// The high card family to use. /// </param> public HighCardHand(List <Card> cards, HighCardFamily highCardFamily) : base(highCardFamily) { this.cards = cards; }