ID:153041
 
I, after my awesome computer hiatus, am working once again on my DMCGI multi-player strategy game. One of the main problems poised is handling the event queue.

Events will be scheduled to take place all throughout the day. For example, a player may receive ten new recruits for soldiers at noon. The logical thing to do is to wait until that player logs on, then modify their stats based on the events in their personal queue - but there's a lot of player-to-player interaction in this game, and that just wouldn't work. Plenty of things can happen that will cause the player's stats to need to be viewed. Another player can infiltrate them with a spy, attack them, or their information could simply be needed to generate a high score list. Any player's current stats need to be grabbed at a moment's notice.

The only other option I see is to check a global queue everytime a player loads a page. I see two problems with that, however:
  • It would be slow. Going through the list and individually editing savefiles would be a hassle and wouldn't do anything to help speed up the user's page loading time.
  • What if two players load a page at the same time? The queue will go through twice and players will receive double what was expected.

    So, I need a logical way to modify the queue so none of this happens. Any ideas?
Keep a queue list of just the player's names as the items in the list, and associate each with another list that would hold their personal queues. When the page loads, just check to see if the player's name is in the main list, if it is, access their associated list and update as needed.

~X