Undocumented framework behaviour

Game development with Board Game Arena Studio
Post Reply
User avatar
Lunalol
Posts: 584
Joined: 09 October 2016, 23:21

Undocumented framework behaviour

Post by Lunalol »

This is a long question...

In a game, I have an "activeplayer' state with an args callback (argument for your game state), let's call it argPossibleMoves.
This callback create a list of possible moves stocked in $this->possible and returned by args callback to client side.

On client side, when a move action is done, an Ajax call is made to mygame.action.php which call for example acMove in mygame.game.php.
...Hope you still follow...

Now, in acMove callback, $this->possible is not defined BUT after self::checkAction('move'); it is restored.

So, there is, in the framework, a mechanism which stores class variables somewhere and restores them.
I find my variable "possible" in database table replaysavepoint.

So, here is my question, can we have some explanations about this mechanism ?

And, which is the FASTER mechanism :
  • store datas in DB
  • store datas in class variable (which are finally stored in BD, so not really efficient ?)
Everytime I need datas, I call "sell::getSomethingFromDB", so I prefer datas stored in class variable, but with this mechanism, I doubt.
And finally, if I create my list of possible moves in a 'stSomething' state, it is not restored in args callback.

Thanks for All.
PJL
User avatar
Lunalol
Posts: 584
Joined: 09 October 2016, 23:21

Re: Undocumented framework behaviour

Post by Lunalol »

up
User avatar
RicardoRix
Posts: 2548
Joined: 29 April 2012, 23:43

Re: Undocumented framework behaviour

Post by RicardoRix »

If you need variables to persist then you need to store them in the DB.

Server programming is not like a normal program. Your class object does not persist in memory.
On a page refresh, F5, the server runs - your class is created - delivers it's page content and then disappears.
Last edited by RicardoRix on 19 May 2020, 14:20, edited 1 time in total.
User avatar
sourisdudesert
Administrateur
Posts: 4630
Joined: 23 January 2010, 22:02

Re: Undocumented framework behaviour

Post by sourisdudesert »

Hi

In 99% of the case, there is no need for such a caching algorithm on server side because:
_ the game database is usually very small
_ we designed our database to be accessed very fast

So unless you found there are some really important performance issues, you don't have to worry about that.

About "args": the framework may call your function at various time. There is no really way to know when it's going to be called: it is called when needed. As you notice it may be called by your "checkAction", but you cannot rely on this. If you absolutely need this variable to be filled, then explicitly call your method which fill it.
Post Reply

Return to “Developers”