ID:265944
 
Alright, here's my idea:
- Have 40 different battle rooms
- The player limit being 40, or less (to prevent people from AFKing and hogging battle rooms - this might not be needed as it's not an anime game)
- Keep the empty battle rooms in a list
- When a player goes into battle, it cycles through each battle room in the list until it finds one the player can enter.

Is this the best way of going about it?
No, it's not.

Try something like SwapMaps instead - dynamic map loading will allow you to have an effectively infinite (Well, within memory limits) number of 'battle rooms'.
JP nailed it. Artificial limits are, well, limiting.

You should use some form of dynamic map loading/unloading to handle your instanced areas. This allows you to have as many rooms as are needed and removes the need for a hard cap on player population. It also should save in resource usage most of the time, assuming you would normally have less than 40 maps loaded at a given point in time.