setAllPlayersMultiactive not working properly

Game development with Board Game Arena Studio
Post Reply
User avatar
stefano
Posts: 89
Joined: 28 June 2011, 22:18

setAllPlayersMultiactive not working properly

Post by stefano »

I'm trying to configure a multiplayer turn, where all players must play a card simultaneously.

This is my code:

State Machine:

Code: Select all

    3 => array(
        "name" => "Playacard",
		"description" => clienttranslate("Play one card"),
        "type" => "multipleactiveplayer",
        "action" => "stPlayacard",
        //"updateGameProgression" => true,      
		"possibleactions" => array( 'Playacard' ),		
        "transitions" => array( "Applyaction" => 4 )
    ),
Game PHP

Code: Select all

	function stPlayacard()
	{
		$this->gamestate->setAllPlayersMultiactive();
	}
When I reach the state "Playacard", I got the following error: "Invalid or missing substitution argument for log message: undefined error" and I go into an undefined state.

If I remove the setAllPlayersMultiactive call, I don't get the error, but then, after the card selection is completed, if I use the function setPlayerNonMultiactive($player_id, "Applyaction"), I have the error: "Unexpected error: Unexpected final game state (4)"
User avatar
Tisaac
Posts: 2743
Joined: 26 August 2014, 21:28

Re: setAllPlayersMultiactive not working properly

Post by Tisaac »

First error is because you are missing "descriptionMyTurn" field in your game description.
Second error is because your game is stuck in state "4" without knowing what do to left (which is only possible in final state)
User avatar
stefano
Posts: 89
Joined: 28 June 2011, 22:18

Re: setAllPlayersMultiactive not working properly

Post by stefano »

I added descriptionMyTurn and now I can use setAllPlayersMultiactive and setPlayerNonMultiactive!!!

I now transition to state "4" only when all players play the card!! Well done thanks!!

Still I got error on the state "4". I tried to add:

Code: Select all

	function stResolvecards()
	{
		$this->gamestate->nextState( 'NextTurn' );
	}

Code: Select all

    2 => array(
        "name" => "PlaceFruit",
		"description" => clienttranslate("Rolling the dice"),
        "type" => "game",
        "action" => "stPlaceFruit",
		"args" => "argPlaceFruit",
		"possibleactions" => array( "PlaceFruitDone"),
        "updateGameProgression" => true,      
        "transitions" => array( "PlayersTurn" => 3 )
    ),
    3 => array(
        "name" => "Playacard",
		"description" => clienttranslate("Play one card"),
		"descriptionmyturn" => clienttranslate("Play one card"),
        "type" => "multipleactiveplayer",
        "action" => "stPlayacard",
        "updateGameProgression" => true,      
		"possibleactions" => array( 'Playacard' ),		
        "transitions" => array( "Applyaction" => 4 )
    ),
    4 => array(
        "name" => "Resolvecards",
		"description" => clienttranslate("Resolve conflicts"),
        "type" => "game",
        "action" => "stResolvecards",
		"args" => "argResolvecards",
        "updateGameProgression" => true,      
        "transitions" => array( "NextTurn" => 2, "GameEnd" => 99 )
    ),
To go back to state 2, but I get error: "Unexpected error: Unexpected final game state (2)".

Instead, when I start a game, the transition 1-->2-->3 works properly!!

Why?
User avatar
Tisaac
Posts: 2743
Joined: 26 August 2014, 21:28

Re: setAllPlayersMultiactive not working properly

Post by Tisaac »

You will need to give me the code of state 2 to see what's wrong here
User avatar
stefano
Posts: 89
Joined: 28 June 2011, 22:18

Re: setAllPlayersMultiactive not working properly

Post by stefano »

User avatar
stefano
Posts: 89
Joined: 28 June 2011, 22:18

Re: setAllPlayersMultiactive not working properly

Post by stefano »

Action of state 2:

Code: Select all

	function PlaceFruitDone()
	{
        self::setAjaxMode();     
		$result = $this->game->gPlaceFruitDone();
        self::ajaxResponse( );
	}
User avatar
Victoria_La
Posts: 665
Joined: 28 December 2015, 20:55

Re: setAllPlayersMultiactive not working properly

Post by Victoria_La »

You don't have any state transitions in the state and no notifications. Since its a game state it has to transition to new state at the end.
Post Reply

Return to “Developers”