Commit Graph

113 Commits

Author SHA1 Message Date
Guangcong Luo
24571ea603 Fix misc errors found by LGTM 2018-10-28 05:04:30 -05:00
CheeseMuffin
7cbb19b879 Trivia: Update categories (#4891) 2018-10-07 15:26:48 -05:00
CheeseMuffin
1bc1e15e93 Trivia: Update levenshtein function (#4720) 2018-08-31 20:01:15 -05:00
CheeseMuffin
a7d0f52b8a Trivia: Don't allow voices to search questions (#4780) 2018-08-01 17:42:14 +09:00
Morfent
5dbe7b19d2
Fix crash in Trivia#askQuestion 2018-07-27 03:57:23 -03:00
Luke Vellotti
5428aa98a1 Trivia: Don't allow games to be started multiple times 2018-07-10 17:48:32 -05:00
Guangcong Luo
de3e0e11c7 Change Chat.count argument order
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.
2018-03-05 21:19:37 +09:00
Guangcong Luo
cad1165ad4 Implement Chat.count
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.
2018-03-05 20:57:25 +09:00
Charlie Kobayashi
331af4e794 Refactor Modlog Formatting (#3972) 2018-01-08 15:18:24 -06:00
Kris Johnson
a6ce5c9dc1 Refactor chat-plugins and formats to for...of (#4288) 2017-12-28 05:22:28 -06:00
Jeremy Piemonte
e0c08eafba Standardize help commands (#4285) 2017-12-27 19:35:32 -06:00
Guangcong Luo
0d43204487 Change room log API
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
2017-12-18 22:51:21 -06:00
Guangcong Luo
a9540917f5 Move fs.js -> lib/fs.js 2017-12-16 15:40:45 -06:00
Ben Davies
cf16bd480d Trivia: fix Trivia#formatPlayerList 2017-11-26 02:46:55 -04:00
Ben Davies
063cf68be3 Trivia: fix crash in category access 2017-11-17 17:12:06 -04:00
Guangcong Luo
340e61682b
Safe FS writing (#4145)
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.
2017-11-14 02:09:18 -06:00
Ben Davies
29b42fee6e Trivia: broadcast top 5 players on answer, start moving to Typescript 2017-11-13 20:02:51 -04:00
Guangcong Luo
ccac3add6e Make eslint rules stricter 2017-10-08 04:41:11 -05:00
CheeseMuffin
f46b9bb338 Trivia: Delete questions by ID (#4042) 2017-10-06 00:44:46 -05:00
Guangcong Luo
f5462fd535 Revert "Trivia: make searching results scroll (#4030)" (#4031)
This reverts commit 2aa8f12ea6.
2017-10-01 20:31:46 -05:00
CheeseMuffin
2aa8f12ea6 Trivia: make searching results scroll (#4030) 2017-10-01 19:14:21 -03:00
CheeseMuffin
333392505b Trivia: status command show player points (#3990)
* Trivia: status command show player points

* Reduce verbosity
2017-09-16 23:16:15 -03:00
CheeseMuffin
358f620522 Trivia: Only voices can submit in QW (#3978) 2017-09-16 11:49:32 -03:00
CheeseMuffin
f4f406c56d Trivia: Fix error messages (#3971) 2017-09-08 05:29:05 -04:00
CheeseMuffin
c086bb4887 Trivia: rename wl to wlink (#3943) 2017-09-02 03:52:07 -04:00
panpawn
fb63b334b8 Trivia: Remove weeklock alias from trivia command (#3941) 2017-09-02 02:42:49 +04:00
CheeseMuffin
7ba80db59e Trivia: New game, general improvements (#3784) 2017-09-01 05:28:35 -04:00
Ben Davies
8a4415f59f Trivia: fix game pause on player connect/disconnect 2017-08-19 03:44:33 -03:00
Ben Davies
32c9bf8ae9 Trivia: make game API more flexible 2017-07-17 05:41:51 -03:00
Ben Davies
92c6c3e3ac Trivia: fix crash in Trivia#destroy, pause when too many players absent (#3531) 2017-05-13 19:35:57 -05:00
Guangcong Luo
6dd58b40d3 Refactor simulator into new sim/ directory
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`
2017-05-05 16:48:38 -05:00
Ben Davies
fa3136f6f4 Prevent JSON writers from being able to block I/O (#3368)
These are the last place process.nextTick should be used. Also fixes
BattleRoom's unit tests.
2017-03-17 17:42:10 -05:00
Ben Davies
b0c117ce7a Trivia: mitigate game end/question timeout callback race condition (#3080)
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.
2017-01-07 04:13:19 -08:00
Ben Davies
b6118e0186 Trivia: only give UGM points for UGM category games (#3027) 2016-12-15 13:55:25 -08:00
Ben Davies
4f4c09e74c Trivia: fix race condition in Trivia#destroy (#3026)
The timeout for Trivia#askQuestion has the chance of ending after someone has
won the game or after forcing it to end.
2016-12-15 03:19:24 -08:00
Ben Davies
a04215bf17 Trivia: fix UGM random category games (#3012) 2016-12-11 03:23:24 -08:00
Ben Davies
ffe26e0506 Trivia: temp UGM activity toggle (#3011) 2016-12-11 04:34:25 -05:00
panpawn
76285471a0 Fix double errorReply while muted in some cases (#2830)
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.
2016-10-08 20:58:16 -07:00
Ben Davies
1446ec6deb Trivia: implement /trivia search command (#2820)
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.
2016-10-04 20:53:39 -07:00
Guangcong Luo
d6f5404e7e Rename CommandParser to Chat
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).
2016-09-30 18:31:15 -07:00
Guangcong Luo
da1b318707 Move text processing from Tools to CommandParser
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.
2016-09-30 18:04:13 -07:00
Ben Davies
4e9577a7e5 Trivia: modlog kicks and wins, clean up unit tests (#2740)
Unit tests were still not destroying a few users.
2016-09-08 02:37:21 -05:00
Ben Davies
237388e6f8 Trivia: adjust question database command permissions (#2717)
Drivers can no longer accept/reject questions, that now being the
responsibility of mods.
2016-08-27 01:34:32 -05:00
Ben Davies
12fee1fda9 Rooms: fix memory leak in safe file writer functions (#2698)
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.
2016-08-17 13:35:25 -05:00
Ben Davies
ee1659260c Commands: guard against constructor being the target in those that don't (#2685) 2016-08-09 21:51:42 -05:00
Ben Davies
343c67b15f Trivia: lazy loading for modules in unit tests (#2677)
This makes it possible to refer to globals normally defined in production in the
outermost scope of the trivia module without making unit tests throw.
2016-08-08 14:43:01 -05:00
Ben Davies
febba6b362 Trivia: add /trivia leave, lower answering period to 10 seconds (#2674) 2016-08-06 14:20:58 -05:00
Ben Davies
4d34ac3996 Trivia: fix crash in /trivia status, fix other trivial bugs (#2660)
- /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.
2016-07-31 23:59:38 -05:00
Ben Davies
d00ba49b1c Trivia: game management code rewrite (#2626)
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.
2016-07-31 18:29:51 -05:00
Guangcong Luo
8325f470b9 Remove Trivia plugin 2016-07-16 15:15:07 -06:00