Page 2 of 2
Re: action never execute
Posted: 18 January 2021, 11:38
by n_e_s_s_u_n_o
Notifications sent between the game start (setupNewGame) and the end of the "action" method of the first active state will never reach their destination.
Does this mean that Hearts is a NON working example?
I say so because my code is equivalent to Hearts code.
Thanks
Re: action never execute
Posted: 19 January 2021, 01:56
by Victoria_La
You mean hearts game or hearts tutorial? Which part is wrong?
Notification are sent from game states following the starting state. Not sure about the logs though.
Re: action never execute
Posted: 19 January 2021, 16:36
by n_e_s_s_u_n_o
Hi, I'm talking of Hearts Tutorial.
Here is my states:
1 => array(
"name" => "gameSetup",
"description" => "",
"descriptionmyturn" => "",
"type" => "manager",
"action" => "stGameSetup",
"transitions" => array( "" => 20 )
),
20 => array(
"name" => "doSomething",
"description" => "",
"descriptionmyturn" => "",
"type" => "game",
"action" => "stdoSomething",
"transitions" => array( "" => 21 )
),
and my game.php
function stdoSomething()
{
$this->cards->moveAllCardsInLocation( null, "deck" );
$this->cards->shuffle( 'deck' );
$cards = $this->cards->getCardsInLocation( 'deck', null, null );
$players = self::loadPlayersBasicInfos();
foreach( $players as $player_id => $player )
{
// Notify player about his cards
self::notifyPlayer( $player_id, 'showCards', 'I am doing showCards', array(
'cards' => $cards
) );
}
$this->gamestate->nextState( );
}
and my .js
in setupNotifications
dojo.subscribe( 'showCards', this, "notif_showCards" );
notif_showCards: function( notif )
{
var j = 1;
for( var i in notif.args.cards )
{
var card = notif.args.cards;
dojo.setStyle( 'btCarta' + j, 'backgroundImage', 'url(' + g_gamethemeurl + 'img/' + card.type + '.jpg)');
j++;
}
}
interface write "I am doing showCards" but it does not.
Now the instructions of notif_showCards is different, but all the rest is practically identical to Hearts Tutorial.
I then added a button, pressing button call php that execute the same code of stdoSomething and notif_showCards is executed.
Thanks.
Paolo
Re: action never execute
Posted: 20 January 2021, 02:02
by Victoria_La
a) why game states have descriptiononmyturn? it should not be there
b) what happens on state 21? It error happens none of notification will be received
c) can you just do console.log in notif handler to make sure it actually called
Re: action never execute
Posted: 20 January 2021, 09:31
by n_e_s_s_u_n_o
Hi, thanks for the answer.
I removed descriptiononmyturn from states 1 and 20.
21 => array(
"name" => "readyTurn",
"description" => clienttranslate('${actplayer} press READY when you are'),
"descriptionmyturn" => clienttranslate('${you} press READY when you are'),
"type" => "multipleactiveplayer",
"possibleactions" => array( "ImReady" ),
"transitions" => array( "ImReady" => 22 )
),
and it works, I press the button and it fire a request for ImReady action, it execute and do exactly what needed.
I used console.log, nothing written, I introduce syntax error in notif handler and nothing is written as it's not executed at all.
Re: action never execute
Posted: 21 January 2021, 00:57
by Victoria_La
what is the game on studio? I would have to look at the code
Re: action never execute
Posted: 21 January 2021, 08:56
by n_e_s_s_u_n_o
paniclabpb
Re: action never execute
Posted: 23 January 2021, 01:35
by Victoria_La
It is working for me, you send notification 'showCards' and I see it right in the begging of the game.
What is not working?
Re: action never execute
Posted: 23 January 2021, 15:39
by n_e_s_s_u_n_o
What is wrong is that it writes showCards in the log but does not execute notif_showCards function. The function must change the cards from the back image to the images of the amebas and laboratory and it doesn't do anything. But if you press the green button READY I send again a notification to showCards and it show the cards.
Thanks
Paolo