Hi !
In odrer to investigate on my previous topic I make lots of tests to identify where is the problem.
I create a new project on studio, modify js to add button (result is a success)
So i take all the JS and put to the "official project" and hope to get the same result. unfortunately that was not the case
Is someone able to help ?
Result in New project
Result in official project
Addbutton part :
My full JS if needed(used in new and the official project)
Code: Select all
I create a new project on studio, modify js to add button (result is a success)
So i take all the JS and put to the "official project" and hope to get the same result. unfortunately that was not the case
Is someone able to help ?
Result in New project
Code: Select all
<div id="generalactions">
<a href="#" class="action-button bgabutton bgabutton_blue" onclick="return false;" id="button_1_id">Play cards</a>
<a href="#" class="action-button bgabutton bgabutton_red" onclick="return false;" id="button_2_id">Reset</a>
</div>
Code: Select all
<div id="generalactions">
<a href="#" class="action-button bgabutton bgabutton_blue" onclick="return false;" id="$2351197">Play cards</a>
<a href="#" class="action-button bgabutton bgabutton_red" onclick="return false;" id="$2351197">Reset</a>
</div>
Code: Select all
onUpdateActionButtons: function (stateName, args)
{
console.log('onUpdateActionButtons: ' + stateName);
if (this.isCurrentPlayerActive())
{
switch (stateName)
{
case "playerTurn":
this.addActionButton('button_1_id', _('Play cards'), 'doDraw', null, false, 'blue');
this.addActionButton('button_2_id', _('Reset'), 'doDraw1', null, false, 'red');
break;
}
}
},
My full JS if needed(used in new and the official project)
Code: Select all
/**
*------
* BGA framework: © Gregory Isabelli <gisabelli@boardgamearena.com> & Emmanuel Colin <ecolin@boardgamearena.com>
* smilelifeR implementation : © <Your name here> <Your email address here>
*
* This code has been produced on the BGA studio platform for use on http://boardgamearena.com.
* See http://en.boardgamearena.com/#!doc/Studio for more information.
* -----
*
* smilelifer.js
*
* smilelifeR user interface script
*
* In this file, you are describing the logic of your user interface, in Javascript language.
*
*/
define([
"dojo", "dojo/_base/declare",
"ebg/core/gamegui",
"ebg/counter"
],
function (dojo, declare) {
return declare("bgagame.smilelife", ebg.core.gamegui, {
constructor: function () {
console.log('smilelife constructor');
// Here, you can init the global variables of your user interface
// Example:
// this.myGlobalValue = 0;
},
/*
setup:
This method must set up the game user interface according to current game situation specified
in parameters.
The method is called each time the game interface is displayed to a player, ie:
_ when the game starts
_ when a player refreshes the game page (F5)
"gamedatas" argument contains all datas retrieved by your "getAllDatas" PHP method.
*/
setup: function (gamedatas)
{
console.log("Starting game setup");
// Setting up player boards
for (var player_id in gamedatas.players)
{
var player = gamedatas.players[player_id];
// TODO: Setting up players boards if needed
}
// TODO: Set up your game interface here, according to "gamedatas"
// Setup game notifications to handle (see "setupNotifications" method below)
this.setupNotifications();
console.log("Ending game setup");
},
///////////////////////////////////////////////////
//// Game & client states
// onEnteringState: this method is called each time we are entering into a new game state.
// You can use this method to perform some user interface changes at this moment.
//
onEnteringState: function (stateName, args)
{
console.log('Entering state: ' + stateName);
switch (stateName)
{
/* Example:
case 'myGameState':
// Show some HTML block at this game state
dojo.style( 'my_html_block_id', 'display', 'block' );
break;
*/
case 'dummmy':
break;
}
},
// onLeavingState: this method is called each time we are leaving a game state.
// You can use this method to perform some user interface changes at this moment.
//
onLeavingState: function (stateName)
{
console.log('Leaving state: ' + stateName);
switch (stateName)
{
/* Example:
case 'myGameState':
// Hide the HTML block we are displaying only during this game state
dojo.style( 'my_html_block_id', 'display', 'none' );
break;
*/
case 'dummmy':
break;
}
},
// onUpdateActionButtons: in this method you can manage "action buttons" that are displayed in the
// action status bar (ie: the HTML links in the status bar).
//
onUpdateActionButtons: function (stateName, args)
{
console.log('onUpdateActionButtons: ' + stateName);
if (this.isCurrentPlayerActive())
{
switch (stateName)
{
case "playerTurn":
this.addActionButton('button_1_id', _('Play cards'), 'doDraw', null, false, 'blue');
this.addActionButton('button_2_id', _('Reset'), 'doDraw1', null, false, 'red');
break;
}
}
},
///////////////////////////////////////////////////
//// Utility methods
/*
Here, you can defines some utility methods that you can use everywhere in your javascript
script.
*/
///////////////////////////////////////////////////
//// Player's action
doDraw: function () {
console.log('dd');
},
doDraw1: function () {
console.log('11');
},
/*
Here, you are defining methods to handle player's action (ex: results of mouse click on
game objects).
Most of the time, these methods:
_ check the action is possible at this game state.
_ make a call to the game server
*/
/* Example:
onMyMethodToCall1: function( evt )
{
console.log( 'onMyMethodToCall1' );
// Preventing default browser reaction
dojo.stopEvent( evt );
// Check that this action is possible (see "possibleactions" in states.inc.php)
if( ! this.checkAction( 'myAction' ) )
{ return; }
this.ajaxcall( "/smilelifer/smilelifer/myAction.html", {
lock: true,
myArgument1: arg1,
myArgument2: arg2,
...
},
this, function( result ) {
// What to do after the server call if it succeeded
// (most of the time: nothing)
}, function( is_error) {
// What to do after the server call in anyway (success or failure)
// (most of the time: nothing)
} );
},
*/
///////////////////////////////////////////////////
//// Reaction to cometD notifications
/*
setupNotifications:
In this method, you associate each of your game notifications with your local method to handle it.
Note: game notification names correspond to "notifyAllPlayers" and "notifyPlayer" calls in
your smilelifer.game.php file.
*/
setupNotifications: function ()
{
console.log('notifications subscriptions setup');
// TODO: here, associate your game notifications with local methods
// Example 1: standard notification handling
// dojo.subscribe( 'cardPlayed', this, "notif_cardPlayed" );
// Example 2: standard notification handling + tell the user interface to wait
// during 3 seconds after calling the method in order to let the players
// see what is happening in the game.
// dojo.subscribe( 'cardPlayed', this, "notif_cardPlayed" );
// this.notifqueue.setSynchronous( 'cardPlayed', 3000 );
//
},
// TODO: from this point and below, you can write your game notifications handling methods
/*
Example:
notif_cardPlayed: function( notif )
{
console.log( 'notif_cardPlayed' );
console.log( notif );
// Note: notif.args contains the arguments specified during you "notifyAllPlayers" / "notifyPlayer" PHP call
// TODO: play the card in the user interface.
},
*/
});
});