I have a mark in the database about the next user level in the game. I have an event that starts a level and logs to the database that the level is started. However, I can't figure out how to finish the level in case of victory or defeat, because coins are awarded for winning the level, and lives are deducted for losing. If I transmit open data that the level is completed with a victory, then the user can wind up a lot of coins for himself and not play the game at all. Are there any solutions that will help me avoid such cheating?
for example, there is a level start method (pseudo)
function startLevel(levelNumber: number){
const userData = getUserData();
if(userData.nextLevel == levelNumber){
userData.onLevel = true;
userData.update();
}
return userData;
}
On the client side, I end the level with a win, and I have to tell the server that the level is completed. In this case after level started, I can send event that level completed and there is no protection for cheating.
function levelEnd(win: boolean){
const userData = getUserData();
if(win){
userData.nextLevel += 1;
userData.onLevel = false;
userData.update();
return userData;
}
userData.onLevel = false;
userData.lives -= 1;
userData.update();
return userData
}
Maybe after starting the level I need to generate some hashes or something like that?