This is purely a readability change; behind the scenes there's now more
magic going on, but magic is good for text processing functions, which
are otherwise way too verbose.
Adds some more magic to make Chat.plural more readable when used to
count things.
Overall, it's not _nearly_ as concise as I'd like, but it might be the
best we can get for now.
Interaction with room logs is changing to be more straightforward. This
is the first step of the change, which changes rooms.js.
- Rename: logEntry -> roomlog
- Rename: sendModCommand -> sendMods
- Rename: addLogMessage -> addByUser
- New function: sendModsByUser
The long-term plan is documented in:
https://github.com/Zarel/Pokemon-Showdown/pull/3972#issuecomment-352226219
Writing program state to a file is fairly hard to do safely, especially
with Node's async FS writing. PS previously reimplemented in several
places the code necessary to do it safely. FS().writeUpdate now
consolidates that code so anyone can easily safely update a file.
This is a surprisingly minor refactor considering how many files it
touches, but most of this is only renames.
In terms of file renames:
- `tools.js` is now `sim/dex.js`
- `battle-engine.js` is now `sim/index.js` and its three classes are
in `sim/battle.js`, `sim/side.js`, and `sim/pokemon.js`
- `prng.js` is now `sim/prng.js`
In terms of variable renames:
- `Tools` is now `Dex`
- `BattleEngine` is now `Sim`
- `BattleEngine.Battle` is now `Sim.Battle`
- `BattleEngine.BattleSide` is now `Sim.Side`
- `BattleEngine.BattlePokemon` is now `Sim.Pokemon`
This isn't very easy to reproduce, so I can't properly test any fixes.
Trivia#broadcast writes to debug monitor rather than throwing if called after
the game instance destroys itself.
Due to the recent refactor that changed how `this.canTalk` works, if a user was muted in a room, and then tried to do a command that wasn't allowed to be used if they can't talk, it would send two replies: "You are muted and cannot talk in this room." AND "You cannot do this while unable to talk."
This makes it so that if you're using a command while muted that isn't allowed to be used if you can't talk, it will just use the "You are muted and cannot talk in this room." errorReply.
Now users can search for questions/submissions without having to rummage
through the entire list of questions. Trivia data and its writer are exported
once more so edits can be made to it with /eval if necessary.
We had a lot of discussion in Dev and a somewhat-close poll, but in
the end "Chat" was a better name than "Messages", and also has the
advantage of being shorter (which is nice for Chat.html and
Chat.plural which should be short).
The following functions have been renamed:
- Tools.html to CommandParser.html
- Tools.plural to CommandParser.plural
- Tools.escapeHTML to CommandParser.escapeHTML
- Tools.toDurationString to CommandParser.toDurationString
- Tools.toTimeStamp to CommandParser.toTimestamp
(notice the lowercase 's')
This is in preparation for a rename of Tools to Dex (by removing the
non-dex-related functions) and a rename of CommandParser to either
Messages or Chat.
The writer functions held circular references to themselves due to their
finishWriting closure. Because the bug that required making an exception
for how files are written on Windows was fixed 4 years ago now
(nodejs/node-v0.x-archive@41f2725), it's perfectly safe to remove the closure
and break the reference.
- /trivia status no longer crashes if a username is provided as a target
- Timer mode no longer gives users scores of NaN
- /trivia start no longer displays that the game is starting in 30000 seconds,
- rather than 30 seconds
- Questions no longer appear as escaped html during games
- Corrected misleading documentation on why the noop methods of trivia exist.
Part 1 of the rewrite for the entire plugin
This is the rewrite of the classes and commands that handle running
trivia games. Several bugs that happened when running trivia games were
fixed, and unit tests were added to help keep them gone.