Hello
I am using the BgaCards module.
Server send to client a hand of cards, cards selected, and card selectable in this hand (via gamedatas)
gamedatas.hand
{
3 : {id: '3', type: '1_Pro', type_arg: '3', location: 'R&D_2413802', location_arg: '0'}
7 : {id: '7', type: '3_Cor', type_arg: '7', location: 'R&D_2413802', location_arg: '0'}
8 : {id: '8', type: '3_Cor', type_arg: '8', location: 'R&D_2413802', location_arg: '0'}
10 : {id: '10', type: '0_Har', type_arg: '10', location: 'R&D_2413802', location_arg: '0'}
11 : {id: '11', type: '0_Har', type_arg: '11', location: 'R&D_2413802', location_arg: '0'}
12 : {id: '12', type: '0_Har', type_arg: '12', location: 'R&D_2413802', location_arg: '0'}
}
gamedatas.selectable
{
10 : {card_id: '10', card_type: '0_Har', card_type_arg: '10', card_location: 'R&D_2413802', card_location_arg: '0'}
12 : {card_id: '12', card_type: '0_Har', card_type_arg: '12', card_location: 'R&D_2413802', card_location_arg: '0'}
}
gamedatas.selected
{
7 : {card_id: '7', card_type: '3_Cor', card_type_arg: '7', card_location: 'R&D_2413802', card_location_arg: '0'}
8 : {card_id: '8', card_type: '3_Cor', card_type_arg: '8', card_location: 'R&D_2413802', card_location_arg: '0'}
11 : {card_id: '11', card_type: '0_Har', card_type_arg: '11', card_location: 'R&D_2413802', card_location_arg: '0'}
}
I can display the hand of cards:
for (const cardId in this.gamedatas.hand)
{
let card = { id: parseInt(this.gamedatas.hand[cardId]['id']) };
card.type = this.gamedatas.hand[cardId]['type'];
card.type_arg = this.gamedatas.hand[cardId]['type_arg'];
card.tooltip = cardId;
cards.push(card);
}
this.playerHand.addCards(cards);
I managed to set the selectable cards and the unselectable ones
let selectableCards = this.playerHand.getCards().filter((card) => Object.keys(this.gamedatas.selectable).find((element) => element==card.id));
this.playerHand.setSelectableCards(selectableCards);
Bu I cant find how to show the selected cards
I see in the documentation there is a metho to select one card (https://x.boardgamearena.net/data/game- ... selectcard)
Do you have to select cards one by one? There is no method to select several cards at once?
I tried this method in a loop, but the cards does not appear as selected
for (const selectedCardId in this.gamedatas.selected)
{ this.playerHand.selectCard(this.playerHand.getCards().filter((card) => card.id == selectedCardId)); }
Thanks for any help
I am using the BgaCards module.
Server send to client a hand of cards, cards selected, and card selectable in this hand (via gamedatas)
gamedatas.hand
{
3 : {id: '3', type: '1_Pro', type_arg: '3', location: 'R&D_2413802', location_arg: '0'}
7 : {id: '7', type: '3_Cor', type_arg: '7', location: 'R&D_2413802', location_arg: '0'}
8 : {id: '8', type: '3_Cor', type_arg: '8', location: 'R&D_2413802', location_arg: '0'}
10 : {id: '10', type: '0_Har', type_arg: '10', location: 'R&D_2413802', location_arg: '0'}
11 : {id: '11', type: '0_Har', type_arg: '11', location: 'R&D_2413802', location_arg: '0'}
12 : {id: '12', type: '0_Har', type_arg: '12', location: 'R&D_2413802', location_arg: '0'}
}
gamedatas.selectable
{
10 : {card_id: '10', card_type: '0_Har', card_type_arg: '10', card_location: 'R&D_2413802', card_location_arg: '0'}
12 : {card_id: '12', card_type: '0_Har', card_type_arg: '12', card_location: 'R&D_2413802', card_location_arg: '0'}
}
gamedatas.selected
{
7 : {card_id: '7', card_type: '3_Cor', card_type_arg: '7', card_location: 'R&D_2413802', card_location_arg: '0'}
8 : {card_id: '8', card_type: '3_Cor', card_type_arg: '8', card_location: 'R&D_2413802', card_location_arg: '0'}
11 : {card_id: '11', card_type: '0_Har', card_type_arg: '11', card_location: 'R&D_2413802', card_location_arg: '0'}
}
I can display the hand of cards:
for (const cardId in this.gamedatas.hand)
{
let card = { id: parseInt(this.gamedatas.hand[cardId]['id']) };
card.type = this.gamedatas.hand[cardId]['type'];
card.type_arg = this.gamedatas.hand[cardId]['type_arg'];
card.tooltip = cardId;
cards.push(card);
}
this.playerHand.addCards(cards);
I managed to set the selectable cards and the unselectable ones
let selectableCards = this.playerHand.getCards().filter((card) => Object.keys(this.gamedatas.selectable).find((element) => element==card.id));
this.playerHand.setSelectableCards(selectableCards);
Bu I cant find how to show the selected cards
I see in the documentation there is a metho to select one card (https://x.boardgamearena.net/data/game- ... selectcard)
Do you have to select cards one by one? There is no method to select several cards at once?
I tried this method in a loop, but the cards does not appear as selected
for (const selectedCardId in this.gamedatas.selected)
{ this.playerHand.selectCard(this.playerHand.getCards().filter((card) => card.id == selectedCardId)); }
Thanks for any help