I think there are ways to do that. I use the “print” macro to turn strings into html code and thus display a map based on array data, so maybe you could use that to run code too, but I think it will be messier and more complicated.
The most practical way to do what you want, in my opinion, is to set the effects as properties in the card arrays, and later set up a passage that will interpret those properties. You will also need a variable to copy the exact content of each chosen card, so it will be targeted to be interpreted and operated. Per example, first set the cards like this:
<<set $cardDeck to [
{name: "card 1",
img: "IMG-1285.png",
text: "this is the first card",
effects: [ /* AFTER THIS BRACKET YOU CAN STORE SEVERAL EFFECTS */
{ /* THIS BRACKET MARKS THE CONTENT OF THE 1ST EFFECT */
name:"Magic healing",
description: "Spends 2 mana to heal 2 health points.",
condition: [ /* STORE SEVERAL CONDITIONS HERE */
{property: "mana", value: 2},
{property: "WhateverOtherYouWant", value: 25739}
],
result:[ /* STORE SEVERAL RESULTS HERE */
{property: "mana", value: -2},
{property: "health", value: 2}
]
},
{ ANOTHER EFFECT HERE (you know what I mean)}
},
{ ANOTHER CARD HERE IN THE SAME STYLE }
]>>
Then, set a new variable (in this example, I’ll name it “$chosencard”) to copy the content of the card whose effects you want to trigger, using also a variable to identify the number (in this case, “$cn”, standing for “card number”):
<<set $chosencard to $cardDeck[$cn]>>
You should, obviously, set $cn when the player clicks a card, or something like that.
And then, finally, you should call another passage with the “include” macro (or the old “display” macro) that would silently operate all of this, using a loop to search all through the card “effects”. This would be quite long to write so I’ll just give you some hints.
/* LOOP FOR EACH EFFECT */
<<for _loop to 0; _loop lt $chosencard.effects.length; _loop++>>
/* LOOP FOR EACH EFFECT'S CONDITION */
<<for _loopcon to 0; _loopcon lt $chosencard.effects[_loop].condition.length; _loopcon++>>
if any/all of the condition's name value matches or is smaller than any/all of the player's value of the same name, then:
do here another loop to search through the "results" part, and inside:
order to "set" each player property whose name matches with the name of each "result", as it's "value" demands.
<</for>>
<</for>>
With some imagination, you can write a code that can handle anything. This will be hard work, however.
EDIT: Typos, sorry. Also, another idea that may help: store “and” and “or” string values -or something like that- inside the “conditions”, so you can manage if you want all of them to be needed to trigger the results, or just one of them. This should be also operated as orders in the “silent interpreter” passage. You could also add strings like that in the effect’s “results”, or even something like “random”, to specify that you want to run all of them, or just one of them, or even trigger some randomness with percentages in the “silent interpreter” passage, too. With imagination and hard working, possibilities are endless!