Stacking, damage building Debuff

Hey All! I'm trying to make a move that should apply a debuff. Then if used again it should check to see if the target has that debuff, apply a little more damage, remove the debuff and apply level 2 of that debuff.

How do I make an attack check to see if a target has a debuff already?

Thank you in advanced, and let me know if I can clarify anything.

I made a formula I thought should work in theory. But it didn't, not sure what's wrong, or maybe it's just not possible this way?:

b.state?(29)? a.mat * 1.75 b.removeState(29); b.addState(28);:b.state?(28)? a.mat * 2.5 b.removeState(28); b.addState(27);:b.state?(27)? a.mat * 3 b.removeState(27); b.addState(26);:b.state?(26)? a.mat * 3.5 b.removeState(26); b.addState(25);:b.state?(25)? a.mat * 3.5 b.removeState(25); b.addState(25);: a.mat * 1.5 b.addState(29);

Original thread: https://forums.rpgmakerweb.com/threads/stacking-damage-building-debuff.77512/