public static IEnumerable <Card> GetPairedCards(this Hand hand) { var pairedRanks = hand.GroupedByRank() .Where(w => w.Count > 1) .Select(s => s.Rank); return(hand.Cards.Where(w => pairedRanks.Contains(w.Rank))); }
public static bool HasThreeOfAKind(this Hand hand) => hand.GroupedByRank() .Where(w => w.Count == 3) .Any();
public static bool HasPair(this Hand hand) => hand.GroupedByRank() .Where(w => w.Count == 2) .Any();
public static bool HasTwoPair(this Hand hand) => hand.GroupedByRank() .Where(w => w.Count == 2) .Count() == 2;