Page 1 of 1

card does not appear in draw cards action

Posted: 05 December 2020, 12:40
by Italo Rufca
I have a problem in the action of draw cards, when this action is performed, the deck counter decreases but the card does not appear in the player's hand, I need to refresh the page for it to appear, how do I resolve?

Re: card does not appear in draw cards action

Posted: 05 December 2020, 13:12
by RicardoRix
is this a game you're developing?

I am guessing: After the draw a card action you send back a notification? The notification handler needs to do all the appropriate UI changes.
Alternatively it could be done via a state change and you are passing back data in the args.args?

So you are handling all of this in the 'setup' which is why it works after page refresh but not after the notification (or state change). 'setup' is a called only once at startup.

You should probably track down how the deck counter is being decreased.

Re: card does not appear in draw cards action

Posted: 05 December 2020, 14:38
by Italo Rufca
Yes, I am developing.

my notification is like this, I got the same code that is used in the game setup to distribute the cards.

notif_cardDraw : function(notif) {
console.log('notif_notif_cardDraw');
console.log(notif);

if (notif.args.cardDrawn != null) {
this.playerHand.addToStockWithId(notif.args.cardDrawn.type_arg,
notif.args.cardDrawn.id, "deck");
}

},

Re: card does not appear in draw cards action

Posted: 05 December 2020, 19:30
by RicardoRix
do you see the message notif_notif_cardDraw in the console, and is the card not null?
Is this notification ever being called? did you register the notif?
and where is the counter being decreased?

Re: card does not appear in draw cards action

Posted: 05 December 2020, 21:03
by Victoria_La
if card is there but invisible its likely stylng issues, inspect HTML of you hand in browser debugging tools, do you see your card there?
If yes check where is, what size is it and what is background. You can adjust css attributes right in browser to see what exactly went wrong.

Re: card does not appear in draw cards action

Posted: 07 December 2020, 13:33
by Italo Rufca
I managed to solve it, thanks. in the addToStockWithId function I was passing an extra parameter, after I removed the "deck" it worked