Checking if all enemies have a state at the same time?

Hello,

I was wondering if anyone could help me with script call that checks to see if the enemy party all have the same state on them. 

For instance, I would like to run an event that turns on a switch whenever the entire enemy party (that's alive) is inflicted with the poison state.
There's probably a better way:

Code:
$game_party.alive_members.size == $game_party.alive_members.select{|member| member.state?(id)}.size
where id is the id of the state (no leading zeros)
Thanks for the response Shaz. However, I'm not really following. I also have a parallel process that's tracking "$game_party.alive_members.size" during battle. It basically sets the number of alive enemies to a variable. Will your example mess that up?

And would this be used in a conditional branch as well?
You can directly query whether all alive members (of the enemy troop) have the specified state ID using

Code:
$game_troop.alive_members.all? {|mem| mem.state?(STATE_ID) }
Got it. Thanks Hime.

Original thread: https://forums.rpgmakerweb.com/threads/checking-if-all-enemies-have-a-state-at-the-same-time.37539/