Page 1 of 2
action never execute
Posted: 14 January 2021, 14:19
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
Re: action never execute
Posted: 14 January 2021, 14:40
by RicardoRix
do you transition to this state?
1 => array(
"name" => "gameSetup",
"description" => clienttranslate("Game setup"),
"type" => "manager",
"action" => "stGameSetup",
"transitions" => array( "next" => 2 )
),
Re: action never execute
Posted: 14 January 2021, 15:02
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.
Re: action never execute
Posted: 14 January 2021, 15:23
by n_e_s_s_u_n_o
yes, both.
logging say entering state doSomething and it is before active all players.
Re: action never execute
Posted: 14 January 2021, 15:40
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.
Re: action never execute
Posted: 14 January 2021, 17:59
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()
Re: action never execute
Posted: 14 January 2021, 22:19
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.
Re: action never execute
Posted: 14 January 2021, 22:40
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).
Re: action never execute
Posted: 15 January 2021, 15:28
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).
Re: action never execute
Posted: 15 January 2021, 22:41
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.
