public int Score(Frame frame, Frame nextFrame) { if (frame?.IsStrike() ?? false) { return(10 + Score(nextFrame)); } if (frame?.IsSpare() ?? false) { return(10 + Score(nextFrame?.Tries.ElementAtOrDefault(0))); } return(Score(frame)); }
public void AddRoll(int pins) { Frame f = (History.Count < this.Round) ? new Frame() : History.Pop(); f.Roll(pins); if (History.Count > 0) { History.Peek().Update(f); } History.Push(f); if (History.Count < 10) { if (f.PinsRolled.Length == 2 || f.IsStrike()) { this.Round++; } } else if (f.PinsRolled.Length == 3 || (f.PinsRolled.Length == 2 && !f.IsSpare())) { this.Round++; } }