public static IList <T> GetTwoPair <T>(this ITexasHoldemPokerHand <T> self) where T : IGambleCard { ITexasHoldemPokerHand <T> tempHand = new TexasHoldemPokerHand <T>(self); IList <T> pair = new List <T>(), tempPair = tempHand.GetPair(); if (tempPair.Count > 0) { for (int i = 0; i < tempPair.Count; i++) { tempHand.Remove(tempPair[i]); pair.Add(tempPair[i]); } tempPair = tempHand.GetPair(); if (tempPair.Count > 0) { for (int i = 0; i < tempPair.Count; i++) { //We dont carea bout removing, so just add pair.Add(tempPair[i]); } } else { pair.Clear(); } } return(pair); }
//Get Explicit Amounts public static IList <T> GetFullHouse <T>(this ITexasHoldemPokerHand <T> self) where T : IGambleCard { ITexasHoldemPokerHand <T> tempHand = new TexasHoldemPokerHand <T>(self); IList <T> fullHouse = new List <T>(), tempKind = tempHand.GetThreeOfAKind(); if (tempKind.Count > 0) { for (int i = 0; i < tempKind.Count; i++) { tempHand.Remove(tempKind[i]); fullHouse.Add(tempKind[i]); } tempKind = tempHand.GetPair(); if (tempKind.Count > 0) { for (int i = 0; i < tempKind.Count; i++) { //We dont carea bout removing, so just add fullHouse.Add(tempKind[i]); } } else { fullHouse.Clear(); } } return(fullHouse); }
public static ITexasHoldemPokerHand <T> GetBestPokerHand <T>(this ITexasHoldemPokerHand <T> self) where T : IGambleCard { ITexasHoldemPokerHand <T> tempHand = new TexasHoldemPokerHand <T>(self), currentBest = new TexasHoldemPokerHand <T>(); IList <T> tempBest; TexasHoldemPokerRank currentRank = TexasHoldemPokerRank.HighCard; bool hit = false; int remaining = (5 - currentBest.Count); tempBest = tempHand.GetRoyalFlush(); if (tempBest.Count > 0 && !hit) { if (currentRank < TexasHoldemPokerRank.RoyalFlush) { currentRank = TexasHoldemPokerRank.RoyalFlush; } for (int i = 0; i < tempBest.Count; i++) { currentBest.Add(tempBest[i]); tempHand.Remove(tempBest[i]); } remaining = (5 - currentBest.Count); hit = true; } if (!hit) { tempBest = tempHand.GetStraightFlush(); if (tempBest.Count > 0) { if (currentRank < TexasHoldemPokerRank.StraightFlush) { currentRank = TexasHoldemPokerRank.StraightFlush; } for (int i = 0; i < tempBest.Count; i++) { currentBest.Add(tempBest[i]); tempHand.Remove(tempBest[i]); } remaining = (5 - currentBest.Count); hit = true; } } if (!hit) { tempBest = tempHand.GetFourOfAKind(); if (tempBest.Count > 0) { if (currentRank < TexasHoldemPokerRank.FourOfAKind) { currentRank = TexasHoldemPokerRank.FourOfAKind; } for (int i = 0; i < tempBest.Count; i++) { currentBest.Add(tempBest[i]); tempHand.Remove(tempBest[i]); } remaining = (5 - currentBest.Count); hit = true; } } if (!hit) { tempBest = tempHand.GetFullHouse(); if (tempBest.Count > 0) { if (currentRank < TexasHoldemPokerRank.FullHouse) { currentRank = TexasHoldemPokerRank.FullHouse; } for (int i = 0; i < tempBest.Count; i++) { currentBest.Add(tempBest[i]); tempHand.Remove(tempBest[i]); } remaining = (5 - currentBest.Count); hit = true; } } if (!hit) { tempBest = tempHand.GetFlush(); if (tempBest.Count > 0) { if (currentRank < TexasHoldemPokerRank.Flush) { currentRank = TexasHoldemPokerRank.Flush; } for (int i = 0; i < tempBest.Count; i++) { currentBest.Add(tempBest[i]); tempHand.Remove(tempBest[i]); } remaining = (5 - currentBest.Count); hit = true; } } if (!hit) { tempBest = tempHand.GetStraight(); if (tempBest.Count > 0) { if (currentRank < TexasHoldemPokerRank.Straight) { currentRank = TexasHoldemPokerRank.Straight; } for (int i = 0; i < tempBest.Count; i++) { currentBest.Add(tempBest[i]); tempHand.Remove(tempBest[i]); } remaining = (5 - currentBest.Count); hit = true; } } if (!hit) { tempBest = tempHand.GetThreeOfAKind(); if (tempBest.Count > 0) { if (currentRank < TexasHoldemPokerRank.ThreeOfAKind) { currentRank = TexasHoldemPokerRank.ThreeOfAKind; } for (int i = 0; i < tempBest.Count; i++) { currentBest.Add(tempBest[i]); tempHand.Remove(tempBest[i]); } remaining = (5 - currentBest.Count); hit = true; } } if (!hit) { tempBest = tempHand.GetTwoPair(); if (tempBest.Count > 0) { if (currentRank < TexasHoldemPokerRank.TwoPair) { currentRank = TexasHoldemPokerRank.TwoPair; } for (int i = 0; i < tempBest.Count; i++) { currentBest.Add(tempBest[i]); tempHand.Remove(tempBest[i]); } remaining = (5 - currentBest.Count); hit = true; } } if (!hit) { tempBest = tempHand.GetPair(); if (tempBest.Count > 0) { if (currentRank < TexasHoldemPokerRank.OnePair) { currentRank = TexasHoldemPokerRank.OnePair; } for (int i = 0; i < tempBest.Count; i++) { currentBest.Add(tempBest[i]); tempHand.Remove(tempBest[i]); } remaining = (5 - currentBest.Count); hit = true; } } while (remaining >= 1) { T card = tempHand.GetHighCard(); if (card != null) { currentBest.Add(card); tempHand.Remove(card); remaining = (5 - currentBest.Count); } else { break; } } //Console.WriteLine(currentRank.ToString()); currentBest.Rank = currentRank; return(currentBest); }