State type "game" and nextState()

Game development with Board Game Arena Studio
Post Reply
User avatar
zigareth
Posts: 7
Joined: 27 October 2020, 18:49

State type "game" and nextState()

Post by zigareth »

Hi,

As per the following documentation (https://en.doc.boardgamearena.com/Your_ ... c.php#type), nothing forbids a transition to be done to a "game" typed state.
Doing this :

Code: Select all

ziga.game.php :
    function action_waitRoll() {
        $this->gamestate->nextState();
    }
With such SM :

Code: Select all

$machinestates = array(

    // The initial state. Please do not modify.
    1 => array(
        "name" => "gameSetup",
        "description" => "",
        "type" => "manager",
        "action" => "stGameSetup",
        "transitions" => array( "" => 2 )
    ),
    
    // Note: ID=2 => your first state

    2 => array(
    		"name" => "waitRoll",
    		"description" => clienttranslate('${actplayer} must roll the dice'),
    		"descriptionmyturn" => clienttranslate('${you} must roll the dice'),
            "type" => "activeplayer",
    		"transitions" => array( "" => 3 )
    ),
    
    3 => array(
        "name" => "getRandomDice",
        "description" => clienttranslate('${actplayer} rolling the dice'),
        "descriptionmyturn" => clienttranslate('${you} rolling the dice'),
        "type" => "game",
        "args" => "argGetDiceRoll",
        "action" => "st_getRandomDice",
        "transitions" => array( "" => 4 )
    ),
[...]
Triggers the following when transitioning from 2 to 3 :

Code: Select all

Unexpected error:  Unexpected final game state (3)
Changing state getRandomDice type to activePlayer instead of game "fixes" the issue.
Just wondering whether this is expected ?
The "game" state type states is explained as the following but doesn't mention such limitation, and from my understanding is not obvious (but I'm just starting exploring BGA, might be wrong) :
game (No player is active. This is a transitional state to do something automatic specified by the game rules.)
Thank you !
User avatar
Tisaac
Posts: 2743
Joined: 26 August 2014, 21:28

Re: State type "game" and nextState()

Post by Tisaac »

Thé problem is with the st getrandom dice that is probably missing a next state inside.
Post Reply

Return to “Developers”