Answer the question
In order to leave comments, you need to log in
How are queues implemented in online games?
I'm still tormented by the question of how in ordinary browser games, in games in social networks, tasks are completed on time: building units, buildings, sending units.
There is a task, there is a time when it must be completed. But all this must be done in real time. Those. regardless of whether I am in the game or not, my opponents will still see the result.
What tools and methods exist for solving such problems?
Answer the question
In order to leave comments, you need to log in
Somehow it was necessary to create a module for a browser game, which is responsible for restoring the character's standard of living. The task was solved by denormalizing the database - added the hp_last_update field. The value of this field was updated every time the user object was accessed, regardless of whether it is online or not. And then it’s a matter of technology - we have the current value of the standard of living and the maximum allowable, as well as the speed of its recovery. With the help of a simple formula, at the next update, we can calculate how much the standard of living should have been restored since the previous update and change this parameter. A similar method is applicable to other game objects.
Separate table for current tasks with a run time field. If necessary, the time is checked, if it has come up, then the task is performed. It is better to delete the completed task (although it depends on the situation).
Do not chase absolute "realtime" - this is not achievable, there will always be errors.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question