action never execute

Game development with Board Game Arena Studio
User avatar
n_e_s_s_u_n_o
Posts: 93
Joined: 08 January 2021, 15:10

action never execute

Post by n_e_s_s_u_n_o »

Hi, sorry to disturb but I'm losing too much time try to understand what's wrong with my code. I have a state of type game with an Action. Action is never execute.

2 => array(
"name" => "doSomething",
"description" => "",
"descriptionmyturn" => "",
"type" => "game",
"action" => "stdoSomething",
"updateGameProgression" => true,
"transitions" => array( "" => 3 )
),

in game.php I have
function stdoSomething()
{
self::debug("stdoSomething");
}

Thanks for any hint.
Paolo
User avatar
RicardoRix
Posts: 2548
Joined: 29 April 2012, 23:43

Re: action never execute

Post by RicardoRix »

do you transition to this state?

1 => array(
"name" => "gameSetup",
"description" => clienttranslate("Game setup"),
"type" => "manager",
"action" => "stGameSetup",
"transitions" => array( "next" => 2 )
),
User avatar
RavingWanderer
Posts: 83
Joined: 12 May 2020, 16:08

Re: action never execute

Post by RavingWanderer »

If it is before the first active player state, you will not get any logging. This is a well known (and highly annoying) problem.
User avatar
n_e_s_s_u_n_o
Posts: 93
Joined: 08 January 2021, 15:10

Re: action never execute

Post by n_e_s_s_u_n_o »

yes, both.
logging say entering state doSomething and it is before active all players.
User avatar
n_e_s_s_u_n_o
Posts: 93
Joined: 08 January 2021, 15:10

Re: action never execute

Post by n_e_s_s_u_n_o »

well, I try put back $this->activeNextPlayer();
and logging says it pass from state 1 to state 3, simply jumping state 2.
User avatar
RicardoRix
Posts: 2548
Joined: 29 April 2012, 23:43

Re: action never execute

Post by RicardoRix »

try posting something to the DB to see if it is being called.

you can call a php function from the chat

stdoSomething()
User avatar
n_e_s_s_u_n_o
Posts: 93
Joined: 08 January 2021, 15:10

Re: action never execute

Post by n_e_s_s_u_n_o »

Thank you,
I try call the function from message and it works. It's simply not called from states.php.
Don't know why.
User avatar
RavingWanderer
Posts: 83
Joined: 12 May 2020, 16:08

Re: action never execute

Post by RavingWanderer »

What you need to do is (1) post a database change inside your method, and (2) make sure your state machine transitions into an active player state. When it gets to that state, you look into the database to see if your change showed up.

If it doesn't, then there is probably something wrong with your state machine.

I ended up adding a logging table to my game's database, to which I could post log messages during startup (setupNewGame and early game states).
User avatar
n_e_s_s_u_n_o
Posts: 93
Joined: 08 January 2021, 15:10

Re: action never execute

Post by n_e_s_s_u_n_o »

Thanks everyone, I think that was my fault, I mean the action is executed, but action contains a notifyAllPlayers and also if log says the notification is received nothing is executed by the notif_doSomething.
notif_doSomething should change background image of a div but I'm sure it's not executed. (I put there syntax errors and no error was shown by the program).
User avatar
Hornir91
Posts: 38
Joined: 15 October 2018, 06:39

Re: action never execute

Post by Hornir91 »

Like it says in documentation: Notifications sent between the game start (setupNewGame) and the end of the "action" method of the first active state will never reach their destination.

I also tried to do something with ie. stBoardSetup (to make board setup via notifs) but I couldn't, so everything stays now in setup() method, calling utility functions created for board setup and managing. :P
Post Reply

Return to “Developers”