No player active in `activePlayer` state

Game development with Board Game Arena Studio
Post Reply
User avatar
Miwarre
Posts: 38
Joined: 07 January 2021, 19:19

No player active in `activePlayer` state

Post by Miwarre »

I am probably overlooking something so trivial that I cannot find any indication of it...

I am working at a game which, when an option is active, has a specific setup state right after the first move. So, the first move is done in the rather usual playerTurn state, then when that option is active, switches to another state (pieSetup) keeping the same player (no next player activation).

The problem I am facing is that, after the state transition, no player is active and no player can perform any move.

This is the definition of the two relevant states (the games has other states but used only later):

Code: Select all

// Player's move
2 => array(
	"name"			=> "playerTurn",
	"type"			=> "activeplayer",
	"description"		=> clienttranslate('${actplayer} has to draw a box side.'),
	"descriptionmyturn"	=> clienttranslate('${you} have to draw a box side.'),
	"possibleactions"	=> array("actDrawSide"),
	"transitions"		=> array("transCompleteBox" => 2, "transSetup" => 3, "transIncompleteBox" => 10, "zombiePass" => 10, "transEndGame" => 99)
),
// First player setup phase, just before pie rule application
3 => array(
	"name"			=> "pieSetup",
	"type"			=> "activePlayer",
	"description"		=> clienttranslate('${actplayer} has to draw a box side or end the setup phase.'),
	"descriptionmyturn"	=> clienttranslate('${you} can draw a box side or end the setup phase.'),
	"possibleactions"	=> array("actDrawSide", "actEndSetup"),
	"transitions"		=> array("transEndSetup" => 4, "transCompleteBox" => 3, "transIncompleteBox" => 3, "zombiePass" => 10)
),
This is the code which does the transitions. The code is in ...game.php inside a longish function which manages the AJAX call when the first player does his first move (and which, under all other respects, works fine; the relevant statement is indicated):

Code: Select all

	// decrement the number of available choices and go to `gameEnd` state
	// if only as many choices remain as there are unused box sides
	if (--$numSel <= $boxesV+1)				// no longer any available box side
	{
self::debug("Transition `transEndGame`");
		$this->gamestate->nextState('transEndGame');
	}
	// if the table has the pie rule option active, transition to setup state
	// and turn pie off
	elseif (self::getGameStateValue("has_pie") > 0)
	{
self::debug("Transition `transSetup`");
		self::setGameStateValue("has_pie", 0);
		$this->gamestate->nextState('transSetup');    // <== TRANSITION
	}
	else
	{
self::debug("Transition `trans(In)CompleteBox`");
		// otherwise, the game goes on in the same state or into another
		// one according to whether boxes have been claimed or not
		$this->gamestate->nextState($freeMove ? 'transCompleteBox' : 'transIncompleteBox');
	}
The transition does occur when it should and the new state is in effect. From the BGA log:

Code: Select all

15/06 16:51:52 [info] [T386837] [82.48.72.115] [2353923/Miwarre1] nextState with action: 'transSetup'
15/06 16:51:52 [info] [T386837] [82.48.72.115] [2353923/Miwarre1] jump to state 3
but, after this, there is no longer an active player. This can be seen from the following facts:
  • both players have the state "description" text and neither has the "descriptionmyturn" text;
  • neither player can do any move (with message "Not your turn!")
  • a couple of log statements to the JS console say:

Code: Select all

Entering state: playerTurn| Active player ID: 2353923 <=== CORRECT
onUpdateActionButtons: pieSetup
Entering state: pieSetup| Active player ID: null <=== NO ACTIVE PLAYER!
This is haunting me since two or three days. Thanks a lot for any suggestion!
User avatar
cheval_raye
Posts: 101
Joined: 19 March 2020, 17:48

Re: No player active in `activePlayer` state

Post by cheval_raye »

I am not sure if it is related to your problem, but you defined the type of state 3 ("pieSetup") as "activePlayer" with a capital P instead of "activeplayer" with a lower case p (the latter is the correct way)

I suspect it might be, because I also had problem with such little mistakes, but I have no access to the internal code of BGA to confirm it.

Edit : i also found this in the wiki :
Note: Make sure you don't mistype the value of this attribute. If you do (e.g. 'multiactiveplayer' instead of 'multipleactiveplayer'), things won't work, and you might have a hard time figuring out why.
User avatar
Miwarre
Posts: 38
Joined: 07 January 2021, 19:19

Re: No player active in `activePlayer` state

Post by Miwarre »

@ cheval_raye : THANKS A LOT! it was precisely that!

In fact, I had it under the eyes so long that I stopped to notice. Thanks again.
Post Reply

Return to “Developers”