Stock item add/remove timing

Game development with Board Game Arena Studio
Post Reply
User avatar
RavingWanderer
Posts: 83
Joined: 12 May 2020, 16:08

Stock item add/remove timing

Post by RavingWanderer »

I have a Stock displaying a hand full of cards. Sometimes, when cards are added to the hand, I would like to highlight them.

I have code that looks roughly like this:

Code: Select all

dojo.connect( this.playerHand, 'onChangeSelection', this, 'onHandSelectionChanged' );
this.playerHand.addToStockWithId(...,mycardid,...);
dojo.ready(dojo.hitch(this, 'makeSelection', mycardid));

makeSelection: function (mycardid)
{
  console.log(mycardid);
   this.playerHand.selectItem(mycardid);
}

onHandSelectionChanged: function(ctrl, item_id)
{
  console.log('onHandSelectionChanged');
  console.log(item_id);
}
The dojo.ready surrounding the makeSelection is my attempt to delay processing of the selection, but it seems to make no difference whether I call makeSelection directly there or delay it. When makeSelection is called in this setting, the onHandSelectionChanged callback says the item_id is undefined. When called in a different setting, not associated with a recent addition of the relevant cards to the hand, the callback reports the correct item_id.

It seems to me there may be a timing issue related to this. How do I best deal with it?
Post Reply

Return to “Developers”