I've created a simple puzzle game and have uploaded it to kongregate, now I want to upload highscores (the least amount of moves = better) to it using their API. To make sure no one can cheat the system (submitting the score before puzzle is finished) I need to make sure that none of the pieces in the puzzle are black. All the pieces of the puzzle are movieclips and are inside a array called buttons.
I've currently got this:
public function SumbitScore(e:MouseEvent)
{
for (var v:int = 0; v < buttons.length; v++)
{
if (buttons[v].transform.colorTransform.color != 0x000000)
{
_root.kongregateScores.submit(1000);
}
}
}
but I think that will submit the score as soon as it checks a movieclip that is not black and it'll ignore the rest.
I think the way to go is to keep track of whether or not an 'empty button' is found in your for-loop. After the loop you could submit the score if no empty tiles were found or let the player know the puzzle has to be completed before submitting.
I've added some comments in the code below:
Alternatively you could let the player know how many buttons he still has to finish:
Hope it's all clear.
Good luck!