[nycphp-talk] online games
Michael Haszprunar
michaelhasz at gmx.net
Sat Nov 5 09:01:36 EST 2005
Marcin Szkudlarek wrote:
> Hi!
>
> I'm thinking about developing online game in php like:
> http://games.swirve.com/utopia
> or
> http://ogame.org
>
> Both of them are real-time strategy games. This means that if you make
> some action in this games, you have to wait for a certain amout of time to
> see the result. For example sending an army to attack another province
> takes few hours of a real-world time.
> My question is , how can I update periodically these kind of data in the
> database? I think I can do it using cron, updating game database every
> hour for example. Is there any other way? Usually you don't have access
> to tool like cron..
>
> Marcin
Hi,
I'm just doing the same and had to do the same thinking. Our solution:
Each dataset (for example the users credits) get a timestamp (last
update). If a function manipulates this value, the timestamp gets
updated. Every time another player accesses this value (for example he
sends our a spy to see the opponents agent) the game has to check if the
value is still correct (maybe tax were paid in the meantime and the user
has not yet logged in to calculate) and if the value is outdated, the
value has to be calculated correct, updated and a net timestamp is given.
The advantage is, that you don't have to calculate ALL new values at the
same time (which can be very complex and long running, depending on the
users), but you just calculate the new value on access. The second
advantage is, that you don't need a cron, which is not availiable in any
hosting environment.
The disadvantage is, that you need a more complex data storage and a
on-access data consistency check.
We tried it and it works great (although the final test is still to come
because our project is about 0.1% complete).
Hope you understand my point, my english is not very good ...
Michael from Germany
More information about the talk
mailing list