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