Page 1 of 1
Adding an option after game has been public
Posted: 24 May 2020, 21:05
by Mistergos
Hi there
I would like to add an option to my game. My game is already public on BGA.
I know i can modify my gameoptions.inc.php but i guess it is gonna brake for already existing game if i call in my php :
Code: Select all
$this->getGameStateValue('mynewoption')
I did not find a way to initialize it in preexisting game.
How can i avoid to get an error while accessing my game state value in a game where it does not exist yet?
Re: Adding an option after game has been public
Posted: 24 May 2020, 21:28
by vincentt
Hi,
Not an issue

If you call this function for an undefined game state value, it will return "0". So just manage this.
You need to take extra care if you add a new state or a new field in database.
Cheers
Vincent
Re: Adding an option after game has been public
Posted: 24 May 2020, 21:50
by Mistergos
Unfortunately no. It throws an error :
Code: Select all
Server syntax error:
Notice: Undefined index: mynewoption in /var/tournoi/release/tournoi-200518-0953-gs/www/game/module/table/table.game.php on line 1004
{"status":"0","error":"Unknow gamestate label: mynewoption","expected":0,"code":100,"stack":"#0
Re: Adding an option after game has been public
Posted: 25 May 2020, 00:46
by RicardoRix
Have you called the init function (self::setGameStateInitialValue), and added it to the list (initGameStateLabels)
You don't mean game option I presume, you mean gameStateValue
Re: Adding an option after game has been public
Posted: 25 May 2020, 12:24
by Mistergos
My bad. I assumed the php constructor was not called in an existing game which is wrong.
So if you set the gameStateValue as usual, it will take the default value in preexisting game.