Jump to content
  • Advertisement
Sign in to follow this  
Sayid Ahmed

Ticks in PHP Games

This topic is 2395 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

With my current project the biggest challenge will be implementing the tick feature of my PHP + MySQL game. To briefly explain, my game is strategy based, is largely text-based (may have some javascript features later on). The following data will be stored in database tables and will need to be updated somehow:

  • one continuous 'world' with each player with their nation statistics
  • resources, units, research, production and such will all be updated on a tick basis (10 min periods, maybe?)
  • long term statistics; e.g. political party popularity for each player updates every 2 weeks
  • battles will be ticked and can last for days

    Which begs the question of how to implement this tick system. The long term stuff and low bandwidth stuff can be arranged by cron job - simple solution probably. It's the resources and battles and all that stuff that I'm curious about. Most online advice says use timestamps and only update on request by the user, but is it actually that much more efficient? Anybody have any experience with it so they can benchmark?

    What bothers me is that, one of the core features of the game will be trade, and with that you need a market place with lists of buy and sell orders. These will need to be kept up to date and every time the user visits the 'market.php' page it will have to do a search query and update it accordingly. I'm worried this could take very long and by the time the user chooses to buy or sell something, the data has changed and they'll get the wrong order when they submit.

    I'd guess some of this data can be cached and work quickly but I have no experience with this.

    Thanks

Share this post


Link to post
Share on other sites
Advertisement

What bothers me is that, one of the core features of the game will be trade, and with that you need a market place with lists of buy and sell orders. These will need to be kept up to date and every time the user visits the 'market.php' page it will have to do a search query and update it accordingly. I'm worried this could take very long and by the time the user chooses to buy or sell something, the data has changed and they'll get the wrong order when they submit.


You need to queue the orders and process them one at a time. Read from the database only if the values have been changed. Otherwise, display it from the cache like what you've said.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!