{ /// <summary> /// for a more friendly description /// </summary> /// <param name="hand"></param> /// <returns></returns> public static string Description(this HandCategoryEnum hand) { switch (hand) { case HandCategoryEnum.HighCard: return("High Hand"); case HandCategoryEnum.OnePair: return("One Pair"); case HandCategoryEnum.ThreeeOfAKind: return("Three of A Kind"); default: return(hand.ToString()); } }
/// <summary> /// Initializes a new instance of the EvaluatedHand class. /// </summary> /// <param name="communityCardList">The list of community cards.</param> /// <param name="playerHand">The player's hand.</param> public EvaluatedHand(IReadOnlyList <Card> communityCardList, Hand playerHand) { List <Card> cardListInput = new List <Card>(); cardListInput.AddRange(communityCardList); cardListInput.Add(playerHand.Card1); cardListInput.Add(playerHand.Card2); // Initialize the class if need be if (!isInitialized) { _Initialize(); } // Populate internal card list foreach (Card card in cardListInput) { // Add only non null cards if (card.TwoPlusTwoValue > 0) { this.cardList.Add(card); } } // Make internal list correct for testing if (this.cardList.Count != 2 && this.cardList.Count != 5 && this.cardList.Count != 6 && this.cardList.Count != 7) { throw new ArgumentException("Need 2, 5, 6, or 7 valid cards to be evaluated"); } // Evaluate using either 5 card or 6/7 card method int twoPlusTwoValue; if (this.cardList.Count == 2) { this._ProcessPreFlopHand(); } else { if (this.cardList.Count == 5) { twoPlusTwoValue = _GetHandTwoPlusTwoValue5Card(cardList); } else if (this.cardList.Count == 6) { // Add one null card to the end this.cardList.Add(new Card(string.Empty)); twoPlusTwoValue = _GetHandTwoPlusTwoValue(cardList); // Remove the null card this.cardList.RemoveAt(6); } else if (this.cardList.Count == 7) { twoPlusTwoValue = _GetHandTwoPlusTwoValue(cardList); } else { throw new ArgumentException("Something went wrong"); } int handCategoryInt = twoPlusTwoValue >> 12; this.handCategory = (HandCategoryEnum)handCategoryInt; this.rankWithinCategory = twoPlusTwoValue & 0x00000FFF; } }
private EvaluatedHand(HandCategoryEnum category, int rankWithin) { this.handCategory = category; this.rankWithinCategory = rankWithin; }