Page 1 of 1

onPlayerHandSelectionChanged issue

Posted: 10 November 2019, 17:47
by tchobello
Howdy

I have an issue with the onPlayerHandSelectionChanged() function.

i've added a if (this.checkAction('giveCards')) there where cards are directly moved on the table when the player clicks on them during 'giveCards' state.

later, on another state, when the player clicks on a card to select it, a warning 'This move is not authorized now' appears.
He is able to validate the choice but how can I get rid of it ?
The warning does not appear if I delete all the if (this.checkAction('giveCards')) bracket...

Re: onPlayerHandSelectionChanged issue

Posted: 10 November 2019, 21:33
by RicardoRix
there is a 2nd default parameter of false, which can be used to show/hide the red message, Try:

if( !this.checkAction( 'giveCards', true ) )


-- you could instead change the event handler with dojo.connect / disconnect.

onUpdateActionButtons:

if (this.playerHand_connect != null)
dojo.disconnect(this.playerHand_connect);

switch( stateName )
{
case 'giveCards' :
{
this.playerHand_connect = dojo.connect( this.playerHand, 'onChangeSelection', this, 'onGiveCards' );
.....

case 'somethingElse' :
{
this.playerHand_connect = dojo.connect( this.playerHand, 'onChangeSelection', this, 'onSomethingElse );
.....

Re: onPlayerHandSelectionChanged issue

Posted: 11 November 2019, 11:10
by tchobello
thanks a lot.

the 'true' parameter works fine.

I might do the nicer one later..