Found another bug in the final Scoremaster

My previous issue is still outstanding with the extra rogue 0, although I’m going to attempt a cunning rewrite of ActionMaster to fix that.

Anyway, with the ScoreDisplay since the spare on bowl 21 modification, that introduces another issue. If you bowl 5’s all the way through so each frame is 5/, on the last frame you should have 5/5, but as of the final code, this will be 5// which is wrong.

I have prepared a test you can use here, of course rename the test to what you require :slight_smile:

I fixed this by having the box 21 check on a separate line with an extra check in the IF statement to see if the previous output string was a /, if it wasn’t then do the Spare, otherwise ignore it, which then falls through to the normal handling.

Here is my code for reference

        else if (box == 21 && rolls[i - 1] + rolls[i] == 10 && output[i - 1].ToString() != "/") {
            output += "/";
        else if (box % 2 == 0 && rolls[i - 1] + rolls[i] == 10) {
            output += "/";

Not elegant, but not sure how I can condense it.

Happy bug fixing!

Edit: I just realised even that solution isn’t going to work if the second hit is a strike, ******… Need to put my strike test first I think… :stuck_out_tongue:

Privacy & Terms