You are invited to Log in or Register a free Frihost Account!

Okay so....

I am working on this game, and it is a kind of browser-based RTS. There is a building cache where you put buildings in to upgrade them. Most upgrades will take at the bare minimum a few minutes. What i want to do is show in that building cache when the building will be complete and how much time is left on a count-down timer. I am trying to figure out the best way to do this.

Does this sound logical:

They click the upgrade button and the building goes to the game-wide building cache database, which is ordered ascending of which building will be completed first. When they click on the button to see the buildings in the cache, it will send a request to the database requesting the completion times of all their buildings. The count down timer will show how long until the building is done and it will be accurate within 2 seconds. When the timer hits zero, a query will be sent to the database that removes all the completed buildings, and the page is refreshed by the Javascript timer.

Does this sound efficient to you?

It will work in clearing out the database becuase every time the building cache page is loaded, it sends the command out to remove all completed buildings before it even calls on the persons unfinished buildings. So if no one at all is logged on for 5 days, buildings that finish anytime in that five days won't be removed until one person checks on their own building cache, then all completed ones will be gone.


-Nick Very Happy Very Happy Very Happy
It sounds good. I don't know if it's efficient to remove the old rows that often but if you can make use of indexes I don't think it's a problem.
I wouldn't rely on any client-side script if I where you. The only thing you should do is make the page refresh when the timer hits 0.

For the cache I'd say, just put the time in it when the update will be completed (mysql timestamp or datetime or unix timestamp). And with each request also send the current server time, then with a javascript countdown script you can on the client-pc calculate the countdown.

I think you should also keep the cache and not delete the rows (logs). If you really want to delete them, make a purge script (cron) to delete old rows and run it each day/hour/... Don't make that run with every request, keep the number of queries per request as low as possible.
That is a good point. But how could I get to to work to see that the building is upgraded and out of the cache when it is complete?


-Nick Smile Smile Smile
Related topics
10 Greatest inventions...
Why our life is like that...
Steven Spielberg's: War of The Worlds
-<[ Get the website of your greatest desires!!! ]>-
Close this thread -anyone can design a banner for me-
Okay, my computer has a problem - always have to re-download
Is it okay to be friends with your ex? own little hobby website
Is it okay for your hard drive to overheat?
Install Joomla...Okay?
Okay what should I do.
is it okay to play hard to get to someone you like?
I have a question...
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

© 2005-2011 Frihost, forums powered by phpBB.