Saving when FORCE Closing game

Hey,
So I have a mobile game with a functioning save system but I’ve ran into a problem. In the game you can find treasures and when you open them 3 random items from a pool is selected that the player can choose from (similar to opening a pack of gwent if anyone has played that). In the current state the treasure is not “claimed” until the player actually chooses one of the 3 items, so if the player was to minimize the app and delete it from memory, upon restart the treasure would be there again and when opened would generate 3 new random items, something I don’t want them to be able to do.

An obvious solution would be if the treasure was assigned 3 random items prior to opening it so a restart would yield the player the same result, thus removing the exploit, maybe that’s what they do in gwent, I’m not sure. But in my case the items are part of a pool and when chosen they are removed from that pool so reserving 3 items in advance would not really work I think, with 30 unique items the pool would be empty after only 10 treasures, so what would happen if you got an 11th one without opening any of the first 10 before?

Another solution would be if it auto-claimed one of them if the game is quit in the selection screen but I think that would feel bad for players.

Can anyone think of a solution I’m not seeing here?

Do all of those on your server where you auto-login all your players. When they reinstall your game on the same device with the same user, you attach them to the same account on your server.
Do everything what you don’t want to be easily hackable on a server. Especially if it affects either real money and/or competition between players.

Lurk is spot-on: the only true way to prevent cheating is to do 100% of the game logic on your own server.

But another halfway point is to shuffle the items ONCE, save it local state, then consume them only in a specific order. The user could still hack the save game, but then it requires more of a thing.

If they try and force-kill before getting the items, next time they’ll just get the same three first items.

Meanwhile, here’s my standard “don’t waste too much time on anti-cheating.”


If you’re concerned about the user ‘hacking your save files,’ or ‘cheating in your game,’ just don’t be. There’s nothing you can do about it. Nothing is secure, it is not your computer, it is the user’s computer. If it must be secure, store it on your own server and have the user connect to download it.

Anything else is a waste of your time and the only person you’re going to inconvenience is yourself when you’re debugging the game and you have savegame errors. Work on your game instead.

Remember, it only takes one 12-year-old in Finland to write a script to read/write your game files and everybody else can now use that script. Read about Cheat Engine to see more ways you cannot possibly control this.

The good news is that most likely nobody will care enough about your game to bother, so you’re safe.

And as far as stealing your code or assets, don’t bother trying to stop that either:

Nobody cares about your project because code has no value.

Proof: you can already download gazillions of open-sourced games with amazing art and code and features and gameplay.

Step 1: Take one, any one, repackage it and try and make some money.

Step 2: You’ll soon find what I mean: code and assets has ZERO value.