How to use a Trigger Action to flip a card
Cards in Vassal are a special game piece that consist of a mask trait (representing unrevealed/back side of card) and generally belong to a defined deck. A common action in games using cards is to hide or show them upon certain conditions. In Vassal we can simulate this task by adding a Trigger Action trait to the cards and setting certain properties to make this possible.
The first thing we have to do is take a look and make note of the key command we defined in our mask trait that performs the actual (un)revealing of the cards. In this case CTRL L.
Next we need to define where (or when) the card flip simulation takes place. For this example we will define 'where' by editing a map window's properties and have it apply a key command (CTRL X) to all game pieces that finish their movement on the map.
Finally, we add a Trigger Action to all the cards and bring everything together. Because we are automating the flip of the card, we need to erase the default menu command and leave it blank. Set the KeyStroke to CTRL X and have it perform CTRL L. In the properties field we define when the Trigger Action occurs. Here we will put:
- ObscuredToOthers = true && CurrentMap = MainMap
The important thing to note is that the keystrokes in the Trigger Action match and therefore link everything together and that we use the correct properties to accomplish the task.
Properties and their use is explained in further detail on other pages, but for a quick brief why we used the properties we have: ObscuredToOthers is an inherit vassal property of the Mask trait and can be set to true or false.
CurrentMap is a module property that is defined by the name of any given map. As you will note from the second image, the name of the Map was "MainMap" and this is what we therefore used in the example.
Depending on how you wish to flip cards it can be obviously surmised that all sorts of properties can be used to achieve the card flip effect, be it a Global Property, Dynamic Property, Marker etc..
Everything is complete and we are now set. Whenever a card is moved onto the MainMap our trigger will activate and run the automation to flip the card. It does not matter if the card was in a deck or player's hand.
If the card was already revealed the routine will still run but fail because the card will fail to meet the criteria of the property ObscuredToOthers = true, but it didn't hurt for us to have it check.