It gets slightly complicated, but not too bad: on('ready',()=>{
const flippingDeckIds = [];
findObjs({type: 'deck'})
.filter( (d) => /^Tarokka/i.test(d.get('name')) )
.forEach( (d) => flippingDeckIds.push(d.id) );
const isFlippingDeck = (cardid) => {
const lookup = {};
if( lookup.hasOwnProperty(cardid) ) {
return lookup[cardid];
}
let card = getObj('card',cardid);
lookup[cardid] = flippingDeckIds.includes(card.get('deckid'));
return lookup[cardid];
};
on('add:card',(obj)=>{
if( isFlippingDeck(obj.get('cardid')) && randomInteger(2) === 1 ) {
obj.set('rotation',180);
}
});
}); I build a list of the deck ids in flippingDeckIds. I'm using findObjs() to get all decks, then .filter() is checking the name (here I'm seeing if they start with Tarokka as I have those available for testing), then add the ids to the list. When a card is added to the table, it actually comes in as a graphic of the subtype card, so I built a function called isFlippingDeck() and pass the cardid from the graphic to it. That function does some caching, but basically gets the card from the card id and looks to see if its associated deck id is in the list of flippingDeckIds, returning true or false. The rest of the logic is the same.