Display number of cards remaining in deck

I have a map that has a button to draw a card from a deck on another map. Below this, I would like to use a Text Label to display how many cards are left in the deck.Not sure what the expression in the Name Format would be on the Text Label to get the count?

In the Deck documentation:

The total number of cards currently in the deck can be referenced by the map-level property of <deckname>_numPieces.

So sub in your deck name, append _numPieces and that’s the property you can put in your Text Label. E.g. if the deck’s name was DrawPile: "The draw pile has $DrawPile_numPieces$ cards remaining."

Thank you. It’s still not working, but probably my syntax. The name of my deck is Nasty Surprise Deck and the Label text I have is:
Turns Left: $Nasty Surprise Deck_numPieces$

When I run it, it just displays “Turns Left:”

Is it okay to have spaces in the name of the deck? (I tried changing the name of the deck to not have spaces, but still nothing.)

I was also wondering if I had to do anything to trigger a refresh of the label? Like the act of drawing a card might trigger it to re-evaluate the numPieces?

Try replacing your label text with: {"Turns Left: " + GetProperty("Nasty Surprise Deck_numPieces")}

If spaces in the deck name is the issue, that should fix it.

Also, the numPieces property is available only on the Map where the deck sits. The solution for that is to use GetMapProperty(<property_name>, <map_name>), instead of plain GetProperty().

The deck is on a map called Setup, so I used this:
{"Turns Left: " + GetMapProperty(“Nasty Surprise Deck_numPieces”,Setup)}

But it still didn’t work. :frowning:

I got it! I had to put the name of the map in quotes as well. So, this was the syntax:
{"Turns Left: " + GetMapProperty(“Nasty Surprise Deck_numPieces”,“Setup”)}

Thank you for your help!

1 Like