How can i get attribute from xpath?

What are the best ways to design player attribute updates in persistent game worlds?

  • Take a game with a persistent state that can continue even when players are not online. E.g. your player enters into a fight and loses some health points which are replenished 1 point every five minutes. There are a number of ways to implement this "update stuff even when the player isn't logged in" scenario. E.g. run a server-side background worker that performs scheduled updates (e.g. +1 to health) once a second. Or, forgo the background worker and store the next-update-time for an attribute (e.g. health) in your Player model. Then, anywhere you fetch/get a Player, perform any attribute updates lazily. That is, if the next-update-time is earlier than the fetch/get time (e.g. "now"), update the attribute and then return the updated Player. My goal is to make this system as simple as possible. What are your thoughts? How would you do this?

  • Answer:

    Well, there's two components... what creates the best experience for the player, and separately, what is best technically. The player just wants to be rewarded.  You can accelerate gains when online if you think that's desirable, but you should definitely have recovery when offline.  So, either system works for this part. And, the servers should not be hammered.  Deferring and making it part of login calculations probably works best.  You need to be careful about what periodic tasks the system has to handle and avoid overlapping them and so forth, and the less periodic tasks you have, the easier this is to do. So, I would make the functions take an elapsed time, and design that however is optimal for the player experience considerations.

Tom Cadwell at Quora Visit the source

Was this solution helpful to you?

Other answers

Echoing and building on and 's points: running offline gains at time of login is also best financially. I'm assuming that the question-asker is doing this for commercial gain and aspires to have a sizable audience. Remember that the the more functions you call more frequently, the more computing power you'll have to pay for as an operating expense.

Ian McCullough

I'd suggest making your update functions capable of taking an elapsed time. Then, for example, you could just update the health by something proportional to the amount of time since the user last logged on (or fill to maximum if it's been ages).

Tom Allen

One major benefit of doing it the background process way is that you can alert players when their health is full.  This is done by a lot of mobile apps who will send your phone a notification like "your lives have refilled" when it is done.  There are some compromises to this, in my opinion, that get you the best of both worlds.  Perhaps running a script once every 20 minutes or so, that fills health by X.  Then, for every player who is now at full health, send some type of notification.  Otherwise, calculate from last update on player log in.  This solution would be based on the idea that notifying players when they can optimally play again is an important feature.  Otherwise, the simplest solution is to just calculate on player log in.

Steve Baumgartner

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.