Well as I said the numbers were pretty much out of my ass, but the idea was that either you're a filthy cheater and you used potions to get your strength to 200 to easily beat cobra who took 50 attack from you (and then she uses ethan's attack as the base) or you didn't cheat and if she took enough attack from you and you're left with let's say 10 attack, you're losing the fight anyway. If you want you can throw in a third value in that max function, something like the value of Cobra's attack in the last available stage *1,1 to ensure that she's tougher than what you'd get in an level 3 fight (and I would expect that the EX fight won't even be available to us if level 3 isn't unlocked).
The part about coding I'll answer in a spoiler, since I want to be as comprehensive as I can, and that can lead to pretty long answers.