Answer the question
In order to leave comments, you need to log in
How are resources accrued in online games (Travian)?
Hi and thanks for your time!
I do not understand anything in game development, but I would like to understand how resource accrual works in online games like travian. Consider the resource "wood" and the construction of military units.
Given:
- The game server has n users and each user has its own rate of resource extraction.
- The user has a wood extraction speed of 60 units / min
- The user builds military units in the amount of 1000 pieces and the speed of 1 unit in 90 seconds
Conditions:
- Resources must be accrued every second;
- The accrual of military units occurs after the readiness of 1 unit, and not the ordered "pack"
As I see it:
- We have a "resource" server to serve 1000 users. At startup, it will calculate the number of accrued tree units per second for each user. Now we go through all users every second and simply increase by the required number of units and at the end of the cycle we flash the changes in the storage;
- By analogy, we have a server of "military units". When a user orders the construction of units, a "transaction" is sent to the server. A transaction is a data structure with information about (unit type, quantity required, construction speed, number of units already built, and time of the last unit built). Now, similarly, we go through transactions every second and check whether we can increase the unit counter by 1, I think the data from the transaction should be enough.
Is this how it should work, and if not, who can tell and explain how it should? Related links are welcome :)
Answer the question
In order to leave comments, you need to log in
No, it's wrong. Such things work according to the event model. The player enters the game - the game sends an event to the server, the server calculates all changes during the offline time.
By itself, the player plays a black box with buttons. The game starts when the button is pressed. The black box (server) processes the action and the results of previous actions (all such games are turn-based, even if you have some kind of timers displayed there). Returns a pretty picture.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question