public static int ThreeOfAKind(this YatzyDice dice) { var threeOfAKind = dice.GroupDice().WhereCountIsAtLeast(3); return(threeOfAKind.Any() ? threeOfAKind[0].Key * 3 : 0); }
public static int LargeStraight(this YatzyDice dice) { var groupDice = dice.GroupDice(); return(groupDice.Count == 5 && groupDice.First().Key == 6 ? 20 : 0); }
public static int TwoPair(this YatzyDice dice) { var pairs = dice.GroupDice().WhereCountIsAtLeast(2); return(pairs.Length == 2 ? pairs[0].Key * 2 + pairs[1].Key * 2 : 0); }
public static int OnePair(this YatzyDice dice) { var pairs = dice.GroupDice().WhereCountIsAtLeast(2); return(pairs.Any() ? pairs.First().Key * 2 : 0); }
public static int FullHouse(this YatzyDice dice) { var groups = dice.GroupDice(); return(groups.Count == 2 ? groups.Sum(g => g.Key * g.Value) : 0); }
public static int SmallStraight(this YatzyDice dice) { return(dice.GroupDice().Count == 5 ? 15 : 0); }
public static int Yatzy(this YatzyDice dice) { return(dice.GroupDice().Count == 1 ? 50 : 0); }