How to calculate production when player is offline
- by Kaizer
What is the best way to do for example food growth based on how many food buildings you have?
Lets say I have a webbased game where you can build a farm wich generates 60 food units per hour. A player has 1 farm in his possession.
What is the best way to keep on producing these units even when the player is offline? Should I do the math when the player get's back online again? If so..how can I do this without having to save his last online time every 5 seconds so I can do some maths with it when he logs back in (datetime.now - lastonlinetime)?
Next thing is when the player is online, should I refresh his resource count every 5 seconds or so by going to the database and back? This would seem weird to do for every logged on player.
I hope you understand my question.
kind regards