Commit Graph

297 Commits

Author SHA1 Message Date
Guangcong Luo
07a1ca043a Stop shimming Array#includes
Our minimum requirement is now Node 6, which has native support for
Array#includes, so we no longer need to shim it.
2016-09-24 13:50:59 -07:00
urkerab
1a191a696a Allow the banlist to specify a numeric limit of team properties (#2773) 2016-09-24 12:35:57 -07:00
urkerab
b507af3cc4 Report complex bans using the original text (#2528) 2016-09-15 17:02:12 -07:00
Taylor Everding
1a1f64fe95 Remove .js extension from requires (#2725) 2016-08-30 00:04:40 -05:00
Marty-D
136ab7a3d2 Fix Tools.html 2016-08-29 15:16:03 -04:00
Guangcong Luo
54b672fe4e Start refactoring for template strings
This commit introduces Tools.html and Tools.plural, helper functions
for string construction.

Tools.html is a template tag function that escapes HTML inside the
template string.

Tools.plural is a helper function that takes a passed Number, Array,
Set, or Map and returns a string representing whether or not it's
plural.

It also starts doing some refactors of some files to make it clear how
I expect code style for template strings to look.

Previously, we used ' for IDs, " for English text, and ' for code.

We should now be using ' for IDs, ` for English text, and ` for code.
2016-08-28 04:35:43 -05:00
Guangcong Luo
bfa4e75c90 Add more guards for 'constructor' in Tools 2016-08-12 18:45:15 -04:00
Guangcong Luo
1cc6f39558 Fix bug in Tools.getTemplate('constructor') 2016-08-08 23:52:00 -05:00
Guangcong Luo
0cd4f5ad6b Fix another 'constructor' crash 2016-08-02 04:08:21 -04:00
Ivo Julca
af0fcd9a10 Tools: Add a Tools#installFormat method 2016-06-17 02:16:01 -05:00
Guangcong Luo
dbc88ee99f Fix comment spacing in tools.js 2016-06-09 04:19:50 -04:00
Marty-D
874ab9fb99 Support Berry names without an alias 2016-06-08 11:53:51 -04:00
Ivo Julca
ea9046ae0e Tools#getSpecies: Properly handle non-string argument 2016-05-13 21:37:59 -05:00
Ivo Julca
765f88559e Make shimmed Array#includes configurable 2016-05-13 20:55:34 -05:00
QuiteQuiet
63955aabd8 Add support for alternative models (#2539)
* Add aliases for alternate sprites

* Add support for alternate models for Pokemon
2016-05-04 11:20:50 -07:00
Guangcong Luo
4a995350bb Shim Array#includes
This also refactors everything to use Array#includes except data
and mods, which are large enough that I'll refactor them later
probably.
2016-05-04 02:55:18 -07:00
Ivo Julca
22779102cc Lint: Add miscellaneous extra rules
Among the newly added rules, there are quite a few intended to enforce
compliance of CONTRIBUTING.md-blessed idioms, as well as ensure
safe usage of classes and constant bindings.

We are also now enforcing usage of early return in commands.js,
which has 100% compliance as of fd2c45c.
2016-04-25 21:52:21 -05:00
Quinton Lee
dfa2ca22ae Add hh:mm:ss option in Tools#toDurationString (#2493) 2016-04-08 07:14:48 -05:00
Guangcong Luo
982b6eb8eb Fix style error 2016-03-21 14:08:24 -05:00
Guangcong Luo
52cc7f2e37 Remove Object.values external dependency
An external dependency is kind of overkill when the only
implementation we need is three lines.

This also lets us write a more performant implementation that
omits the parts irrelevant to us.
2016-03-21 10:15:55 -05:00
Ivo Julca
3a8e58c966 Revert "Forcibly replace Object.values implementation from Sugar.js"
This reverts commit 3cce56f as it is no longer needed.
2016-03-21 02:22:01 -05:00
Guangcong Luo
a125a3ed7b Remove sugar-deprecated 2016-03-16 09:51:23 -05:00
Ivo Julca
3cce56f6d2 Forcibly replace Object.values implementation from Sugar.js 2016-03-10 17:18:53 -05:00
Ivo Julca
12e9ca78da Remove usage of Date|Function methods implemented by Sugar.js
Implements Tools#toTimeStamp to support Node.js builds without ICU support,
which are currently the default. If/when that changes, we should be able to
use Date#toLocaleDateString, given that appropriate locale options are used.
2016-03-09 16:55:47 -05: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
Ivo Julca
bc1a46eee1 Deps: Deprecate sugar extensions 2016-03-09 16:31:44 -05:00
Guangcong Luo
75da4645c0 Add basic name filter
This filters out characters commonly used for impersonation. It's
based on the one used in Main, but now the rest of you can enjoy it
too!

This also filters zalgo and other annoying characters out of pokemon
names as well as usernames.
2016-02-16 03:46: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
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
Guangcong Luo
8495dafe69 Make tools.js stand alone
tools.js no longer needs sugar and a toId definition included externally,
which should make using it in scripts a lot easier, as well as cut
down the repeated toId definitions in every PS process.
2015-12-24 02:55:52 -06:00
Guangcong Luo
30a3138a48 Ban RTL control characters from nicknames 2015-12-03 18:30:47 -06:00
Guangcong Luo
4d2b23a9a4 Change data loading order
Pokedex is now first.

In theory, this has zero consequences, but it prepares for a future
refactor that fixes some mod loading issues.
2015-11-24 10:08:13 -05:00
Ivo Julca
f504765852 Automatically parse aliases for Mega/Primal formes
Mega-Species and M-Species are now equivalent to Species-Mega.
2015-11-21 02:40:06 -05:00
Ivo Julca
e2b0bf61be Report inexact matches in Tools#dataSearch 2015-11-21 02:37:48 -05:00
Juanma Serrano
c4ac8d6e2f Use strict mode and let and const instead of var
This commit also fixes some duplicated variable declarations.
2015-11-06 21:56:52 -05:00
Ivo Julca
1a8c51e9a9 Consolidate Pokémon forme validation
- Introduces `battleOnly` to Pokémon formats-data to flag which formes are forbidden on battle start.
- Adds back Secret Sword as Keldeo-Resolute's required move.
- Introduces `requiredAbility` to handle Darmanitan-Zen.
- Introduces `forcedForme` to items' data to flag the formes that some items enforce.
2015-10-20 23:13:32 -05:00
Ivo Julca
cd99d41f58 Fix library mode 2015-08-21 10:42:28 -05:00
Ivo Julca
14af193c91 Fix Pokémon data corruption in old gens
Ensure that mods are loaded before any `Tools.getTemplate` call.
2015-08-09 07:17:41 -05:00
Ivo Julca
2c6ca3ef1e Throw early error if a format requires a non-existent mod
This is possible now that the list of mods is loaded just before the formats, and makes debugging PS mods issues much easier.
2015-08-06 00:58:46 -05:00
Ivo Julca
6800e497d9 Refactor Tools to support partial load 2015-08-06 00:58:36 -05:00
Ivo Julca
f9b660bae6 Support toggling format availability for tournaments 2015-07-16 13:00:19 -05:00
Ivo Julca
c1e452ea59 Improve error handling in tools loading
- Isolate try-catch blocks
- Throw meaningful early errors wherever possible.
2015-07-14 21:54:37 -05:00
Ivo Julca
e3a8bbb897 Isolate try-catch blocks in Tools load 2015-07-14 02:06:23 -05:00
Ivo Julca
ac41d54c64 Revert removal of scripts installation on Tools
It breaks team validation (tools.gen no longer exists).
2015-07-10 17:45:39 -05:00
Ivo Julca
cee748b28d Shrink needlessly long prototype chains for battles
Properties should now be searched in this order:
- Instance
- Scripts installed
- Battle.prototype properties
- Tools properties
- Object properties
2015-07-09 00:48:53 -05:00
Ivo Julca
32c120fab1 More lightweight implementation of nature data 2015-07-06 04:03:16 -05:00