Sign in to follow this  
v0idnull

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

Recommended Posts

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

Share this post


Link to post
Share on other sites
Check when you need to know; for any individual player, that means checking when they log in:
[i]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.[/i]
[i]
[/i]
Your question is what to do when we add an additional player in to the mix:
[i]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.[/i]
[i]
[/i]
So no, you still don't need any sort of timed functionality -- you just resolve all the checks for a player whenever [i]anyone[/i] (including the player themselves) needs to access that player's information.
[i]
[/i]
Hope that helps! [img]http://public.gamedev.net/public/style_emoticons/default/smile.gif[/img]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[quote name='jbadams' timestamp='1297921180' post='4775267']
Check when you need to know; for any individual player, that means checking when they log in:
[i]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.[/i]
[i]
[/i]
Your question is what to do when we add an additional player in to the mix:
[i]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.[/i]
[i]
[/i]
So no, you still don't need any sort of timed functionality -- you just resolve all the checks for a player whenever [i]anyone[/i] (including the player themselves) needs to access that player's information.
[i]
[/i]
Hope that helps! [img]http://public.gamedev.net/public/style_emoticons/default/smile.gif[/img]
[/quote]

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.

Share this post


Link to post
Share on other sites
[quote name='v0idnull' timestamp='1297964198' post='4775480']...One last thing:...Neither Jeff nor Rachel are online when the attack is scheduled to happen...the attack still has to take place...[/quote]

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.

Share this post


Link to post
Share on other sites
[quote name='v0idnull' timestamp='1297964198' post='4775480']
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.[/quote]
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, [i]or[/i] the next time another player interacts with either of them.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this