Making a Case statement

Sometimes you want to have a set of Triggers where only one of the Triggers will execute for a given condition. However, if the execution of a Trigger changes the condition result on subsequent Triggers then you can easily get a situation where one or more of the other Triggers will then execute.

The idea of adding a Trigger Case trait into Vassal’s capabilities has been discussed before, and this would prevent that situation. Fortunately, there is a simple workaround… evaluate the condition upfront, and then use that “case condition” to control the triggers. Because the Case condition is specific, it gives you more control (normally just to ensure only one of the Triggers activates).

Example from the Player Order Marker prototype from a development version of my Liberté module:

In this example, the piece is setup to respond to a mouse-click. The action depends on the game state. However, the three Trigger actions themselves change the relevant game state. To avoid this complex and undesirable interaction, each Trigger contains a condition of the form {clickCase==n} where n is a literal numeric between 1 and 3. The condition is evaluated into the Dynamic Property clickCase before the Trigger action is tested.

1 Like