Page 1 of 1

setAllPlayersMultiactive not working properly

Posted: 19 October 2020, 08:12
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)"

Re: setAllPlayersMultiactive not working properly

Posted: 19 October 2020, 10:12
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)

Re: setAllPlayersMultiactive not working properly

Posted: 19 October 2020, 10:29
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?

Re: setAllPlayersMultiactive not working properly

Posted: 19 October 2020, 10:37
by Tisaac
You will need to give me the code of state 2 to see what's wrong here

Re: setAllPlayersMultiactive not working properly

Posted: 19 October 2020, 10:53
by stefano

Re: setAllPlayersMultiactive not working properly

Posted: 19 October 2020, 11:24
by stefano
Action of state 2:

Code: Select all

	function PlaceFruitDone()
	{
        self::setAjaxMode();     
		$result = $this->game->gPlaceFruitDone();
        self::ajaxResponse( );
	}

Re: setAllPlayersMultiactive not working properly

Posted: 19 October 2020, 13:05
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.