[Help] How to create an energy refilling in realtime systme on Android

I want to create one of those systems where the player has only so much energy to play each level, and playing one losses one point, and can’t play a level without energy.

Then, say, every hour, the player regenerates 1 energy point.

My current idea is, when the player opens the level select menu, find the difference between the current time and the last time they left this UI and calculate this difference.

This seems fairly simple to implement, but I’d like to hear any other ideas for this system, because maybe there is an even easier way.

Yeah if you do it locally that will be the way. Candy Crash work that way. You can check it because if you change clock settings you then get lives.

Or you can use something like this,https://github.com/PlayFab/PlayFab-Samples/tree/master/Recipes/RegeneratingCurrency, and do the calculation at Playfab, or something similar on you servers. Of course it requires more work.

Okay, great! And I don’t have any servers, so I’ll just stick to this way.