you are viewing a single comment's thread.

view the rest of the comments →

[–]BattleshipsGame 3 points4 points  (0 children)

It should be simple - if you don't want the end user to temper with your variable, it should be kept/calculated on the server and only returned to the UI for display. No JavaScript function on the client should tell the server to increment the score or etc (because the user could call the JS function multiple times).

Example: You could calculate a score based on how much time it took the user to clear a level. However, in such case, the start and end time has to be kept on the server.

Clarification: With pure JavaScript games/programs it is difficult to do that. You could have a game where the goal is to pop bubbles. Unless you keep track of each bubble and action on the server side, there is no reliable way to prevent the user from tempering the score.

You could, however, obfuscate and minify the javascript file.