[Spoiler] Lecture 237 Handles Gutter/Strike

This took some time. The gutterIndex is a static char array that keeps track of when a gutter ball has been rolled. You can use StringBuilder for improved performance but I think this was easier to control the char array for detecting when the user rolled a gutter ball.

public static string FormatRolls(List<int> rolls)
{
    string output = string.Empty;

    for (int i = 0; i < rolls.Count; i++)
    {
        if (i <= 20)
        {
            if (rolls[i] == 0)
            {
                output += rolls[i].ToString();
                if (i == (rolls.Count - 1))
                {
                    gutterIndex[i] = 'g';
                }
            }
            else if (i > 0 && rolls[i - 1] < 10 && rolls[i] < 10 && (rolls[i - 1] + rolls[i] == 10))
            {
                output += "/";
            }
            else if (rolls[i] == 10)
            {
                if (i > 0 && i <= rolls.Count - 1)
                {
                    if (rolls[i - 1] > 0 && rolls[i - 1] != 10)
                    {
                        output += "/";
                    }
                    else if (gutterIndex.Length > i)
                    {
                        output += (gutterIndex[i - 1] == 'g') ? "/" : "X";
                    }
                    else
                        output += "X";
                }
                else
                    output += "X";
            }
            else
            {
                output += rolls[i].ToString();
            }
        }
    }
    return output;
}

I am also using gutterIndex to identify a strike in ScoreMaster. ActionMaster inserts(Pads) the strike with a 0 which ScoreMaster does not account for. The accumulative score will always count it as a spare. I hope that Ben and company will address this in the new version. He said he was going to finish the end game which I have not seen in the current videos. Does anyone know where I can find a gutter image? I guess I could try blender to make it but I have spent quite a bit of time with this game.

Privacy & Terms