Issues getting FormatRolls to work for strikes

So I’ve been having an issue with getting FormatRolls to work correctly and it stemmed from importing Ben’s actionmaster.

The problem I have is the score display has no concept of how to discern between a strike in the first shot or a spare caused by a strike in the second shot of a frame.

here’s the offending line in actionmaster sending that information back

            if (rolls[i] == 10) {
                rolls.Insert(i, 0); // Insert virtual 0 after strike
                nextAction = Action.EndTurn;
            }
            else {
                nextAction = Action.Tidy;
            }
        }

as you can see it inserts a virtual miss here (which goes before the strike in the list), so my score display things it should display as a Spare (as to the rules of bowling, if you miss then strike, it’s a spare)

Am I alone with this? Is there something I’m missing? All my tests on everything pass, so the individual modules are returning the correct numbers, it’s only when you actually play the game so it’s all working together the issue rears its ugly head.

Edit: I just tried bens FormatRolls and that also comes out wrong.

Edit2: Just spotted this guy had the same issue, but seems to have fixed it by copying the list instead [Solved]ScoreDisplay tests pass but strikes actually display as -/

2 Likes

thanks for sharing this link, i was on the same problem.

@Rob : Maybe an update of the course should be needed ? Or a link somewhere to solve this problem

nb : I’m currently using 2017.1.0f3

1 Like

Hi @Dieedi,

That would be down to @Ben really, but obviously the new 2017 course will be in development soon so it may be the case that the older course wouldn’t get patched.

What you could do though, to help a few other students out would be to post the issue under the corresponding lecture’s Q&A on Udemy, and then put the link in to point back to the post here for the resolution.

That could be done :slight_smile:
I fixed it personally by reintroducing a “bowls” variable, didnt really want to copy the whole list, but I rewrote the function to be similar to the older one and that seems to work fine. I finished the game off but didn’t really want to upload it to itch.io :stuck_out_tongue:

Thanks for this! I was ripping my hair out pinpointing a solution when I found this bug while I was doing the ScoreDisplay challenge on my own. Everything was working perfectly on the tests but I kept on getting - / when I get strikes. I didn’t expect the problem to stem from a code Ben asked us to copy and paste :tired_face:

1 Like

No problem! I’m glad it helped :slight_smile:

Privacy & Terms