The first question for any spell which costs gems is: does the AI think the opposition threatening enough to spend gems on? Which depends on your total strength compared to the opponent's --- so you have to say how much the enemy is, compared to you. No matter what you script, it will only use gems on spells if it feels it needs to, else it'll pick a non-gem spell.