Page 1 of 1

gamestate label issue

Posted: 06 July 2026, 23:16
by RichardSPeters
Code is currently in ALPHA state and yesterday could start game no issues. This morning when starting up I get

Unexpected error: Propagating error from gameserver 1 (method: createGame): Fatal error during numbabeta setup: Unknown gamestate label: numbaValue (reference: GS1 07/07 00:05:15) (reference: GS0 07/07 00:05:15)

In my Game.php I have

Code: Select all

    public function __construct()
    {
        parent::__construct();
        $this->initGameStateLabels(
            [
                "numbaValue" => 0
            ]
        );
and

Code: Select all

    protected function setupNewGame($players, $options = [])
    {
        $this->playerCardsInHand->initDb(array_keys($players), initialValue: 0);

        // Set the colors of the players with HTML color code. The default below is red/green/blue/orange/brown. The
        // number of colors defined here must correspond to the maximum number of players allowed for the gams.
        $gameinfos = $this->getGameinfos();
        $default_colors = $gameinfos['player_colors'];
        $query_values = [];

        $this->setGameStateValue('numbaValue', random_int(1, 6));
If I remove the line of code "$this->setGameStateValue('numbaValue', random_int(1, 6));" then game starts up, reinstate it and I get

Unexpected error: Propagating error from gameserver ...


Very confusing...

Any suggestions thoughts greatly appreciatted

Re: gamestate label issue

Posted: 07 July 2026, 03:27
by RichardSPeters
Issue was with how my intpretation of how game state lables work. Assumed that when they are initated i.e.

Code: Select all

public function __construct()
    {
        parent::__construct();
        $this->initGameStateLabels(
            [
                "numbaValue" => 0
            ]
        );
the the value uased, "0", is the default value - WRONG it's a label and must be between 10 and 89 - see this for more details : https://en.doc.boardgamearena.com/Main_ ... :_Game.php

Re: gamestate label issue

Posted: 07 July 2026, 08:50
by thoun
Don't hesitate to use $this->bga->globals that are easier to use, return proper typing, and can store more than numbers :)
And btw use bga_rand for random ints.

Re: gamestate label issue

Posted: 10 July 2026, 02:14
by RichardSPeters
will do - thanks