Page 1 of 1
eliminatePlayer behaviour
Posted: 26 October 2014, 11:48
by przemek88
Hi, i am working on K2 (project name: tuyrg) and recently found problem with eliminating players who have both climbers dead (in which case they do nothing to the end of the game). I thought the eliminatePlayer function is a perfect choice, but once i eliminated any player, the game is cancelled. Is that specific to the studio environment? How can i eliminate player without finishing the game (even if there is a single player alive)?
Re: eliminatePlayer behaviour
Posted: 30 October 2014, 23:32
by sourisdudesert
Hi,
The normal behaviour is that the game continue until the end, so please use the method as you planned to use it.
I'm going to check if there is a bug in the studio.
Cheers,
Re: eliminatePlayer behaviour
Posted: 31 October 2014, 15:23
by sourisdudesert
Hi,
The explanation is simple: once a player is eliminated, the "zombie" code is applied to make him play. If this case (= game state) is not supported, the game automatically abandoned.
So you just have to write the "zombie" method and everything is going to be okay!
Re: eliminatePlayer behaviour
Posted: 31 October 2014, 19:16
by przemek88
Thanks for answer. I attached the message i see before automatic redirect at the end of the game. I filled zombiePass in states.php but the problem still occurs. My current zombieTurn function:
Code: Select all
function zombieTurn( $state, $active_player )
{
$statename = $state['name'];
if ($state['type'] == "activeplayer") {
switch ($statename) {
default:
$this->gamestate->nextState( "zombiePass" );
break;
}
return;
}
if ($state['type'] == "multipleactiveplayer") {
// Make sure player is in a non blocking status for role turn
$sql = "
UPDATE player
SET player_is_multiactive = 0
WHERE player_id = $active_player
";
self::DbQuery( $sql );
$this->gamestate->updateMultiactiveOrNextState( '' );
return;
}
throw new feException( "Zombie mode not supported at this game state: ".$statename );
}
it has never complained about the unsupported state. Logs are silent either.
Re: eliminatePlayer behaviour
Posted: 31 December 2014, 18:39
by przemek88
Just for the record: recently the problem stopped to happen (i have not touched the zombieCode since then) thus i assume something on the BGA side changed (logs were silent).
Anyway, i think it would be a good idea to make it more resilient (at least in the Studio env). Any exception in the zombiePass method cause to end the game which is irritating during development. I managed to work-around that inconvinience by putting the whole code inside try-catch and log the problem, but it's not fine on production.