Page 1 of 1

multipleactiveplayer Question

Posted: 17 April 2020, 23:00
by VanHlebar
I have a question on why my action in a machine state is getting called twice.

Background:
Player selects a card which then puts the machine state into a multipleactiveplayer state for the other players in the game.

My state is defined below:

Code: Select all

    STATE_CHOOSE_REGION => array
    (
        "name" => "chooseRegion",
        "description" => clienttranslate( 'Some players need to choose a region to remove Caballeros from.' ),
        "descriptionmyturn" => clienttranslate( 'You must choose a region to remove Caballeros from using your disc.' ),
        "type" => "multipleactiveplayer",
        "action" => "stChooseRegion",
        "possibleactions" => array( "chooseRegion", "chooseRegionResponse" ),
        "transitions" => array( "returnCaballerosToProvince" => STATE_RETURN_CABALLEROS )
    ),
    
    STATE_RETURN_CABALLEROS => array
    (
        "name" => "returnCaballeros",
        "description" => "",
        "type" => "game",
        "action" => "stReturnCaballeros",
        "transitions" => array( "placeCaballeros" => STATE_PLACE_CABALLEROS, "useActionCard" => STATE_NEXT_ACTION_CARD )
    ),
Once the last player has selected their region the STATE_RETURN_CABALLEROS is called triggering stReturnCaballeros, in which there are two paths that I can take depending on if the player has used both actions available on a card. Relevant code for changing to the next state:

Code: Select all

        // set the activePlayer back to the person who initiated this multiplayer action
        $this->gamestate->changeActivePlayer( $player_id );

        if( $has_placed_cabs )
        {
            // Since we have played both actions at this point we can
            // end the player's turn and turn over the action card.
            $this->endPlayerTurn( self::getActivePlayerName(), $deck, $card_id );
        }
        else
        {
            self::setGameStateValue( 'max_cabs_to_move', $deck);
            $this->gamestate->nextState( "placeCaballeros" );
        }
What I can't figure out is that my argPlaceCaballeros is getting called 3 times when I switch to that state above. It's causing me issues with the variables that get sent back to the client from the server. I was expecting that when switching states above that it would only call the argPlaceCaballeros once.

Anyone have some thoughts or insight? I am just getting back to my project here after over 3 months off due to US Tax Season so it's very possible I am over looking something even in my own code right now. :)

Re: multipleactiveplayer Question

Posted: 18 April 2020, 03:05
by Victoria_La
Missing other parts of the puzzle which is more important - function handling action for multiplayer
and function handling state for multiplayer state, check this
http://en.doc.boardgamearena.com/Your_g ... ayer_state
If you send me your project name I can check the code

Re: multipleactiveplayer Question

Posted: 18 April 2020, 13:42
by VanHlebar
Thanks Victoria I will take a look at the link.

Appreciate the direction.

Re: multipleactiveplayer Question

Posted: 18 April 2020, 17:41
by VanHlebar
I have finally figured out my issue. Not sure if my resolution is the "correct" method, but it is now working. I was making a comparision in the arg Method to the CurrentPlayer and the player that started the Multiplayer state. I needed to be comparing the ActivePlayer and the player that started the Multiplayer state.

Thanks again for the direction!