示例#1
0
        public Turn(int scoreBefore, ImmutableList <ThrowResult> throws = null)
        {
            if (scoreBefore <= 0)
            {
                throw new ArgumentOutOfRangeException("scoreBefore");
            }
            ScoreBefore = scoreBefore;
            Throws      = throws ?? ImmutableList <ThrowResult> .Empty;
            var gainScore = Throws.Sum(t => t.Score);

            Bust = gainScore == ScoreBefore - 1 ||
                   gainScore > ScoreBefore ||
                   gainScore == ScoreBefore && Throws.Last().SectionArea != SectionArea.Double;
            ScoreAfter = Bust ? ScoreBefore : ScoreBefore - Throws.Sum(t => t.Score);
            Finished   = Throws.Count == 3 || Bust || ScoreAfter == 0;
        }