Early notifications

Game development with Board Game Arena Studio
Post Reply
sparr
Posts: 65
Joined: 08 April 2014, 02:12

Early notifications

Post by sparr »

Notifications sent between the game start (setupNewGame) and the end of the "action" method of the first active state will never reach their destination.
If I want some notifications sent before the first player's turn to appear to all the players, should I just insert a dummy state in betwen the start and my first real state?

PS: What makes a state "active"?
User avatar
Een
Posts: 3861
Joined: 16 June 2010, 19:52

Re: Early notifications

Post by Een »

Hi,

You can use notifyAllPlayers in the game setup, for example at the end of setupNewGame(). Just tried it for some game, and it works.

State number 2 is activated after the game setup (which is state number 1); other states are activated when you apply the proper transition (as defined in the states file) to go from one state to another with $this->gamestate->nextState( "transition" );

Cheers,
Een
sparr
Posts: 65
Joined: 08 April 2014, 02:12

Re: Early notifications

Post by sparr »

Code: Select all

    // The initial state. Please do not modify.
    1 => array(
        "name" => "gameSetup",
        "description" => clienttranslate("Game setup"),
        "type" => "manager",
        "action" => "stGameSetup",
        "transitions" => array( "" => 10 )
    ),

    // new hand. collect cards, shuffle, deal, identify start player
    10 => array(
        "name" => "newHand",
        "description" => "",
        "type" => "game",
        "action" => "stNewHand",
        "updateGameProgression" => true,
        "transitions" => array( "playerTurnStart" => 20, "gameEnd" => 99 )
    ),
in stNewHand() I have this:

Code: Select all

            self::notifyAllPlayers( 'playCard',
                clienttranslate('${player_name} starts with ${color_displayed} ${number_displayed} in their palette'),
                array(
Now, all the effects of notif_newHand in my javascript do work. So the gameplay/logic isn't broken. What doesn't work is the display of the "... starts with ... ... in their palette" text in the game log. It works on every hand other than the first one of the game.
User avatar
Een
Posts: 3861
Joined: 16 June 2010, 19:52

Re: Early notifications

Post by Een »

Yes, I was suggesting that you notify at the end of stGameSetup, but in your case your new hand has not yet been drawn.
So adding an extra 'dummy' state between 1 and 10 seems indeed the best solution.
I usually define "nextPlayer" as my second state (which doesn't need notifications), so I have never run into that notification trouble myself.
sparr
Posts: 65
Joined: 08 April 2014, 02:12

Re: Early notifications

Post by sparr »

Code: Select all

    // The initial state. Please do not modify.
    1 => array(
        "name" => "gameSetup",
        "description" => clienttranslate("Game setup"),
        "type" => "manager",
        "action" => "stGameSetup",
        "transitions" => array( "" => 5 )
    ),

    // A dummy state, to fix a bug with notification text in the first state after 1.
    5 => array(
        "name" => "dummyStart",
        "description" => clienttranslate("Game setup"),
        "type" => "game",
        "action" => "stDummyStart",
        "transitions" => array( "newHand" => 10 )
    ),

    // new hand. collect cards, shuffle, deal, identify start player
    10 => array(
        "name" => "newHand",
        "description" => "",
        "type" => "game",
        "action" => "stNewHand",
        "updateGameProgression" => true,
        "transitions" => array( "playerTurnStart" => 20, "gameEnd" => 99 )
    ),

Code: Select all

    function stDummyStart()
    {
        $this->gamestate->nextState( "newHand" );
    }

    function stNewHand()
    {
...
            // Notify all players about starting palettes
            //FIXME: the 'starts with' text doesn't appear for the first hand of a game
            self::notifyAllPlayers( 'playCard',
                clienttranslate('${player_name} starts with ${color_displayed} ${number_displayed} in their palette'),
                array(
Still no dice. The "... starts with ..." text doesn't appear in the players' game logs.
User avatar
Een
Posts: 3861
Joined: 16 June 2010, 19:52

Re: Early notifications

Post by Een »

Hmm. Maybe a dummy notification in stDummyStart in case only the first notification gets lost ? ;)
No other idea without plunging really deep.
sparr
Posts: 65
Joined: 08 April 2014, 02:12

Re: Early notifications

Post by sparr »

The notifyAllPlayers in question here is inside a loop. It runs 2-4 times, so it's not just the first instance getting lost.

It would be helpful if I knew, for sure, what triggered the "notifications start working" behavior. I've tried putting an activeplayer state before newHand, but that doesn't seem to fix it, either. Do I need to put in a state where the player actually does something?
Post Reply

Return to “Developers”