MV Looking for a way to check for multiple states

Right now I'm making this code to change a state if the state is stacked upon it.

if (!target.isStateAffected(agiup)) {
target.addState(22);
}

Basically I want it to check if it does not have these variables (Ie. agiup,agiup2,agidown,agidown2) then it would apply state 22.

In summary, I want it to achieve a state level up and level down system where states would stack and change the icon.

If anyone can help please let me know! Thank you!
JavaScript:
let sids = [1,2,3,4,5,6];
for (let i = 0; i < sids.length; ++i) {
    if (target.isStateAffected(sids[i])) {
        target.addState(22)
    }
}
something like this should work, there might be a cleaner way though.
something like this should work, there might be a cleaner way though.
thats a good use for array.some()
a problem with that approach is that any apply effects would happen for each state. however...

I want it to check if it does not have these variables
OP wants it to work if the battler does not have any of those states. so something like this should work
Code:
let sids = [1,2,3,4,5,6];
if (!sids.some(sid=> user.isStateAffected(sid)))
  user.addState(999);
I'm not yet really familair with array.some and NOT part is that I missed.
but I try to learn or keep learning as I did it similar way to my ocarina part
of erasePictures, so the result might be equal, but yours are cleaner.

the cleaner is better is the performance is better or faster to process =)
I'm not yet really familair with array.some and NOT part is that I missed.
but I try to learn or keep learning as I did it similar way to my ocarina part
of erasePictures, so the result might be equal, but yours are cleaner.

the cleaner is better is the performance is better or faster to process =)
one of some()'s features is that some will stop iterating once any element causes its callback function to return true.

in the case of your for loop, if you had states 2,3, and 5 on the battler, the loop would still run 6 iterations and it would apply the state 3 times.
but for some(), it would do an iteration for 1, do an iteration for 2, see that 2 causes the callback function to return true, and then itll stop and return true. the state would only be applied once because it never continues after the first element that passes passes
thats a good use for array.some()
a problem with that approach is that any apply effects would happen for each state. however...


OP wants it to work if the battler does not have any of those states. so something like this should work
Code:
let sids = [1,2,3,4,5,6];
if (!sids.some(sid=> user.isStateAffected(sid)))
  user.addState(999);
Hey this worked out pretty well, thank you I appreciate it.

Original thread: https://forums.rpgmakerweb.com/threads/looking-for-a-way-to-check-for-multiple-states.170451/