public static bool HasPokerType(this List <BTCard> cards, BTPokerHands type) { switch (type) { case BTPokerHands.Single: case BTPokerHands.Double: case BTPokerHands.Triple: return(cards.Count == (int)type + 1 && cards.HasSameValuedCards(type)); case BTPokerHands.Quadruple: return(cards.Count == 5 && cards.HasSameValuedCards(type)); case BTPokerHands.Straight: return(cards.Count == 5 && cards.HasStraight()); case BTPokerHands.Flush: return(cards.Count == 5 && cards.HasFlush()); case BTPokerHands.FullHouse: return(cards.Count == 5 && cards.HasFullHouse()); case BTPokerHands.StraightFlush: return(cards.Count == 5 && cards.HasStraightFlush()); } return(true); }
public IEnumerable <IGrouping <int, BTCard> > GetSameGameValuedCards(BTPokerHands type) { IEnumerable <IGrouping <int, BTCard> > matchingCards = this .GroupBy(c => c.GameValue) .Where(g => g.Count() == (int)type + 1); return(matchingCards); }
public bool HasPokerType(BTPokerHands type) { switch (type) { case BTPokerHands.Single: case BTPokerHands.Double: case BTPokerHands.Triple: case BTPokerHands.Quadruple: return(HasSameValuedCards(type)); case BTPokerHands.Straight: return(HasStraight()); case BTPokerHands.Flush: return(HasFlush()); case BTPokerHands.FullHouse: return(HasFullHouse()); case BTPokerHands.StraightFlush: return(HasStraightFlush()); } return(true); }
public static IEnumerable <IGrouping <int, BTCard> > GetSameValuedCards(this List <BTCard> cards, BTPokerHands type) { var temp = type == BTPokerHands.Quadruple ? 4 : (int)type + 1; IEnumerable <IGrouping <int, BTCard> > matchingCards = cards .GroupBy(c => c.Value) .Where(g => g.Count() == temp); return(matchingCards); }
public static bool HasSameValuedCards(this List <BTCard> cards, BTPokerHands type) { IEnumerable <IGrouping <int, BTCard> > pairs = cards.GetSameValuedCards(type); return(pairs.Any()); }
/// <summary> /// Has Single/Double/Triple/Quadripe /// </summary> /// <param name="type"></param> /// <returns></returns> public bool HasSameValuedCards(BTPokerHands type) { IEnumerable <IGrouping <int, BTCard> > pairs = GetSameValuedCards(type); return(pairs.Any()); }