Commit Graph

264 Commits

Author SHA1 Message Date
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
Guangcong Luo
12b673bb49 Fix style errors; update gulpfile
I used a hack to make the multiple declaration errors go away,
so all that remained in jsHint were actual errors, which I've
now mostly fixed.

All this linting ended up uncovering one actual bug: Uproar's
message not showing. It's a very minor bug in a move no one uses,
so I'm going to fold it into this commit.
2014-08-10 18:06:44 -04:00
Slayer95
3ea30b4790 Support searching for natures with /data 2014-06-14 22:54:08 -05:00
Slayer95
1b27d0879c Natures are now available in Tools.data 2014-06-14 19:53:00 -05:00
Slayer95
b025743d34 Global 'sanitize' is now 'escapeHTML' method of Tools 2014-05-12 20:52:29 -05:00
小太
5c8fc7b982 Space after function for anonymous functions 2014-04-22 01:58:16 +10:00
小太
6fb3bc332a Spaces around operators and === instead of == 2014-04-22 01:56:11 +10:00
Slayer95
2efe53ab05 Add missing semicolons and remove whitespace 2014-04-19 00:05:31 -05:00
Slayer95
3fc36ef80f 'clampIntRange is now a method of 'Tools' and no longer global 2014-04-18 15:14:54 -05:00
Slayer95
4c18aa60f1 Remove global 'fs' 2014-04-17 14:37:32 -05:00
V4Victini
93ad70d7dd Remove Pokeball from team data 2014-03-28 00:54:56 -04:00
Relados
7c537c8249 Allow aliases for formats
This will make it easier for tournament hosts to create tournaments for formats with extensive names
2014-03-26 19:31:41 -05:00
V4Victini
adbed9d633 Add pokeball field to sets 2014-03-26 15:48:27 -04:00
Guangcong Luo
15b0397143 Make team unpacker less susceptible to DoS 2014-03-09 15:04:40 -04:00
Ivo Julca
03a62165fb Fix crash when packing a team with custom mons 2014-03-06 18:38:43 -05:00
Ivo Julca
6757ff8110 Fix crash when parsing a team with custom mons 2014-03-06 18:22:53 -05:00