Commit Graph

208 Commits

Author SHA1 Message Date
Ivo Julca
10bb83bf3c Improvements to command broadcast API
- Method `this.runBroadcast()` has been split from `this.canBroadcast()`.
It's now the only method handling command-usage and intended as the main API
for synchronous commands. Async commands will execute both separately.
Note that the `suppressMessage` parameter is now passed to `runBroadcast`.

- The semantics of `broadcasting` have been similarly split.
`this,broadcastMessage` will be set to a truthy value when `this.canBroadcast` is run.
`this,broadcasting` will only be set to `true` once `this.runBroadcast` is executed.
2016-04-02 15:46:13 -05:00
Juanma Serrano
77e0a17082 Update /git command: it's only node.js now
io.js has been merged into node.js anyway and all information leads to node.
2016-04-01 11:20:43 +02:00
Ivo Julca
f901bfe31e Fix data load in informational plugins
- Single-process `datasearch` requires mods.
- `info` requires Gen 6 data.
2016-03-31 16:50:50 -05:00
Ivo Julca
6173d622d4 Info plugin no longer requires mod data 2016-03-31 14:01:17 -05:00
Bär Halberkamp
0e206dcd42 Make /learn multiprocess using the same process as /ds 2016-03-31 15:59:36 +02:00
Ivo Julca
14d0716e7e Refactor Simulator to use the PM API
This removes Simulator.battles in favor of each process' tracking their own battles.
2016-03-23 02:44:46 -05:00
Ivo Julca
84d4f9dc83 Refactor /dexsearch and /processes to use the PM API 2016-03-23 02:44:34 -05:00
Bär Halberkamp
365462a85c Dexsearch: Correctly broadcast dexsearches 2016-03-20 04:43:42 +01:00
Guangcong Luo
e87fd32550 Refactor TeamValidator
The callback code in TeamValidator and the functions that use it have
been refactored to use Promises.

Pretty much all signatures have been changed, for instance:

    TeamValidator.validateTeamSync(format, team)
    -> TeamValidator(format).validateTeam(team)

    TeamValidator.validateTeam(format, team, callback)
    -> TeamValidator(format).prepTeam(team) // returns a Promise

Validators are no longer cached since they're really lightweight. They
contain a format and a Tools instance, and Tools instances are already
cached in Tools anyway. This saves a tiny bit of RAM in exchange for a
tiny bit of CPU time, but more importantly makes the code more
readable.

I'm introducing a new pattern/API for managing the parts of code with
child processes - their process managers are now at .PM and are now
opt-in, so you can use them synchronously without needing to spawn
any processes.

Fixes #2448
2016-03-16 09:43:59 -05:00
Bär Halberkamp
bc00dab2f2 Convert dexsearch.js to be multiprocess 2016-03-15 19:47:18 +01:00
Ivo Julca
66c00d29af Remove usage of String|Number methods implemented by Sugar.js
Implements Tools#toDurationString to replace Number#duration.
2016-03-09 16:55:40 -05:00
Ivo Julca
0281176fd1 Remove usage of Array|Object methods implemented by Sugar.js
Adds a dependency to shim Object.values until it's natively available.
2016-03-09 16:55:34 -05:00
Marty-D
c70bc2da94 Avoid all potential Thousand Arrows crashes from info commands 2016-03-07 21:45:29 -05:00
Ivo Julca
2b391ad824 Fix informational commands crashing for Thousand Arrows 2016-03-07 21:22:15 -05:00
Guangcong Luo
9111f2635f Split dexsearch off to its own chat plugin 2016-03-03 05:25:13 -06:00
Guangcong Luo
c97cadcb19 Implement /processes 2016-02-19 06:53:57 -05:00
Guangcong Luo
b665660608 Refactor for more ES6 features
Now that nodejs/node#3072 is mostly fixed, we can finally start using
Node 4+ features.

This refactor:

- uses arrow functions where appropriate

  Note that arrow functions still aren't used in Mocha, where `this`
  is sometimes meaningful.

  This also removes the need for .bind() nearly everywhere, as well
  as the `self = this` trick.

- refactors Validator and Connection into ES6 classes

- no longer uses Array#forEach for iterating arrays

  We strongly prefer for (let i = 0; i < arr.length; i++) because of
  performance reasons. Most forEaches have been replaced with for..of,
  though, which is 5x slower than the long-form loop but 2x faster
  than forEach, which is good enough outside of most inner loops.

  The only exception is tournaments, which is due for a more invasive
  refactor soon anyway.
2016-02-10 17:40:21 -06:00
Guangcong Luo
4ed4fd460a Improve /learn messages
Specifically, the message for `.sourcesBefore` is now much clearer.
2016-02-01 22:06:38 -06:00
Guangcong Luo
1da53454cb Validator: Support tradebacks in GSC
Joim's previous code apparently already did, but this implementation
does it correctly with the set-intersect system.

As an added bonus of correctly using the set-intersect system, it now
shows up properly in /gsclearn
2016-01-31 16:52:24 -06:00
Guangcong Luo
77c667f617 Fix /learn in past gens
`Tools.includeMods()` is unfortunately still massively broken and
unable to be loaded on-demand. This commit restores the old Tools
behavior of loading it at the beginning, which is horrible for
startup time but is the only way of fixing incorrect /learn
results in past gens.

The previous displayed message for 'sourcesBefore' in gen 1-2 was
also wrong.

This was, as far as I can tell, a mistaken interpretation of what
'sourcesBefore' means; possibly due to a past bug in its
implementation.
2016-01-31 16:52:23 -06:00
Guangcong Luo
351aff4dad Merge pull request #2399 from bumbadadabum/mafia3
Mafia updates
2016-01-29 02:08:45 -08:00
Guangcong Luo
117ef7c378 Improve colors for !dt, especially Dark Mode 2016-01-27 04:37:54 -05:00
Bär Halberkamp
602e0a62c0 statcalc: fix !statcalc with no target 2016-01-26 17:48:38 +01:00
Hidden50
7d2f8290d1 Fix /statcalc to round between applying modifiers
!statcalc gardevoir, spe 252+ scarf
Base 80 at level 100 with 31 IVs, 252+ EVs at +1: 427. (should be 246)
!statcalc gardevoir 252+ spe
Base 80 at level 100 with 31 IVs, 252+ EVs: 284.
2016-01-22 12:58:04 +01:00
The Immortal
97de9f1e53 Smogdex: Remove Hoopa-U special case 2016-01-21 22:55:52 +04:00
Teremiare
34b767a434 Clarify how to set EVs in /statcalc 2016-01-15 16:56:45 +01:00
Hidden50
d09fe0d459 changed /statcalc command to accept argument "252+"
/statcalc 252+ speed heatran
/statcalc 252+ev speed heatran.
The 2nd always worked, but the 1st should too. Now it does.
(Also fixed a typo in the command description.)
2016-01-14 20:43:30 +01:00
Quinton Lee
7b0c2abf8a Fix crash in /details 2016-01-13 02:46:22 -06:00
小太
cdbf7c8fdb Don't modify the original template when compiling learnsets for dexsearch
This broke the team validator on event pokemon if it was running in the
same process as the commands
2016-01-13 15:28:39 +11:00
Hector Garcia
330f9c6d67 Validate dexsearch results with checkLearnsetSync 2016-01-11 20:51:17 +00:00
Quinton Lee
7ab0143e16 Update /whois
When showing rooms that users are banned from, also show the names they were banned under
2016-01-10 16:50:33 -06:00
Guangcong Luo
9d245a1652 Revert "Revert "Remove explicit decimal radix from parseInt""
This reverts commit 55df20be60.
2016-01-07 18:45:50 -06:00
Slayer95
55df20be60 Revert "Remove explicit decimal radix from parseInt" 2016-01-05 12:56:32 -05:00
Bär Halberkamp
c254c663d3 Remove explicit decimal radix from parseInt 2016-01-05 17:35:12 +01:00
Konrad Borowski
81f602b8d8 Always use trailing comma for multiline objects 2016-01-01 00:20:07 +01:00
Hector Garcia
e8b94f1978 Enforce intended alternatives limit in /ds 2015-12-21 00:36:39 +00:00
Guangcong Luo
0e9eb64193 Add help for /rules 2015-12-19 04:12:31 -05:00
Quinton Lee
58d85bec38 Info: Fix typo in /help dexsearch 2015-12-14 14:39:21 -06:00
Guangcong Luo
a659f6733f Don't require HTTPS for images
Most images are hosted in places that already support HTTPS, so all
we need to do is transparently rewrite them to be protocol-local.

For the rest, I don't care enough to enforce HTTPS on them. At
least wait for browsers to complain more about it...
2015-12-12 20:52:56 -06:00
Ivo Julca
303155bdf3 Require HTTPS for images 2015-12-11 21:55:41 -05:00
Guangcong Luo
332a65f9c0 Convert some Users tables to ES6 Maps
Specifically, Users.users, Users.connections, and Users.pastUsers
are now ES6 Maps. In theory, this should be a minor performance
upgrade, but we still need to profile to make sure.
2015-12-10 11:52:26 -05:00
MonoHearted
fe1796dcbf Update info.js 2015-11-26 07:03:35 -08:00
The Immortal
0650ce9701 Info: Update /om 2015-11-25 20:58:57 +04:00
Ivo Julca
4aeb6917a0 Fix /data for natures 2015-11-23 17:18:08 -05:00
Ivo Julca
e2b0bf61be Report inexact matches in Tools#dataSearch 2015-11-21 02:37:48 -05:00
Juanma Serrano
8de8cdfa31 Avoid infinite loops on itemsearch command
This command was causing infinite loops that caused PS to die several times.
It was adding new elements on an array that was being looped at the moment for some reason.
The command seems to work better now, even though the functionality may be faulty, but it's prefered to causing an infinite loop.
We may need to revisit this command and change it for one that doesn't tries to use natural language.
2015-11-20 14:20:01 +01:00
Nineage
c10743d4e1 Add /isearch as an alias for /itemsearch 2015-11-15 17:06:25 -08:00
Marty-D
945e41a3d2 Fix crash in dexsearch 2015-11-09 15:37:50 -05:00
Ivo Julca
8629883279 Smogdex: support Giratina-O and CAP 2015-11-08 13:04:45 -05:00
Guangcong Luo
a918812201 Remove some unused variables
This cuts down on the number of exceptions for eslint
2015-11-07 23:05:55 -06:00