[web] Some questions about tesearch/build/leveling up times

Started by
4 comments, last by jbadams 13 years, 2 months ago
Hello,

I did see some threads on this subject in this forum and most conclude the same way. Why check in intervals when you can check when the user logs in? Log in, fetch expired tasks and process them.

Ok, that is fine, but this doesn't help multiplayer interaction. In my scenario, player A might say, launch an attack against player B and player B is on vacation! Well, that won't stop the attack from happening. So since player B is on vacation he can't log in and get his building timers updated. So ultimately, I do need somthing to check every now and then if build timers are expired.

So it seems rather simple to cook up some kind of daemon in a multithreaded langauge like Java or Python to run every say, five minutes, to check for expired timers. But I wonder if there alternative ways of approaching this subject.

Any input would be nice,

thank you
Advertisement
Check when you need to know; for any individual player, that means checking when they log in:
Jeff logs in to AwesomeGame. The system checks if any tasks (construction orders, resource gathering, etc.) were pending for Jeff and resolves the results. The game is then able to accurately display Jeff's information.


Your question is what to do when we add an additional player in to the mix:
Rachel is logged in to AwesomeGame, and launches a fiendish attack against Jeff. The system checks if any tasks were pending for Jeff and resolves the results. The game is then able to accurately display information and calculate battles between Jeff and Rachel.


So no, you still don't need any sort of timed functionality -- you just resolve all the checks for a player whenever anyone (including the player themselves) needs to access that player's information.


Hope that helps! smile.gif

- Jason Astle-Adams

Even if you don't do that, you still don't need to POLL for events. You just keep an ordered list somewhere of the events. For example a unit upgrade being completed. Whenever anyone starts an upgrade you compute how long it should take and post it to the list inserting it into the sorted order.

You can now look at the front of the list, and if that event hasn't happened yet, nothing's expired. Otherwise you just pull things off the front and do them until you get an event dated in the future.

Your process for doing the events can sleep until either the list is changed (in which case it wakes up and checks the front item) or for as long as it is from NOW until the time on the front item.

Check when you need to know; for any individual player, that means checking when they log in:
Jeff logs in to AwesomeGame. The system checks if any tasks (construction orders, resource gathering, etc.) were pending for Jeff and resolves the results. The game is then able to accurately display Jeff's information.


Your question is what to do when we add an additional player in to the mix:
Rachel is logged in to AwesomeGame, and launches a fiendish attack against Jeff. The system checks if any tasks were pending for Jeff and resolves the results. The game is then able to accurately display information and calculate battles between Jeff and Rachel.


So no, you still don't need any sort of timed functionality -- you just resolve all the checks for a player whenever anyone (including the player themselves) needs to access that player's information.


Hope that helps! smile.gif


It does, thank you. One last thing:

Rachel launches fiendish attack against Jeff. Neither Jeff nor Rachel are online when the attack is scheduled to happen (it's a dice roll operation, you don' tneed anyone online for it to happen).

So... if the attack takes 3 days to complete, and on the third day no one is online, the attack still has to take place and be based on jeff's potential "state" the day of the attack.

what then? I can't really think of a way around having a server-side daemon running to check for expired events and processing them.
...One last thing:...Neither Jeff nor Rachel are online when the attack is scheduled to happen...the attack still has to take place...


Why it has to take place? Neither Jeff nor Rachel is online, so who wants to know how this attack ended?

If you answer this question, than you know what you need. Updates on page refresh, cron jobs or your own dedicated realtime webserver.

Rachel launches fiendish attack against Jeff. Neither Jeff nor Rachel are online when the attack is scheduled to happen (it's a dice roll operation, you don' tneed anyone online for it to happen).

So... if the attack takes 3 days to complete, and on the third day no one is online, the attack still has to take place and be based on jeff's potential "state" the day of the attack.

The same solution still applies -- you resolve any out-standing changes when you need to know the state; so in this case, you would resolve the attack the next time either Rachel or Jeff logged in, or the next time another player interacts with either of them.

- Jason Astle-Adams

This topic is closed to new replies.

Advertisement