code-dot-org/blockly — pull request #789 by Bjvanminnen (2014-08-04 21:32:15+00:00)
Title: Refactor how goals work some

Instead of having a count of goal sprites and an array of goal sprites, have just an array and use the length property for count.

I'd like to change how this works for sprite/sprite count too, but am not doing so for now.

Really, the cleanest solution would probably be to have all the sprites in one array, and then mark them as goal sprites or not, but I'm trying to refrain from rewriting too much.

I also did some refactoring of how we tell if we've reached all the goals. I think my approach is somewhat cleaner/more understandable.

For spriteFinishIndex, there's currently only one level where this is defined. We could pretty easily change that level so that spriteFinishIndex is always 0, and simplify things some. We could also have it so that instead of having only one sprite that can reach goals we allow any sprite too. I'm again trying to limit how much I change things, and am sticking with spriteFinishIndex for now.

We get test coverage from my earlier studio_goals checkin.