Commit Graph

279 Commits

Author SHA1 Message Date
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
Ivo Julca
e92bb1b07f Rename globals toName|toString to Tools.[getName|getString] 2015-07-06 00:34:44 -05:00
Ivo Julca
7810613776 Fix formats getting corrupted if loaded as rules from different mods 2015-07-02 07:48:54 -05:00
Ivo Julca
f18eef39ca Fix Travis build 2015-06-12 03:41:22 -05:00
SolarisFox
29b961ff69 Style fix: indexOf() comparisons 2015-05-18 15:55:57 -07:00
Joimer
0b43420727 Fix Thunder Wave hitting Ground-types
Since move.ignoreImmunity was defined as `false` for Thunder Wave, the statement !move.ignoreImmunity would always evaluate to true.
This would lead to move.ignoreImmunity being true for all status moves.
This commit fixes that problem, checking if the property was not defined as opposed to anything JavaScript deems `false`.

Related: 2e56120ad9
2015-04-15 00:29:09 +02:00
Guangcong Luo
54947b665f Merge pull request #1728 from ascriptmaster/move-fixes
Move refactor: moves/items that ignore immunity/effectiveness
2015-04-14 17:05:22 +00:00
Ivo Julca
c534abb6d5 Remove all fs.existsSync calls
They have been officially recommended against for a long time
2015-04-11 21:47:32 -05:00
Kevin Lau
2e56120ad9 Move refactor: affectedByImmunities -> ignoreImmunity
While move.affectedByImmunities was always a Boolean value to denote if
the move was affected by immunities, move.ignoreImmunity can be a Boolean
value if it ignores or is affected by all type immunities, but also can
act as an object such that !!move.ignoreImmunity[type] means it ignores
immunities of that type.
2015-04-08 00:17:12 -07:00
Morfent
ce1724e179 Replace all s.substr(x, 1) with s.charAt(x) 2015-04-06 21:20:43 -03:00
Marty-D
1f689e7e69 Make sure moves have the flags object 2014-12-16 12:39:43 -05:00
Marty-D
fdc3d9f570 Fix several item mechanics.
- Griseous Orb, Plates, Drives, and Mega Stones can no longer be removed
from or given to their respective species by any means
- Mold Breaker and friends can no longer remove a Plate from an Arceus
- The Fling base power for these related items is now defined in Tools,
like Berries
- Sticky Hold works correctly with Bestow, Fling, Knock Off, Switcheroo,
and Trick
2014-11-13 15:51:28 -05:00
Ivo Julca
ddf3767411 Fix Inverse Battle
- Immunities turn into weaknesses (I don't know how I could forget that).
- Tools#getImmunity is now similar to Tools#getEffectiveness. Also add a bit of documentation, since there seems to be a lot of confusion about its usage.
2014-10-28 17:51:41 -05:00
Ivo Julca
727579ff89 Revamp effectiveness calculation
- Implement BattlePokemon#runEffectiveness, accounting for battle events.
- Refactor Tools#getEffectiveness accordingly.
- Remove Inverse mod. It's now implemented using the global event 'Effectiveness', and with a few changes in the base data for hazards and Arena Trap.
- NEXT: Fix Filter and Solid Rock not accounting for the special effects of Freeze Dry and Flying Press.
2014-10-27 03:46:32 -05:00
The Immortal
a8689a5a10 Primal formes can't be used directly 2014-10-18 13:31:03 +04:00
小太
5027be79fb Add jscs as a style checker, and add some extra jshint options 2014-09-29 18:38:01 +10:00
Ivo Julca
b4ec88610f Properly load banlist tables for modded formats
They are no longer loaded in Tools.getFormat, which could be called from any modded tools and cached the bans.
2014-08-24 22:24:09 -05:00
Ivo Julca
6a9497b53c Use shallow merges to load mod data 2014-08-24 19:15:53 -05:00
Guangcong Luo
2e8ffb0d50 Lazy load mods into Tools
mods are now loaded the first time Tools.mod() is called, rather
than during startup.

This has two effects:
1. Significantly faster startup
2. Less RAM usage on main process, which never uses Tools.mod()
   at all

Sadly, the amount of RAM saved is pretty insignificant on main,
but it could be nice for smaller servers.
2014-08-20 20:31:32 -04:00