gamestate label issue

Game development with Board Game Arena Studio
Post Reply
User avatar
RichardSPeters
Posts: 18
Joined: 27 August 2021, 23:14

gamestate label issue

Post 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
User avatar
RichardSPeters
Posts: 18
Joined: 27 August 2021, 23:14

Re: gamestate label issue

Post 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
User avatar
thoun
Posts: 1618
Joined: 10 December 2020, 22:25

Re: gamestate label issue

Post 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.
User avatar
RichardSPeters
Posts: 18
Joined: 27 August 2021, 23:14

Re: gamestate label issue

Post by RichardSPeters »

will do - thanks
Post Reply

Return to “Developers”