Make a refill life system and keep the timer active even when game is closed.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By hamza_memon

I am making a match 3 game. I want to implement a lives system, there will be 4 lives, you use one life for starting a stage and you get one life after every 15 minutes. What, I am thinking is making a dictionary with a single key value pair and updating it. For adding lives back, I am thinking of starting a timer when a life gets cut and updating dictionary at the end of 15 minutes set in timer. If there are still lives remaining to be refilled the timer restarts if maximum lives are reached is stops. The problem is if the game is shut down then it will not update. What should I do to let this logic run even when the game is shut down and also send a notification when all lives are refilled?

Could you possible use OS.get_unix_time() store the time at the point of shut down and when the player loads in, compare the two ? not sure how you could go about tracking that and sending notifications outside of the game.

Chafmere | 2020-06-17 06:06

Thank you, for that time logic. If, I get some doubts, I will get back to you.

hamza_memon | 2020-06-17 06:53

You should be aware that if you are going to store time record on user’ device it can be altered easily, so the best way is to have a server which stores it, but it is a completely different story…
P.S. A small trick: you can use File.get_modified_time() to check if file was modified after it was written by your app :wink:

1shevelov | 2020-06-17 10:18

I was thinking of using firebase to store all user info and time and all right now, I am using dictionaries to store data. I am a beginner with only a few months of experience in development, the data, I have in my game is information about level whether its unlocked and high score and all, information about boosters which can also be purchased and lives system as mentioned above, will uploading all this on database be better and can you point me in the right direction?

hamza_memon | 2020-06-19 07:29

Of course, this info should be saved in database on your server. I’m not experienced in these questions either. I suppose you, or somebody else, should create a service which will serve this data through API to your game. And this service can be written on JavaScript on Node.js, or Python, or PHP - Godot can’t do it.
If you can’t do it yourself I would suggest make the version of your game without purchasing options and if the game would be successful then make second version with the help of backend programmer.
Or may be publishing platforms like Kongregate can handle this stuff… but I know no more.

1shevelov | 2020-06-30 11:50