How to Discard a random card

Hi;
My latest conundrum involves discarding a random card from those which are in play on the Map. The cards must be in the 9 Active development Zones which can be defined by the Expression DevelAct == "true". The Zone names are Active “Development_1”, etc. I have configured a GKC which will send a Discard command to Random Zone that contains the “Active Development” cards…

…the problem is I do not know how to limit this to only those Zones which have a card in them. It can take several left-clicks before a random card is removed.

The Expression CountMap("Main Map","{DevelAct == \"true\"}") gives me count of the number of occupied Zones so I tried the following trigger set to loop…

… so that the Tigger would fire until there was one less card Active Development card left on the Map however this becomes an infinite loop unfortunately and so do some other variations on using CountMap. There must a way to do this but several hours of Trial and error have drawn a blank.

Darren

A method I’ve used before is to create a special deck of pieces. Each piece in the deck (let’s call the deck X) identifies a zone. When I put a card in a zone, I add its corresponding piece to X. When I remove a card from a zone, I remove the piece from X. So X always has pieces for only occupied zones.

Set X to always shuffle. It can be hidden off screen. Each piece has no image—just a zone name or number. Now when I want a random card from an occupied zone, I just pull a card from X. Voila. Done.

1 Like

Your loop expression is trying to compare a number (CountMap(...) - 1) to a literal string ("true"), so it’s no wonder that doesn’t work. You need to add a Dynamic Property to store the initial value of the count (I’ll call it DevelActCount for this example), give it a Key Command to set the value directly to {CountMap("Main Map","{DevelAct == \"true\"}")}, and trigger it with the Perform this Key Command once before looping starts part of the Trigger Action.

Then, your loop condition would be {CountMap("Main Map","{DevelAct == \"true\"}") == DevelActCount - 1}, which will keep running the GKC until the current count is 1 less than the starting count.

Edit: you should also add an expression to the Trigger when properties match field: {CountMap("Main Map","{DevelAct == \"true\"}") > 0}, to prevent the Trigger Action from firing if there aren’t any cards to delete (which would result in an infinite loop).

1 Like

Hello Jonathan;

Once again I believe you have the solution. I have been pondering this overnight and thought that what is needed is a kind of “OldCount” like there is an “OldZone” etc. to compare the CountMap to and here you are making one. I will try this out some time today and let you know how it goes.

It might be good idea to make sure the Commands that Trigger DevelActCount are different to the one which triggers the Random discard but yeah I think this will work. Much obliged.

Darren

Hi Shilinski;

So drawing a “Card” from Deck X will remove a card (or Piece) from an occupied Zone only? Interesting. Jonathan’s answer is more the way I was thinking but I may have a use for your suggestion too, especially if the MapCount doesn’t work. Thank you for taking the trouble to reply.

Darren

Hi Jonathan;

Success!!! Never mind my comment…

…I was thinking of placing the Triggers in the Development Deck (different Deck to the one initiating) and using the movement of the cards to update the count and a GP instead of a DP. Your way is much better.

So DP configured…

1st Trigger…

…the Expression {CountMap("Main Map","{DevelAct == \"true\"}") > 0} (as per your suggestion) disables the Right-Click menu text so it can’t be used accidently when all Zones are empty.

And 2nd Trigger…

Works a treat, thanks again.

Darren