Sending notifications before first player action

Game development with Board Game Arena Studio
Post Reply
jarhead271
Posts: 1
Joined: 30 April 2020, 02:17

Sending notifications before first player action

Post by jarhead271 »

Hi,
I am trying to send notifications to players, which don't seem to be making it to the client browsers.

I have a simple state machine:

Code: Select all

    // The initial state. Please do not modify.
	1 => array(
		"name" => "gameSetup",
		"description" => "",
		"type" => "manager",
		"action" => "stGameSetup",
		"transitions" => array( "" => 10 )
	),
    
    // Note: ID=2 => your first state

	10 => array(
		"name" => "roundSetup",
		"type" => "game",
		"action" => "stRoundSetup",
		"transitions" => array( "startRound" => 20 )
	),

	20 => array(
		"name" => "playerTurn",
		"description" => clienttranslate('${actplayer} must place a token'),
		"descriptionmyturn" => clienttranslate('${you} must place a token'),
		"type" => "activeplayer",
		"possibleactions" => array( "playToken" ),
		"transitions" => array( "playToken" => 25 )
	),
So after "gameSetup", I am moving into state "roundSetup". The function for roundSetup is:

Code: Select all

	function stRoundSetup()
	{
		// This doesn't seem to work
		self::debug("In stRoundSetup");
				
		// The message 'Round # has begun' IS showing up in the player notification area
		self::notifyAllPlayers( "roundSetup", clienttranslate( 'Round # has begun!' ), array() );
		
		// This is working
		$this->gamestate->nextState('startRound');

	}
First off, the debug message is not showing up in the BGA request log. I know that logging is not visible if written from the constructor or gameSetup, but we are in a different state by this point. I expected it to work once we are out of the gameSetup state, but I guess I am mistaken.

I'm unsure if the notifyAllPlayers call is working. I do see the message 'Round # has begun!' for each player, in the notification area, but the commands in my .js function, notif_roundSetup, don't appear to be executing:

Code: Select all

		notif_roundSetup: function(notif)
		{
			//Neither of these commands are working
			console.log('notif_roundSetup');
			this.testVar = "WORKING";
		},
The plan for the roundSetup state was to inform each player which set of tokens they have in their hand. This needs to happen each round, before the first player acts. If my current approach is not correct, how should I handle this situation? Maybe include the initial set of tokens for each player in gameDatas instead of relying on notifications?

Thank you!
User avatar
RicardoRix
Posts: 2548
Joined: 29 April 2012, 23:43

Re: Sending notifications before first player action

Post by RicardoRix »

Yes, use the gamedatas.
Which you'll have to do anyway because anyone can press F5 at any time.
Something about notifications not working until after the setup.
User avatar
Victoria_La
Posts: 665
Joined: 28 December 2015, 20:55

Re: Sending notifications before first player action

Post by Victoria_La »

I just checked my game and I do have same kind of state setup, where first state is game state and it is upkeep, and it does send notifications and it works.
Make sure at the end of game setup you set active player. Notification are batched and not send until first player state, but I am not sure
what happens when no active player set
Post Reply

Return to “Developers”