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:
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:
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.
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 )
),
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" );
}
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.