示例#1
0
    // returns a list of individual frame scores, Not cumulative
    public static List <int> ScoreFrames(List <int> rolls)
    {
        ActionMaster actionMaster = new ActionMaster();

        actionMaster.SetBowls(rolls.ToArray());
        List <int> frameList   = new List <int> ();
        int        rollsLength = rolls.Count;
        int        frameCount  = 0;

        for (int i = 0; i < rollsLength; i++)
        {
            if ((i == 0) || (i != 20 && i % 2 == 0))
            {
                frameCount = ((i + 1) + 1) / 2;                       // note that i+1 gives us the strart bowl throw of this frame
                int frameScore = actionMaster.CalculateFrameScore(frameCount);
                if (frameScore != -1)
                {
                    frameList.Add(frameScore);
                }
            }
        }
        return(frameList);
    }