in reply to Running a script periodically to update player statistics on a web game.

If it's just once every five minutes, my initial inclination is to say cron is probably the way to go.

However, as kcott pointed out, you may be able to instead do this processing on-demand when players are loading pages, with something along the lines of

for (1 .. ($time_since_last_turn / 300)) { process_turn($player); }
...but that's not really suitable if turn processing has side-effects visible to other players which would require the turns to actually be processed at the same time as the turn (nominally) occurs.

While I'm often fond of building back-end daemons to run my games, I don't really see the point of it for turns that are only processed once every five minutes, regardless of whether your host will allow long-running processes or not.

  • Comment on Re: Running a script periodically to update player statistics on a web game.
  • Download Code