I changed the function name to "onMoveButton" and that seems to have fixed it.
I'm creating two buttons, move and end turn. Clicking on the first one calls the functions for both instead of just the clicked one. I'm sure it's something simple but I've been banging my head against it for way too long.
The button definitions:
The functions called:
I'm creating two buttons, move and end turn. Clicking on the first one calls the functions for both instead of just the clicked one. I'm sure it's something simple but I've been banging my head against it for way too long.
The button definitions:
Code: Select all
onUpdateActionButtons: function( stateName, args )
{
console.log( 'onUpdateActionButtons: '+stateName );
if( this.isCurrentPlayerActive() )
{
switch( stateName )
{
case 'playerTurn':
var player = this.gamedatas.players[this.getActivePlayerId ()];
if( player.player_AP > 0 )
{
this.addActionButton( 'move_button', _('Move'), 'onMove' );
}
this.addActionButton( 'pass_button', _('End Turn'), 'onEndTurn' );
break;
}
}
},
Code: Select all
onEndTurn: function( evt )
{
// Stop this event propagation
dojo.stopEvent( evt );
// Check for allowed action
if( this.checkAction( 'pass' ) )
{
var player = this.getActivePlayerId ();
this.ajaxcall( "/unknown/unknown/endTurn.html", { player:player }, this, function( result ) {} );
// remove any remaining AP
this.gamedatas.players[player].player_AP = 0;
this.player_Aps[player].toValue(0);
}
},
onMove: function( evt )
{
// Stop this event propagation
dojo.stopEvent( evt );
// Check for allowed action
if( this.checkAction( 'move' ) )
{
var player = this.getActivePlayerId ();
this.ajaxcall( "/unknown/unknown/playerMove.html", { player:player }, this, function( result ) {} );
}
},