it's not needed, but know OGame and alikes helps to understand.
Way back in my "early" days (around 10 - 15 years ago) I played a lot of browser games like OGame, HackTheNet, WorldHackOrg and such ... and always wondered: How do these work on the server side backend.
One of those, can't remember wich, maybe even ogame, once released an old version wich was just a few php files and a few notes on how to set it up and that it's important a few files get's called in certain time frames to keep the game up. All it ended up with, as far as I understood it back then, where a few formulars with timestamps based on data stored in the database re-newed each time a player did a action, or for those not active online, done in those time intervals.
A few years later I was able to implement a very rudimentary "engine" (one would call it now days "early alpha"). It had a few buildings and a few resources, just barely enough to have a basic eco like: energy production, resource collection, storage (if you know OGame pretty much basic mines, storage and power plant). It was far from having things like research and even further away from player interaction.
It basicly worked like this way:
- the base clock was set to 10min - so, if some action started, like upgrade a knew building, and this action took more than 10min, the server send to the client: don't pull me in the next 10min - there will be no updates - or, if some action would fin in the next 10min the server would reply: pull again in X amount time - I'll have new updates for you
- as it was implemented in java there ran threads on the client active wait for an action to complete - so, when an action was started, the server replied how long it'll take and the client kept active track no matter of the over all 10min cycle
- the resources where interpolated - means, instead of only display the value calculated on last server action, but active counting - this was done by server send rates for how much of a resource was gathered in wich time (could be negative!) - an addition I would may consider today: based on what the players would like, I would either implement it the way like age of empires: when you want to build something to resources gets taken away all at once and you need at least the amount of resources to order - or like red alert: doesn't matter if you have the resources now, and they wont get taken all by once but over time as the build progress - maybe even mixing both - I would the players decide what they like more
So, as I had these very basics done, one could start to farm resources and upgrade buildings and manage eco and energy.
Adding buildings, units, research - I guess that's not that hard to implement a basic "tech tree" and come up with formulars that can factor in additional benefits like faster process or combine of stuff to make new stuff available (like settlers: you need coal and iron ore to make iron to make tools and weapon).
But what about scaling? Wiki says ogame has 2 mil players - is it really that easy to crunch that many datasets with possible collision of active players getting calculated each action they do instead of regular time interval for offline ones? Also, what about calc errors - the more datasets you have the more time it needs to update all calculations. When you start at the first and get to 10'000s you may already a few seconds in. For a high rank player this lack of precision could mean 1000s of resources missing behind what the actual should have. I can see how this would work for a small community - but for massive servers with thousands of players each may request huge datasets at same time (would end up in timeouts for some of the higher latency connections)?
never mind - I guess that's something to re-plan when you get big.
Another thing I never got my head around: How does player interaction work on such games?
To stick to the example of OGame: I sent a command: attack player X with fleet - wich takes time for the way to flight to player X - then a bit of "action" - and the return. How such events calculated? Active? Or by wich ever thread comes first of one of the players, or if both inactive for more than 10min, just the usual server side cycle? I guess that's a topic I need much help with - it's hard to find such specific information on the net.
Thanks in advance to anyone,