Ok, I'm making progress lol... Where is the trigger for a card to be played in Hearts?

Game development with Board Game Arena Studio
Post Reply
User avatar
JCase16
Posts: 116
Joined: 26 June 2015, 19:07

Ok, I'm making progress lol... Where is the trigger for a card to be played in Hearts?

Post by JCase16 »

I cannot figure out how the click to a card is actually causing the playCard function to be called. Where in the hearts tutorial (or other games) is the trigger from the click of the card?


My goal:
Right now I'm trying to figure out how to click multiple cards and then click a button to cause them to be played to the table. Many card games allow you to play multiple cards. Think Hand and Foot, Durak, Scum, Phase 10, Rummy or a number of other games. So the goal is to allow the player to select multiple cards and click a button to cause them to be played to the table, discarded or handed to another player. Any help here would be very appreciated. I still have a long way to go to understand states and notifications and such but I'm at least learning and getting something that is working.

As a side note, wouldn't it be nice to have a series of tutorials that show how individual features of the framework work? Maybe one that shows how to build new states and what all has to be changed/added to make a state change work. Or maybe a tutorial on how to adjust points or trigger buttons to pop up when certain criteria are met.
User avatar
fa81
Posts: 32
Joined: 25 November 2016, 16:35

Re: Ok, I'm making progress lol... Where is the trigger for a card to be played in Hearts?

Post by fa81 »

I'd suggest having a look at the Stock component: http://en.doc.boardgamearena.com/Stock
It has multiselection mode and takes away some of the burden to handle selectable things of the same type (e.g. cards).

If you want to do it manually, it'd be something like this:

Code: Select all

dojo.connect($('my_card_id'), 'onclick', this, 'playCard');
User avatar
fafa-fr
Posts: 383
Joined: 22 December 2013, 21:58

Re: Ok, I'm making progress lol... Where is the trigger for a card to be played in Hearts?

Post by fafa-fr »

I was writing an answer when I saw fa81's post, but I'll post my answer since it gives some more informations.
JCase16 wrote:I cannot figure out how the click to a card is actually causing the playCard function to be called. Where in the hearts tutorial (or other games) is the trigger from the click of the card?
You can see it at the beginning of the "Client - Server interactions" part of the Hearts tutorial. In Hearts the cards in players' hands are displayed and managed by the Stock BGA Studio Component. The call is triggered with the onChangeSelection method of this Stock component (see the Stock doc for details): whenever a player clicks on one of the elements of a Stock, it is selected (or unselected if it was selected), so this method is called.
JCase16 wrote:Right now I'm trying to figure out how to click multiple cards and then click a button to cause them to be played to the table. Many card games allow you to play multiple cards.
In this case, you won't use onChangeSelection method to trigger the action. You will display a button connected to the method that calls the action that plays cards (using onUpdateActionButtons, look for docs and examples), and let players select and unselect cards till they've made their choice, then click on this button.
JCase16 wrote:As a side note, wouldn't it be nice to have a series of tutorials that show how individual features of the framework work?
It takes time to write tutorials for each individual thing, and a lot of doc has already been written. If you're able to code games, you'll be able to find things in the doc and in other games, and figure out how things work. In the Studio you can have a read-only access of a lot of published games (including card games like Haggis). You're already asking a lot of basic things in the forum.
User avatar
JCase16
Posts: 116
Joined: 26 June 2015, 19:07

Re: Ok, I'm making progress lol... Where is the trigger for a card to be played in Hearts?

Post by JCase16 »

Thank you so much for this. Will try and dive back in today. It's getting exciting to me that I'm getting closer to understanding the setup well enough to start actually coding logic. Again, thank you.
Post Reply

Return to “Developers”