Change states.inc.php without breaking ongoing games
Posted: 30 January 2021, 19:05
Hi,
Is there anyway to add a state in the states.inc.php file without breaking all the ongoing games during the deployment?
My specific use case is that I would like to add an "activeplayer" state that can be reached after an existing "game" state. In the game.php file I would like to only transition to the new state if it exists, that is, if the game has started after the new code version was deployed.
Something like
I tried to use the self::checkAction('chooseShowHand', FALSE) method but it does not seem to work during the execution of a "game" state.
An other option I have in mind is to check the current game version and define which transition to do based on that (like the upgradeTableDb() function).
Please find below the two states I mention above.
EXISTING game STATE
NEW activeplayer STATE
Is there anyway to add a state in the states.inc.php file without breaking all the ongoing games during the deployment?
My specific use case is that I would like to add an "activeplayer" state that can be reached after an existing "game" state. In the game.php file I would like to only transition to the new state if it exists, that is, if the game has started after the new code version was deployed.
Something like
Code: Select all
if (state 32 exists) {
$this->gamestate->nextState("chooseShowHand");
} else {
$this->gamestate->nextState("endHand");
}An other option I have in mind is to check the current game version and define which transition to do based on that (like the upgradeTableDb() function).
Please find below the two states I mention above.
EXISTING game STATE
Code: Select all
31 => array(
"name" => "endBetRound",
"description" => "",
"type" => "game",
"action" => "stEndBet",
"transitions" => array("nextBetRound" => 30, "chooseShowHand" => 32, "endHand" => 25)
),NEW activeplayer STATE
Code: Select all
32 => array(
"name" => "chooseShowHand",
"description" => clienttranslate('${actplayer} decides if she/he wants to reveal her/his hand'),
"descriptionmyturn" => clienttranslate('Do you want to reveal your hand ${you}?'),
"type" => "activeplayer",
"possibleactions" => array("chooseShowHand"),
"transitions" => array("chooseShowHand" => 25, "zombiePass" => 98)
),