I tried to implement a simple zombie mode in my 2-player game that immediately ends the game if one player leaves. It looks like this:
When a player leaves, I get:
Here's the state code for "zombieEnd":
And, in case it is relevant, here's the state machine:
Code: Select all
function zombieTurn($state, $active_player)
{
$statename = $state['name'];
if ($state['type'] === "activeplayer")
{
switch ($statename)
{
default:
$this->gamestate->nextState("zombieEnd");
break;
}
return;
}
if ($state['type'] === "multipleactiveplayer")
{
// Make sure player is in a non blocking status for role turn
$this->gamestate->setAllPlayersNonMultiactive("zombieEnd");
return;
}
throw new feException("Zombie mode not supported at this game state: " . $statename);
}
Code: Select all
Unexpected error: BGA gameserver 1 do not respond (method: zombie) (timeout: cluster)Code: Select all
function stZombieEnd()
{
// It's a two-player game, so if a player leaves, just end it.
$this->gamestate->nextState("gameEnd");
}
Code: Select all
STATE_ZOMBIE_END => array(
"name" => "zombieEnd",
"description" => "",
"descriptionmyturn" => "",
"type" => "game",
"action" => "stZombieEnd",
"transitions" => array(
"gameEnd" => STATE_GAME_END)
),