Displaying number of cards in hand

Hi, I am trying to create a simple Piece Inventory Window which counts the number of cards each player has in their hand, but I cannot figure out how to apply the CountMap() or SumMap() functions.

I am using the Window below to count the number of cards which have a “SupporterCount” marker with a value of 1. But when I look at the display, the function does not return a value, it only shows the function itself. I guess this is a syntax problem, but I cannot figure it out for the life of me.

Screenshot_3

You’re trying to use a Beanshell function in a legacy format in the “Label for folders” field. Though it lacks a “calculator button”, I’m pretty sure that it will accept Beanshell. Try this instead:
{"$PropertyValue$ = " + CountMap("SupporterCount")}

Alternatively, I think this will work too:
$PropertyValue$ = sum_SupporterCount

The sum_ prefix is a legacy feature that counts up pieces for which the named property defined.

You might also simplify your match field by replacing the CurrentMap == "..." bits with:
CurrentMap.endsWith("Hand")

Thanks for your reply, but I still cannot get this to work. Perhaps it’s a problem with the card attribute that’s being counted.

I used a marker property with the property name ‘SupporterCount’ and a value of 1. Is this the correct approach?

Screenshot_4

I think the Marker is fine.

On reflection, CountMap(“SupporterCount”) won’t work because it needs to know the mapname, which it will not in this context.

Rather than tailor the Beanshell expression further, have you tried
$PropertyValue$ = sum_SupporterCount ?

Yes, that did the trick! Thanks for your help.

1 Like