Esempio n. 1
0
        private void BuildGame()
        {
            var pinCount = 0;
            var frameCount = 0;
            int firstThrow, secondThrow, thirdThrow = 0;

            while (frameCount < Constants.FramesPerGame - 1)
            {
                firstThrow  = PinsRolled[pinCount];
                secondThrow = PinsRolled[pinCount + 1];

                var currentFrame = frame.BuildFrame(firstThrow, secondThrow);
                Frames.Add(currentFrame);
                frameCount++;

                if (currentFrame.IsStrike)
                {
                    pinCount++;
                }
                else
                {
                    pinCount += 2;
                }
            }

            firstThrow  = PinsRolled[pinCount];
            secondThrow = PinsRolled[pinCount + 1];
            if (pinCount + 2 < PinsRolled.Count)
            {
                thirdThrow = PinsRolled[pinCount + 2];
            }
            var gameFinalFrame = finalFrame.BuildFrame(firstThrow, secondThrow, thirdThrow);

            FinalFrame = gameFinalFrame;
        }