Redir used user.can as a way to stop lower auth from rediricting to
higher auth to other rooms.
However, if a user had auth over another user in a private room, this
user could redir the other user even if the latter had higher global auth
and/or was not in the room.
This commit fixes that, checking if a user is inside a room before being
able to use redir on they.
With the 0 PP behaviour fixed, there is no need to keep partial trapping moves banned, since the game changing struggle lock on 0 pp sequence is no longer there.
Now, most rooms inherit auth from global auth. In other words, if
you're a global driver but a room leader, you'll be a leader
in that room, but if you're a global driver but have no room
auth, you'll be a room driver.
The exception is private rooms with private auth: These don't
inherit, and in general are not bound by chat rules, so /warn
doesn't work in these rooms at all.
Use splice on the numerical arrays instead of delete to be sure no null is being saved as a room, since JavaScript will leave the null in the middle of the array instead of removing it, causing it to be saved on the file.
If someone tries to list the rooms in the exact moment it's being deleted and before chatRooms is updated, getRooms will crash. Additionally, a leftover empty room name will crash on construct when the index is still accessible but the data has been deleted, ie. it's saved as "null" if the room data is saved before the garbage collector ultimately destroys the deleted data.
In gen 1, previous to this fix, when you used the last PP of a partial trapping move you couldn't continue the sequence and would be forced into Struggle. This fixes it.
Add a command that deletes a chat room. It will first kick out all the users, try to delete all its data, and then write the result on the rooms json file, deleting it.
Sometimes a userid will be empty and it will crash the server. The first check on the function should be enough to be sure the room exists, this check further ensures that the command won't crash.
Due to how validateSet and scopes work, STABmons needs either this 2 line hack or to copy basically all moveset check to formats, duplicating code, for it to work.
The function getNextGroupSymbol now takes an extra parameter to exclude room only ranks, which are defined in config.
The function will try to find the closest non room only rank with a safeguard against maliciously or badly crafted config.js to crash the server.
If no rank is found regardless of room only or not status, the first or last rank are returned accordingly.
This refactor allows getNextGroupSymbol's name to keep true to its functionality, while also providing a way to exclude crafted ranks for rooms or otherwise from the global demote/promote scheme.
Now Leader demotions go straight to Moderator, and Moderator demotions go straight to Leader. The ranks are hardcoded because both the symbol and name are subject to change, so there is no safe way to get the symbols from config.
The command now works as intended, test:
Popsickles was promoted to Leader by Joim.
(Popsickles was demoted to Voice by Joim.)
Popsickles was promoted to Driver by Joim.
Popsickles was promoted to Moderator by Joim.
(Popsickles was demoted to Driver by Joim.)
(Popsickles was demoted to Voice by Joim.)
Popsickles was promoted to Driver by Joim.
Popsickles was promoted to Moderator by Joim.
Popsickles was promoted to Leader by Joim.
(Popsickles was demoted to Moderator by Joim.)
Popsickles was promoted to Leader by Joim.
Popsickles was promoted to Administrator by Joim.
(Popsickles was demoted to Leader by Joim.)
(Popsickles was demoted to Moderator by Joim.)
This should make Rock Wrecker and Roar of Time match the readme description: "Recharge moves are similarly buffed. They have 75 base power, always crit, and they only recharge if they KO. Be careful - in return for a KO, they still give the foe a free switch-in and a turn to set up."