Help with transitions
Posted: 09 March 2025, 11:17
I am developing my first BGA game - it has been a big learning curve.
I am having an issue with an aspect of transitions from one state to the next. The relevant part of the states.inc.php is:
// Phase 1 (Multiplayer)
STATE_PHASE_1 => array( // 20
"name" => "playerTurnPhase1",
"description" => clienttranslate('Waiting for other players to place their shape or pass'),
"descriptionmyturn" => clienttranslate('You must place the first shape in one of the grids or pass'),
"type" => "multipleactiveplayer",
"action" => "stSetupPhase1",
"updateGameProgression" => true,
"possibleactions" => array("actProcessPlaceShape", "actPass"),
"transitions" => array("completePhase1" => STATE_PHASE_2, "gameEnd" => STATE_END_GAME)
),
// Phase 2 (Multiplayer)
STATE_PHASE_2 => array( // 30
"name" => "playerTurnPhase2",
"description" => clienttranslate('Waiting for other players to place their shape or pass'),
"descriptionmyturn" => clienttranslate('You must place the second shape in one of the remaining grids or pass'),
"type" => "multipleactiveplayer",
"action" => "stSetupPhase2",
"updateGameProgression" => true,
"possibleactions" => array("actProcessPlaceShape", "actPass"),
"transitions" => array("completePhase2" => STATE_PHASE_3, "gameEnd" => STATE_END_GAME)
),
In the transition from STATE_PHASE_1 to STATE_PHASE_2 (after both players have placed and confirmed the position) the stSetupPhase2() function does certain things (including a self::notifyAllPlayers() call) which are being undone by by the actProcessPlaceShape() function which should be called during STATE_PHASE_1,
I would expect actProcessPlaceShape() would run before the transition to next state and beforestSetupPhase() runs.
The actProcessPlaceShape() is called when a player places their shape and works as expected when the first player (in a two player game) confirms their shape position.
I have struggled with this for too long so anny help or suggestions would be most welcome.
I am having an issue with an aspect of transitions from one state to the next. The relevant part of the states.inc.php is:
// Phase 1 (Multiplayer)
STATE_PHASE_1 => array( // 20
"name" => "playerTurnPhase1",
"description" => clienttranslate('Waiting for other players to place their shape or pass'),
"descriptionmyturn" => clienttranslate('You must place the first shape in one of the grids or pass'),
"type" => "multipleactiveplayer",
"action" => "stSetupPhase1",
"updateGameProgression" => true,
"possibleactions" => array("actProcessPlaceShape", "actPass"),
"transitions" => array("completePhase1" => STATE_PHASE_2, "gameEnd" => STATE_END_GAME)
),
// Phase 2 (Multiplayer)
STATE_PHASE_2 => array( // 30
"name" => "playerTurnPhase2",
"description" => clienttranslate('Waiting for other players to place their shape or pass'),
"descriptionmyturn" => clienttranslate('You must place the second shape in one of the remaining grids or pass'),
"type" => "multipleactiveplayer",
"action" => "stSetupPhase2",
"updateGameProgression" => true,
"possibleactions" => array("actProcessPlaceShape", "actPass"),
"transitions" => array("completePhase2" => STATE_PHASE_3, "gameEnd" => STATE_END_GAME)
),
In the transition from STATE_PHASE_1 to STATE_PHASE_2 (after both players have placed and confirmed the position) the stSetupPhase2() function does certain things (including a self::notifyAllPlayers() call) which are being undone by by the actProcessPlaceShape() function which should be called during STATE_PHASE_1,
I would expect actProcessPlaceShape() would run before the transition to next state and beforestSetupPhase() runs.
The actProcessPlaceShape() is called when a player places their shape and works as expected when the first player (in a two player game) confirms their shape position.
I have struggled with this for too long so anny help or suggestions would be most welcome.