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

Re: action never execute

Post 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
User avatar
Victoria_La
Posts: 665
Joined: 28 December 2015, 20:55

Re: action never execute

Post 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.
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 »

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
User avatar
Victoria_La
Posts: 665
Joined: 28 December 2015, 20:55

Re: action never execute

Post 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
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 »

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.
User avatar
Victoria_La
Posts: 665
Joined: 28 December 2015, 20:55

Re: action never execute

Post by Victoria_La »

what is the game on studio? I would have to look at the code
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 »

paniclabpb
User avatar
Victoria_La
Posts: 665
Joined: 28 December 2015, 20:55

Re: action never execute

Post 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?
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 »

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
Post Reply

Return to “Developers”