public IEnumerable<Frame> Frame_rolls(IEnumerable<int> rolls) { var frames = new List<Frame>(); var frame = new Frame(); foreach (var roll in rolls) { if (frame.Roll1.HasValue) { frame.Roll2 = roll; frames.Add(frame); frame = new Frame(); } else { frame.Roll1 = roll; if (roll == 10 && frames.Count < 10) { frames.Add(frame); frame = new Frame(); } } } if (frame.Roll1.HasValue) frames.Add(frame); return frames; }
private static bool Check_for_single_roll_after_spare_in_10th_frame(Frame[] frames) { return frames.Count() == 11 && frames[9].Roll1 != 10 && frames[10].Roll1.HasValue; }
private static bool Check_for_pair_in_10th_frame(Frame[] frames) { return frames.Count() == 10 && frames[9].Roll2.HasValue && frames[9].Score < 10; }
private static bool Check_for_2_more_rolls_after_strike_in_10th_frame(Frame[] frames) { return frames.Count() == 11 && frames[9].Roll1 == 10 && frames[10].Roll1.HasValue && frames[10].Roll2.HasValue; }