Remember that the way you write your gambits in a text file and the way you store them in memory when actually playing the game don’t have to be the same. When reading a data file, it’s very common to parse and transform the contents into internal data structures that are more convenient to use and don’t necessarily have the same structure.
As a trivial example, rather than using a string like “allies” or “health”, you could convert that value into an enum. (By itself, this won’t save you from having to write long switch statements, but it’ll make them more efficient and help protect you against spelling errors.)
You might be able to avoid some switch statements by how you store your data. For instance, instead of having separate variables for character attributes like strength, dexterity, intelligence, etc. you could have an array that holds all attributes (array[0] is strength, array[1] is dexterity, etc.). Then you can specify which attribute you want to work with using its index number, and the code for accessing the attribute doesn’t need a switch statement to select the right one.
You can also use various forms of lookup tables, such as a Dictionary, to convert from an identifier for a thing to the thing itself. (At some point, this ends up being pretty similar to a switch statement under the covers, but it might be more palatable in terms of syntax.)
Basically, try to find clever ways to abstract and group your gambits together so that a bunch of different gambits can all be executed by the same function with different parameters.
On a tangential note, my recollection of FF 12 is that the gambits were a neat idea but they ended up being more frustrating than useful because they were naively designed and not flexible enough. I encourage you to learn from their mistakes.
The first issue was that you simply don’t get enough gambit slots. Personally, I’d have made them unlimited.
Another major problem was that they threw a lot of different considerations into the “target” field so that you couldn’t combine them. For instance, you could say “target the enemy with the lowest health” or “target an enemy that is within this range”, but you couldn’t say “out of all enemies that are within this range, target the one with the lowest health” or “cast on the enemy with the lowest health, but only if I have at least X mana remaining”.
There were also problems related to coordination between multiple characters. For instance, if 2 different characters both had the rule “heal someone below 30% health”, then when someone drops below 30%, they both heal them at the same time instead of dividing up the labor. (Or at least, there were issues of that general type. I don’t remember for sure whether it happened with healing specifically, but it happened with several things.)
Finally, they didn’t think through the practical use-cases of their unique game, so there were a bunch of basic things that you couldn’t make work in the way you would obviously want them to work. For example:
-
You could make a gambit to steal from an enemy, but you couldn’t make them stop stealing once they successfully stole the item.
-
Telling your character to attack with whatever element the enemy is weak against required a huge number of gambit slots (one for each possible element) and wasn’t available until very late in the game (because you had to “unlock” those conditions)
-
And even then, it couldn’t be combined with priority rules, as mentioned above. You couldn’t say “attack the lowest-hp monster with whatever they’re weak to” or “attack the monster I’m attacking with whatever they’re weak to”, you could only say “attack some random lightning-weak monster with lightning”.
-
You could create gambits to refresh your buffs, but they wouldn’t trigger while your party was moving (even though casting spells while moving was entirely legal), so you still had to notice that it was time for a refresh so that you could give them the opportunity to trigger, and you still had to waste time waiting around while they were cast. This could have been such a QoL improvement but they ruined it.
You might find it fruitful to compare to the AI in FF 13, which is less noticeable because it’s not customizable, but it quietly does a lot of sophisticated stuff. For instance, the AI will test all the different elements it can use to see what enemies are weak against, it will switch between bigger and smaller heal spells depending on how damaged an ally is, it will switch to un-dodgable attacks against highly evasive enemies, even a magic-focused character will do one physical attack when there’s an opportunity to use Launch, etc. IMO a good gambit system should allow the player to recreate all of those behaviors (or whatever the equivalents are within your game system).