PonyClicker icon indicating copy to clipboard operation
PonyClicker copied to clipboard

Understanding PonyClicker: storing location of game data (ingame variables)

Open 3plus4i opened this issue 7 years ago • 1 comments

I'm not sure if you care for PonyClicker anymore at all, but can I still ask some questions? After two years I kinda got interested again and want to work with the code this time. I'm very new to js, xhtml and css (and git and github as well, as far as actually working with it) and have a hard time to understand how the game works. I already prepared for a pull request dealing with problem of getting a cupcake for no smiles at all at the beginning of a game, that I recently mentioned in #78 (though it actually seems to be unrelated to that issue). I haven't pushed it to github yet because I wanted to do some testing. That's where I stumbled over a problem that really puzzled me.

For some quick testing I wanted to use the web console of firefox to easily change the smiles and see if my changes work as expected. But it seems I can't find the correct location of these variables. I expected them at ponyclicker.Game.smiles but when I loaded a regular game with quadrillions of smiles to check ponyclicker.Game.smiles returned 0 and the store was seemingly empty, despite the itself page displaying everything correctly ...

Input and output of the console:

ponyclicker.Game.smiles
0
ponyclicker.Game.store
Array [ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3 weitere… ]

Where am I mistaken? Is it indeed stored somewhere else or am I doing something wrong?

3plus4i avatar Jun 18 '17 10:06 3plus4i

I haven't touched this in 2 years and I honestly have no idea. I suspect javascript fuckery is involved here, in particular the fact that the entire game is namespaced into a giant closure function which may be "hiding" the real store values. I recommend trying to actually print the variables from inside the code to verify they are what you think they are first. Then you can deal with the console lying to you.

ErikMcClure avatar Jun 18 '17 21:06 ErikMcClure