> Hi,
> I'm new to this group and I'm writing because my java knowledge lack of
[quoted text clipped - 11 lines]
> Do you have any suggestions using java language/pattern/common
> solutions?
What I usually do for stuff like this is, instead of running a
background thread or whatever, I have a DB table which basically schedules
when events should occur. For example, if the player says "Move this ship
from its homeplanet of Quartz to planet Nebulon", I'd immediately change the
ship's location from "Quartz" to "space", and then add a scheduled event of
"At stardate 499283, move ship from 'space' to 'Nebulon'".
Then, the next time a player (ANY player in the game) does something, I
run a quick process to calculate the in-game stardate based on the real-life
time, and then look at schedule-table to see which events are in the pass,
according to this stardate, and then trigger all the events in order.
The only problem with this is that if players decide to abandon your
game for a while (e.g. days or months), the events won't actually trigger
until the next time a player logs into the game to check the state. And this
is only a problem if your game also features e-mail notification of events;
the other players won't get the e-mail notification until SOMEBODY logs in.
If this is a problem for you (it won't be, if you don't have e-mail
notification feature), then you can just create a dummy robot account, and
write a small application (in any language, not nescessarily Java) which
just logs into the robot account every 5 minutes, and immediately logs out.
- Oliver
Jack Burton - 25 Oct 2006 20:46 GMT
This is an interesting point of view, Oliver!
I was thinking about other issues that it can produce (other than the
email notification), but I was only able to argue about performance.
It's true that if at every action a user does I have to check "an event
queue", perhaps it's better to check on a regular basis (thinkin' of
dozens of users). You can argue that the checks could have a minimum
delay, but for every action you have to do a little amount of code (at
least to check if this minimum delay has passed).
Your solution, however, is very clever and coming with not too much
coding effort.
Thanks!