public int Three(Hand h) { var gv = h.GroupByValue() .OrderByDescending(kvp => kvp.Value) .ThenByDescending(kvp => (int)kvp.Key) .ToList(); if (gv.Count() == 3 && gv.First().Value == 3) { return D * D * (int)gv[0].Key + D * (int)gv[1].Key + 1 * (int)gv[2].Key; } return 0; }
public int HighestCard(Hand h) { var gv = h.GroupByValue() .OrderByDescending(kvp => (int)kvp.Key) .ToList(); if (gv.Count() == 5) { return D * D * D * D * (int)gv[0].Key + D * D * D * (int)gv[1].Key + D * D * (int)gv[2].Key + D * (int)gv[3].Key + 1 * (int)gv[4].Key; } //throw new Exception(); return 0; }
public int IsOnePair(Hand h) { var gv = h.GroupByValue() .OrderByDescending(kvp => kvp.Value) .ThenByDescending(kvp => (int)kvp.Key) .ToList(); if (gv.Count() == 4 && gv[0].Value == 2) { return D * D * D * (int)gv[0].Key + D * D * (int)gv[1].Key + D * (int)gv[2].Key + 1 * (int)gv[3].Key; } return 0; }
public int FullHouse(Hand h) { var gv = h.GroupByValue() .OrderByDescending(kvp => kvp.Value); if (gv.Count() == 2 && gv.First().Value == 3) { return D * (int)gv.First().Key + (int)gv.Last().Key; } return 0; }