Accessing to gamestate args from php side

Game development with Board Game Arena Studio
Post Reply
User avatar
Alkazar
Posts: 22
Joined: 16 August 2011, 14:52

Accessing to gamestate args from php side

Post by Alkazar »

Hello,
Is there a way to access gamestate args array from the php side ? Just in order to avoid unnecessary calls to some functions already called to calculate the args.
I've tried this-> gamestate->state_args but as it is defined as private ...
User avatar
sourisdudesert
Administrateur
Posts: 4630
Joined: 23 January 2010, 22:02

Re: Accessing to gamestate args from php side

Post by sourisdudesert »

Hello,

Thank you for using BGA Studio :)

Basically: no.

The best thing to do is the following:
  • Create a utility function that return the state args.
  • Use it in your "argMyMethod" to generate the result
  • Use it anywhere else :)
Hope this answer the question :)
User avatar
Alkazar
Posts: 22
Joined: 16 August 2011, 14:52

Re: Accessing to gamestate args from php side

Post by Alkazar »

Well it is what I'm already doing but as I was trying to optimize my code I thought it was a pity to call functions like "calculate possible moves" twice.
User avatar
sourisdudesert
Administrateur
Posts: 4630
Joined: 23 January 2010, 22:02

Re: Accessing to gamestate args from php side

Post by sourisdudesert »

Hi,

What you can use them is a local member variable to store the result. Something like:

Code: Select all

if( $this->stored_result )
{
   return $this->stored_result;
}
else
{
    $this->stored_result = self::get_possible_moves_compute();
    return $this->stored_result;
}
Post Reply

Return to “Developers”