Help with Count function

I’m trying to restrict an action on a card if there aren’t enough cards in the player’s hand for the action to be valid, using

Count("{cardCount==1}",GetProperty(PlayerSide+" Hand"))<2

as the expression for the restriction (the card hand windows are called “Black Hand”, “Blue Hand”, etc.).

Every card has a marker, cardCount, equal to 1.

However, it seems to always return true (the command is always restricted). Any idea what I’m doing wrong?

Managed to fix it by using Count("{cardCount==1}",$CurrentMap$)<2
instead, but I still don’t understand why the first version didn’t work.

I think the issue will be the map parameter…

Unless you have defined global properties for the hand window names (it appears not from your post) GetProperty(PlayerSide+" Hand") will be translating to a null string.

If I’m right, try Count("{cardCount==1}",PlayerSide+" Hand")<2

You beat me to a solution. As a postscript, the reason that $CurrentMap$ works is because the Count() is being performed within PlayerSide’s own hand window, my suggestion is a more general solution if you need it.

To understand why your first version didn’t work will save you a lot of time in future (from one who has been there)… your first attempt was specifying the map name as a property that didn’t exist (“Black Hand”, “Blue Hand” etc).

Also, in your working you don’t need the $$ around CurrentMap; they aren’t really supposed to be used like that but Vassal tolerates them for backward compatibility.


D’oh! Of course, I was just having a brain fart. Don’t know why I thought I needed GetProperty–I guess I’m just so used to using it when combining things like that.

As for the $$ signs around CurrentMap, I had just been doing a bunch of work with GKCs, and had that formatting on the brain. I really need to stop trying to edit the module when I’m tired! :smiley: