Commit Graph

1096 Commits

Author SHA1 Message Date
Ivo Julca
a09c0110b8 Destiny Bond: Add tests for exclusive counter and a minimal implementation 2016-11-19 14:17:08 -05:00
Ivo Julca
792548c01d Add test for Mega-evolution vs Pursuit order 2016-11-19 02:54:52 -05:00
Ivo Julca
78ab0bdf31 Implement Spectral Thief 2016-11-18 18:26:16 -05:00
Ivo Julca
34beddac3d Add test for bounced status moves affected by Prankster
So that UltiMario can be validated when it happens in CC:
http://www.smogon.com/forums/threads/3586701/page-33#post-7087589
2016-11-18 16:59:22 -05:00
Ivo Julca
1700067a77 Fix Judgment test 2016-11-18 15:14:27 -05:00
Ivo Julca
fbc88c8428 Fix Emergency Exit: It should block Volt Switch effect 2016-11-18 15:10:51 -05:00
Ivo Julca
c2f8c72b38 Judgment should not change type from Z Crystals 2016-11-18 15:09:21 -05:00
Ivo Julca
e97ccb3d48 Emergency Exit activation quirks are similar to Eject Button and Red Card
In particular, it only activates after all hits in a multi-hit move are performed, and
it won't activate if the move is boosted by Sheer Force.

This commit also implements the interactions of Emergency Exit
with Eject Button and Red Card, and adds tests.
2016-11-18 13:55:57 -05:00
Ivo Julca
5d04c4f2e0 King's Shield Atk drop now triggers even if immune 2016-11-18 12:48:50 -05:00
Ivo Julca
c8308ccd89 Sheer Cold no longer affects Ice-type Pokémon 2016-11-18 01:53:24 -05:00
Ivo Julca
511a45eb95 Implement immunity of Dark-types to Prankster
The immunity also applies to any moves, even non-Status, called by
other Prankster-boosted moves.
2016-11-18 00:35:52 -05:00
Guangcong Luo
382eeca94a Fix test error 2016-11-17 22:28:40 -06:00
Ivo Julca
e741700553 Test: Update the PRNG seed to make confusion self-hits more consistent 2016-11-17 23:09:04 -05:00
Ivo Julca
92c31e9d7c Test: Move old gen suites for statuses to the bottom 2016-11-17 23:09:04 -05:00
Ivo Julca
005287443c Add tests for new mega evolution & turn order mechanics 2016-11-17 20:57:29 -05:00
Ivo Julca
4fa6c5499b Build: Fix issues reported by the latest Eslint version 2016-11-17 14:27:39 -05:00
Ivo Julca
ddfe02efe3 Build: Fix Node v7 support 2016-11-17 14:20:33 -05:00
Guangcong Luo
b734d2f1c3 Make gen 7 the default mod
This makes gen 7 the default mod, updates the tests to match, and fixes
the corresponding build error.

Note that this only changes the default Tools mod, the default Formats
mod is now gen6. gen7 must be specified by name in a format, for that
format to be a gen 7 format.
2016-11-17 12:27:46 -06:00
QuiteQuiet
17a18e7a2a Tests: Update TeamValidator tests and add new ones (#2855)
* Tests: Add TeamValidator nature and happiness test

* Tests: Make TeamValidator test synchronous
2016-10-27 13:01:35 -05:00
Guangcong Luo
02055d3d17 Fix mod loading order
Sometimes mods would mess up if they were loaded in the wrong order.
Specifically, some autogenerated properties of e.g. moves need to be
recalculated for mods.

Anyway, the entire cache system is replaced with a newer, faster,
slightly-more-memory-intensive-but-only-slightly cache system, which
no longer has these kinds of loading order issues.
2016-10-23 14:17:13 -05:00
Guangcong Luo
7d8d47c97c Refactor BattleEngine
Battle is now an ES6 class... mostly... it's complicated.

Battle's inheritance system has always been a mess. I tried to redo it
in a sensible way but it caused nondeterministic test failures. Not
even kidding; different things would fail each time I ran tests, even
without code changes. I'll investigate closer later, but this refactor
makes it use ES6 classes with only a small amount of hacking, which is
good enough. It is, at the very least, simpler than the previous mess.

BattleEngine.Battle.construct has been renamed BattleEngine.construct.
2016-10-22 23:11:26 -05:00
Guangcong Luo
2604780ec5 Refactor Tools
Tools will be renamed to Dex soon, which is why the code inside Tools
is calling itself "Dex" now, but right now we're just refactoring its
internal code and not officially renaming it yet.

In the meantime, Tools is now an ES6 Class.

A long-standing bug in learnset loading order (the one
test/chat-plugins/datasearch.js tests for) has finally been fixed, so
Tools.includeMods() is no longer necessary to accurately access modded
data.

Tools.mod has been split into Tools.mod(modid) and
Tools.format(format). The issue of Tools.mod being ambiguous about
whether it's passed a mod or a format hasn't been a _bug_ for a while,
but this is still more readable.

Other renames include:

Tools#isLoaded -> Tools#dataLoaded
Tools.includeMods() -> Tools.includeModData()
Tools.preloadMods() -> Tools.includeMods()
Tools.preloadedMods -> Tools.modsLoaded
Tools.moddedTools -> Tools.dexes

Do not just rename your calls of Tools.includeMods() to
Tools.includeModData(). With the learnset loading bug fixed, there's
no reason to use it unless you need direct access to
Tools.dexes[...].data for some reason (you don't, just use
Tools.mod(...).data)
2016-10-21 13:23:21 -05:00
Guangcong Luo
87c41eb67c Rename simulator.js to room-battle.js
simulator.js doesn't actually contain the simulator, but is really just
an implementation of battles in the RoomGame interface.

Renames:
`Simulator.Battle` -> `Rooms.RoomBattle`
`Simulator.BattlePlayer` -> `Rooms.RoomBattlePlayer`
`Simulator.SimulatorManager` -> `Rooms.SimulatorManager`
`Simulator.SimulatorProcess` -> `Rooms.SimulatorProcess`
`Simulator.create` -> no longer exists, use `new Rooms.RoomBattle(...)`
2016-10-21 13:21:12 -05:00
Ben Davies
54d0ff203a Performance: replace direct references to arguments with rest parametres (#2818)
Replacing direct references to the arguments object of functions with rest
parametres prevents the function from being deoptimized while still allowing
use of arbitrary arguments. This may also fix some minor memory leaks related
to mishandling the arguments object.
2016-10-04 16:29:14 -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
Guangcong Luo
2bc0bf5061 Tests: Properly resolve rejected promise 2016-09-30 15:56:50 -04:00
Ivo Julca
ce9cdecafd Drop commands sent to rooms from outside 2016-09-17 19:42:15 -05:00
Ben Davies
d9c6fe54b2 ProcessManager: subclass to extend ProcessManager, unit tests setup (#2739)
Before, an options object containing properties and values to be used
was how decorated instances of the class would be created. This meant
the constructor could assign anything you feel like to `this`. Rather
than that, the constructor now assigns a strict set of values, and
methods are redefined in subclasses.

Basic unit tests were added to test if they could be written for after
the final refactor to fix the other memory leak here.
2016-09-09 15:51:49 -05: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
Taylor Everding
1a1f64fe95 Remove .js extension from requires (#2725) 2016-08-30 00:04:40 -05:00
Ben Davies
ecb00710a7 Trivia: dispose of extra users in unit tests (#2719) 2016-08-27 14:47:08 -05:00
Ben Davies
d88561b42e Trivia: properly dispose of trivia games in mode unit tests (#2718) 2016-08-27 02:39:22 -05:00
Guangcong Luo
4523078519 Refactor User#games from Map to Set
User#games no longer retains games; it instead gets them from
Rooms(roomid).game.

The Trivia tests needed to be fixed for fidelity to continue passing.
2016-08-27 02:16:58 -05:00
Guangcong Luo
1a1530f4ff Refactor Connection#rooms to Set
Connection#rooms, previously a null-prototype roomid:room Object,
is now Connection#inRooms, a roomid Set.

This, incidentally, makes it stop retaining rooms, which may make the
GC's job easier and may also lead to unexpected bugs if we get
inconsistent state (we often do get inconsistent state, so look
forward to that!)

The rename is mostly to put it in line with the new User#inRooms,
and for ease of greppability without running into Rooms.rooms.
2016-08-22 03:57:52 -05:00
Bär Halberkamp
55429ed884 Move modlog writing to Room.prototype (#2700)
* Move modlog-related functions to Room.prototype, instead of CommandParser

* Wifi: modnote the winner of a giveaway
2016-08-18 16:45:53 -05:00
Ben Davies
5c4834f3fd Tests: tweak user mocks, add Connection tests, fix Trivia tests (#2682)
Worker mocks now have proper ids. Trivia tests now dispose of user objects
rather than letting them stay in memory for the rest of the tests.
2016-08-09 04:02:27 -05:00
Guangcong Luo
34650dd455 Refactor Rooms.rooms and Rooms.aliases to Map 2016-08-08 16:46:11 -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
Taylor Everding
f6a7c4bd30 Move IPC from battle-engine.js to simulator.js (#2666) 2016-08-04 00:35:59 -05:00
The Immortal
76b6030043 Fix Relic Song 2016-08-04 03:41:15 +04:00
Ben Davies
0d2d73540d Trivia: add unit tests confirming if points given aren't NaN (#2661) 2016-08-01 15:03:04 -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
Marty-D
41e6945417 Add Electric/Misty Terrain messages 2016-07-20 14:05:25 -04:00
Konrad Borowski
bb3acda351 Copy auth from tournament room to tournament battle (#2608)
This allows room staff to perform moderation in tournament battles.
2016-07-06 07:28:47 -05:00
Ivo Julca
9d5e0e78a7 Resolve tournament matches on battle room expiry 2016-07-01 10:07:03 -05:00
The Immortal
a61e19b46a Tests: Remove unused const 2016-06-26 05:37:17 +04:00
Kevin Lau
5e3f1dcabc Tests: Update Weather tests for clarity and readability (#2596)
Updated remaining Primal Weathers to the new APIs.

Updated misleading test cases relating to base power of moves in
Desolate Land / Primordial Sea.

Increased coverage on weather tests.
2016-06-24 20:11:03 -07:00
Ivo Julca
f095ac4fea Implement Curse targetting glitch 2016-06-20 11:57:23 -05:00
Ivo Julca
ec572891a5 Fix typing information leak 2016-06-20 11:38:06 -05:00
Ivo Julca
59c667337b Refactor Team Preview to support per-Pokémon decisions 2016-06-20 10:49:21 -05:00
Ivo Julca
543bbf5ccc Refactor switching to support per-Pokémon decisions
- Implements `skip` choice, which acts as a placeholder in the player
choices. This is relevant to double-KOs, since in-game you are allowed
to specify switch-ins in any order.
2016-06-19 23:45:57 -05:00
panpawn
a331b5d41c Test: fix iteration index (#2594) 2016-06-20 05:25:52 +02:00
Ivo Julca
50fcd02b6d Tighten move validation
The target location is checked on chooseMove(), rather than
after the decision has entered the queue.
2016-06-19 07:53:58 -05:00
Ivo Julca
2861463b48 Test: Increase coverage of /undo
Among the added tests, are included:
- A skipped test for an edge case in which usage of Reflect Type
causes a typing information leak via the presence/absence of the
"maybe-trapped" warning and cancel prevention.
- Two skipped tests related to partial decisions functionality.
2016-06-19 05:49:23 -05:00
Ivo Julca
3b1749eccf Add basic support for per-Pokémon decisions
- Basically, support is added only for `move` requests here, and
behind a flag (`battle.supportsPartialDecision`).
- Switching is mostly supported, except for the multiple-KOs case.
- Team Preview needs a rework in order to enable this feature.
2016-06-17 12:26:56 -05:00
Ivo Julca
76604daf58 Test: Cover /team and /shift decisions 2016-06-17 11:48:07 -05:00
Ivo Julca
be8ba884c8 Test: Increase coverage of decisions 2016-06-17 08:48:22 -05:00
Ivo Julca
99f43ca2ef Test: Fix misc issues
Introduced in commits 69d9dc803 and 22c55e656
2016-06-17 08:41:58 -05:00
Ivo Julca
67da1a1221 Test: Use the new common#createBattle method
- This cuts down tons of code that define player names, avatars,
and deal with Team Preview.
2016-06-17 05:45:22 -05:00
Ivo Julca
22c55e6560 Test: simplify battle initialization with a common module 2016-06-17 05:44:33 -05:00
Ivo Julca
e69d9dc803 Test: Dramatically increase coverage of choice parser 2016-06-16 08:25:37 -05:00
Ivo Julca
b242e86c04 Test: rearrange tests for decisions 2016-06-16 08:22:07 -05:00
Ivo Julca
6ca2233657 Fix logging of passes 2016-06-15 10:02:52 -05:00
Ivo Julca
f2aff1b6ae Refactor tests to use the new assert/battle APIs 2016-06-15 08:56:29 -05:00
Ivo Julca
0be37dd2ce Split apart Battle#parseChoice into several BattleSide methods 2016-06-15 08:56:11 -05:00
Ivo Julca
2ab2937b3c Implement assert extensions to enhance the test suite 2016-06-15 08:54:18 -05:00
Ivo Julca
e5971f4f13 Test: Increase choice parser coverage 2016-06-15 01:28:06 -05:00
Quinton Lee
e08f7ef4c0 Test: add TeamValidator tests (#2546) 2016-05-04 16:33:16 -07:00
Bär Halberkamp
b450b0617f Move things relating to punishments to punishments.js (#2540) 2016-05-02 12:16:25 -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
kotarou3
952cefbad4 Minor crash guard changes (#2470)
- Remove unused crash guard comment
- Update Config.crashguard comment a bit
- Use Config.crashguard to disable it in tests
2016-04-17 02:15:17 -07:00
Kevin Lau
1c574c6c55 Critical Hit Ratio refactor: Use an event to modify crit ratios (#2501)
This allows for proper crit ratios when a Pokemon loses/gains an ability,
item, or other effect in the middle of a multi-hit attack.
2016-04-11 21:35:36 -04:00
Ivo Julca
bbb58d5a29 Add a test for old-gen /learn 2016-03-31 14:01:11 -05:00
Kevin Lau
715de49408 Refactor Anger Point to the Hit event handler
This fixes its interaction with Clear Smog because Hit handlers for
moves always activate before all other global event handlers.

Removed the Hit event from the list of events stopped by Mold Breaker
variants as there are no abilities that would be negated by it that
use that handler.
2016-03-23 20:23:42 -07:00
Kevin Lau
bfac338ddb Normalize doesn't affect moves that change type
The ModifyMove singleEvent for moves always runs before the
larger event that triggers an ability's event handler and
take precedence over Normalize, so we code exceptions in
Normalize to not change the type in those situations.

Conveniently, all the moves that change type right now are
defaulted to Normal-type, and since Normalize technically
won't change the type of any Normal-type move, we're using
that as the guideline for our exception.
2016-03-16 10:54:47 -07:00
Guangcong Luo
82ed5e0d22 Fix Levitate Flying Ring Target interaction 2016-02-19 17:23:21 -06:00
Guangcong Luo
8446e5fbc3 Fix Thousand Arrows Wonder Guard interaction
Thousand Arrows shouldn't add Smack Down if Wonder Guard avoids it.
2016-02-19 17:23:21 -06:00
Guangcong Luo
794d160eec Refactor runImmunity
BattlePokemon#runImmunity is now two functions, runImmunity and
runStatusImmunity.

The split is helpful because: 1. NegateImmunity only applies to type
immunities, and 2. Immunity only applies to status immunities and
Ground immunities.

Ground immunities are now entirely handled hardcoded in isGrounded.

This overall doesn't have a noticeable impact on performance, but
it makes certain things behave more predictably, and correctly
shows the ability activation for Levitate, so I assume that means it's
a net positive. I hope I at least improved readability...
2016-02-19 05:18:40 -06:00
Guangcong Luo
a8e8272bac Refactor types and remove ModifyPokemon
The unwieldy system that is typesData is now removed, and is replaced by
the array `types` and the string `addedType`, which track the same amount
of information in a much more efficient way. (Roost is now hardcoded, but
let's not talk about that.)

Incidentally, this now roughly matches client, which tracks typechange
and typeadd as volatiles.

This allows us to remove ModifyPokemon, which overall provides a 10%
performance increase. I was hoping it'd be more substantial, but oh well.
2016-02-16 23:42:37 -06: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
Kevin Lau
ab64569717 Fix Focus Punch bugs
By setting a handler to listen for the Hit event, Pokemon will now lose
focus properly when attacked by multiple Pokemon or by Nature Power.
2016-01-27 16:15:50 -08:00
Guangcong Luo
c7bb5b5315 Add RoomGame support for /joingame, /leavegame
The old commands /joinbattle, /leavebattle are now /joingame and
/leavegame, and can be implemented by any RoomGame.
2016-01-19 01:47:26 -08:00
Guangcong Luo
f094e4cf01 Fix Lightning Rod redirection priority
In speed ties, the pokemon that's had the ability the longest is
redirected to.

Fixes #2083

Closes #2154
2016-01-13 00:13:55 -08:00
Guangcong Luo
99a6e73df0 Mostly fix Curse targeting
Curse now correctly updates what target it asks for when the user
changes type.

The only remaining targeting issue is when the user changes to
Ghost-type mid-turn in Doubles.
2016-01-12 15:16:23 -08:00
Guangcong Luo
1e2bb4a9c5 Merge pull request #2371 from kotarou3/fix-repl-tests
Don't enable repl while testing
2016-01-12 02:29:57 -08:00
Guangcong Luo
331608da49 Fix Natural Cure message
In-game, you can see your opponent's pokemon represented as balls, with
statused pokemon being dark balls. Because of this, light balls are
clearly not statused, which allows you to know when a pokemon has
Natural Cure.

The only exception is in Doubles/Triples, where multiple pokemon that
are statused but could have Natural Cure switch out at the same time,
but not all of them have Natural Cure: it's not possible to know which
pokemon had Natural Cure.

This exception is now handled correctly.

Fixes #1452
2016-01-12 02:28:43 -08:00
小太
edb9d27262 Don't enable repl while testing 2016-01-12 20:44:27 +11:00
Guangcong Luo
573922f145 Give more control over when servers are spawned
Previously, include('./sockets.js') and include('./app.js') would
automatically spawn listener processes.

Now, you have to actually use .listen() to spawn listener processes.

This makes the testing framework simpler, since it no longer needs an
ugly hack to suppress spawning socket processes, and also makes it
easier for the ./pokemon-showdown "binary" to pass a port to app.js.

./pokemon-showdown will now also install dependencies if necessary.
2016-01-07 00:20:49 -06:00
Guangcong Luo
4898190cb6 Fix old pullreq for modern code style 2016-01-04 23:13:43 -06:00
Guangcong Luo
69934732ef Merge pull request #2130 from ascriptmaster/move-fixes
Refactor move redirection
2016-01-05 04:06:58 +00:00
Konrad Borowski
81f602b8d8 Always use trailing comma for multiline objects 2016-01-01 00:20:07 +01:00
Konrad Borowski
79a5b23f25 Modify data and mods files to follow style rules 2016-01-01 00:18:00 +01:00
urkerab
ba6dc7c5c0 Prevent IV values that represent half of a DV 2015-12-30 15:32:40 +00:00
Marty-D
bb7bfada94 Fix lingering issues from #2339 2015-12-28 15:09:32 -05:00
Marty-D
235e470553 Merge pull request #2339 from ascriptmaster/trapping
Trapping refactor
2015-12-28 12:10:52 -05:00
Kevin Lau
7c491ad06b Add test suites for trapping moves and abilities 2015-12-21 14:56:21 -08:00
The Immortal
d47c968ee6 Fix Magic Room interaction with Primals 2015-12-21 21:22:23 +04:00
Ivo Julca
c8df8c4e27 Test: increase timeout for Lightningrod Triples test 2015-12-21 05:41:56 -05:00
Ivo Julca
f5b3a3b875 Test: use mock-fs to sandbox the file system 2015-12-20 03:22:02 -05:00
Ivo Julca
1673f1fd9b Test: make player name sync regression test more robust
If Custom Game was configured as never rated (in order to e.g. give it an unrated ladder), it would yield bogus failures.
2015-12-20 00:18:23 -05:00
Ivo Julca
344e021700 Increase timeout for Pressure tests in Triples 2015-12-14 17:53:03 -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
Guangcong Luo
4e9a5a962f Merge pull request #2293 from ascriptmaster/trickroom
Refactor Trick Room and fix interactions with speed-based moves
2015-12-10 11:24:32 +00:00
Kevin Lau
64c8650713 Add tests for Trick Room and the TR Glitch 2015-12-09 15:52:21 -08:00
Ivo Julca
9116fea506 Fix config crashes possibly resulting in config reset 2015-12-04 01:01:50 -05:00
Ivo Julca
50c3f8f8aa Fix test for battle player identifier consistency after rename 2015-12-03 20:45:13 -05:00
Ivo Julca
47918a6d92 Replace remaining instances of var by block bindings 2015-12-03 19:45:35 -05:00
Guangcong Luo
341ab3b684 Refactor simulator.js to new RoomGame API
This is a huge refactor that's a half-scratch rewrite of simulator.js.

Everything seems to be working so far, but with such a huge change,
I wouldn't be surprised if something went wrong.
2015-12-03 18:30:47 -06:00
Ivo Julca
33386f79aa Test: increase time limit for redirection tests 2015-11-09 00:15:48 -05:00
Ivo Julca
7dddb66253 Migrate build system to ESLint
JSHint's ES6 support is shaky, and its development has stalled as of late.
Since ESLint can do by itself both JSHint and JSCS' jobs, this commit replaces them.
Gulp and its related dependencies are also hereby removed.
2015-11-07 21:36:49 -05:00
Ivo Julca
9a52fe337f Parse all numerical user input as base 10
Also took the chance to commit some style fixes missed in 90973d5 and 04c64c1.
2015-11-07 20:08:01 -05:00
Ivo Julca
04c64c143e Cleanup: remove several unused variables 2015-11-07 17:34:21 -05:00
Ivo Julca
90973d5c0c Style fixes
- Cut down excessive spacing
- Add braces to missing conditionals
2015-11-07 17:08:09 -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
b794d2ee09 Fix Travis CI build 2015-11-01 16:36:05 -05:00
Ivo Julca
e510d036fd Add tests for Curse targetting
Refs Zarel/Pokemon-Showdown-Client#354
2015-11-01 15:43:35 -05:00
Konrad Borowski
d9abb0eeb7 Poison/burn/leech seed don't increment residualdmg on start in Gen1
Previously moves like Leech Seed incremented residualdmg when used by 1,
but this doesn't actually happen in the game. Instead, an actual game
uses a flag to store toxic poisoning flag, and when it's not specified,
these statuses always dealt 1/16 of full HP.

This fixes the issue where the sequence of moves (Toxic followed by Leech
Seed) was dealing 1/16, 3/16, and 4/16 of full HP in residual damage,
instead of 1/16, 2/16, and 3/16.
2015-10-04 13:26:23 +02:00
Carl Sobolewski
4155771189 Test: Fire- and Water-related weathers modify damage correctly
These calculations would return 150 and 54 damage respectively prior to the
previous commit.
2015-09-13 03:23:01 -06:00
Carl Sobolewski
f1146dcac6 Weather modifies baseDamage instead of basePower
http://git.io/vZKFp
2015-09-13 02:43:39 -06:00
Ivo Julca
e2709e6213 Fix Travis CI build 2015-09-11 00:54:37 -05:00
Ivo Julca
3ae84997c9 Test: don't load chatroom data 2015-09-11 00:41:15 -05:00
Ivo Julca
234e87319b Test: don't write to file system 2015-09-11 00:40:22 -05:00
Ivo Julca
85379ff12e Test: don't listen for connections 2015-09-11 00:38:49 -05:00
Kevin Lau
449f0aaa16 Add test suite for Shield Dust 2015-09-03 03:10:13 -07:00
Kevin Lau
cc1f581c90 Refactor move redirection
Implemented a new priorityEvent function that is set to abort when any
event handler returns a non-undefined result, unlike runEvent which waits
until all event handlers have run. Set RedirectTarget to use this event.

Changed ability/move priorities for RedirectTarget handlers to fit under
this new paradigm.

Added new Lightning Rod and Storm Drain tests to ensure proper behavior.
2015-08-26 20:22:28 -07:00
Kevin Lau
1c70494e2b Fix Snatch and Imprison's interaction with Pressure
They target the user, but for the purposes of Pressure are treated as if
they target the opposing side.
2015-08-21 18:50:21 -07:00
Kevin Lau
e846fbb129 Fix Battle Armor and Shell Armor tests to no longer use the battle log
Instead, they can use Battle#on to check for the move dealing a critical
hit within the ModifyDamage event instead.
2015-08-12 16:02:12 -07:00
Ivo Julca
0a1cf02b9d Prevent login server requests in tests 2015-07-30 09:20:47 -05:00
Ivo Julca
2670d4d2ce Fix stray spacing style issues
These were not caught by the CI until the cache was deleted.
2015-07-29 15:34:42 -05:00
Ivo Julca
47263c8749 Fix players of rated battles getting out of sync on rename
- This removes one of the reasons of `sendFor` calls' sometimes failing.
- This also fixes battle logs so that they register the proper end type (forfeit).
2015-07-29 15:18:17 -05:00
Ivo Julca
cd36fbfde2 Gulpfile: add more JSCS rules
- Disallow spaces between function names and round brackets.
- Disallow spaces inside array/object literal brackets.
- Disallow spaces before semicolons.
- Disallow yoda conditions for equality.
2015-07-28 19:38:53 -05:00
Kevin Lau
9a7585c58e Add tests for Ice Ball/Rollout 2015-07-26 19:58:38 -07:00
Marty-D
d00ed0c5c5 Fix trailing whitespace from cf295251a1 2015-07-24 21:26:28 -04:00
Pikachuun
cf295251a1 Fix Flower Gift 2015-07-24 20:03:25 -04:00
Kevin Lau
b310eb00b9 Add Intimidate test for double-KOs 2015-07-19 16:54:55 -07:00
Guangcong Luo
0eb6f4b244 Merge pull request #2006 from ascriptmaster/move-fixes-2
Fix PP deduction interactions with Pressure
2015-07-17 13:40:19 -05:00
Kevin Lau
4da92ae00c Upgrade Follow Me test to check for self-targetting moves 2015-07-17 01:48:01 -07:00
Kevin Lau
913704c3ac Release and update Pressure tests
Added a check for Harsh Sun/Water moves failing and deducting PP.

Spikes has 32 max PP. Correct relevant values in the code.
2015-07-17 01:47:58 -07:00
Guangcong Luo
3bde6c758b Merge pull request #2050 from ascriptmaster/tests
Fix Mold Breaker interaction with Damp
2015-07-16 16:36:43 -05:00
Konrad Borowski
c0b71f03b7 Show that weather began even under Air Lock effect 2015-07-16 16:12:47 +02:00
Kevin Lau
e5beaba7bf Upgrade Sky Drop test to check for Follow Me 2015-07-16 04:24:07 -07:00
Kevin Lau
55f08be727 Add many Ability tests related to Mold Breaker 2015-07-15 14:48:57 -07:00
Kevin Lau
72b61b25d6 Update Intimidate test to ensure ability activation order
Re-do the activation test with the Pokemon switched to ensure that ability
activation was based on speed instead of player order.
2015-07-13 20:39:25 -07:00
Kevin Lau
604194e7d4 Normalize wording on tests related to Mold Breaker
The two most common wordings were "suppressed" and "bypassed". Out of the
two, "suppressed" was chosen to be used across all tests.
2015-07-12 03:27:11 -07:00
Kevin Lau
e991c70f4c Update Intimidate test to check activation order 2015-07-07 13:20:32 -07:00
Guangcong Luo
f67fd91590 Merge pull request #2037 from Slayer95/test
Add regression test for players being unable to join battles
2015-07-07 03:17:40 -05:00
Ivo Julca
43e20ebf24 Add regression test for issue described in b3b435c 2015-07-07 03:11:49 -05:00
Ivo Julca
b441375b5a Test: move utility functions to dev-tools/ 2015-07-07 03:08:18 -05:00
Kevin Lau
3c33a363fa Add Intimidate test to check simultaneous switches 2015-07-07 00:15:10 -07:00
Kevin Lau
70c8ca45ff Fix behavior with Ability activation in double-KO scenarios
Add new function battle.insertQueue that inserts a decision into the
correct position in an already-sorted queue instead of re-sorting. Also,
to prevent code reuse, add new funciton battle.resolvePriority to deal
with shared code between battle.addQueue and battle.insertQueue.
2015-07-06 20:33:40 -07:00
Guangcong Luo
9d79f72418 Merge pull request #1999 from ascriptmaster/move-fixes
Fix Quash interaction with self-switching moves
2015-07-02 07:34:06 +00:00
Kevin Lau
f7f310831d Improve tests relating to item removal 2015-06-28 16:47:12 -07:00
Kevin Lau
51f2cd93ff Fix Color Change test wording 2015-06-27 00:42:21 -07:00
Kevin Lau
020c08d5d9 Add tests for Color Change, Relic Song, Thief 2015-06-27 00:40:16 -07:00
Ivo Julca
fc89d5f372 Test suite is now deterministic 2015-06-26 21:55:43 -05:00
Kevin Lau
dafbefe973 Fix Sky Drop test pointing at wrong generation
It should be Doubles Custom Game, not [Gen 5] Doubles Custom Game.
2015-06-26 19:07:47 -07:00
Kevin Lau
5403862e43 Fix random failure in Sky Drop test
In Doubles, if a decision is not specified, it tends to choose the first
move but the intended target can be wrong.
2015-06-26 18:59:43 -07:00
Guangcong Luo
e35ed8ebd5 Refactor login
finishRename was a really huge function. This splits it into three
much more manageable functions with more useful names.
2015-06-25 04:43:34 -04:00
Kevin Lau
523ffe454b Add Sky Drop tests and pending Sky Drop glitch tests (for Gen 5) 2015-06-23 11:49:53 -07:00
Kevin Lau
d2eda4a375 Add Quash tests 2015-06-23 00:52:41 -07:00
Kevin Lau
d7b77a76a4 Mocha: Normalize oldgen descriptions for tests
Listing the generation number imitates the style used in PS! format names,
and is clearer on which generation it is than listing games from that gen
(so GSC -> Gen 2, etc)
2015-06-19 00:25:03 -07:00
Kevin Lau
8913271ea9 Merge pull request #1985 from ascriptmaster/tests
Further upgrade status move tests
2015-06-18 18:28:23 -07:00
Ivo Julca
8329e6f532 JSCS: fix crash in validateConditionals rule for empty blocks 2015-06-18 19:35:41 -05:00
Kevin Lau
85ee0961c1 Further upgrade status move tests
Steel-types are immune to the poison status in Gen 3+, so wrap it into the
"fail when the opposing Pokemon is immune to the status it sets" and set
up the poison-inflicting status test to check Generation 2.

Spin off Thunder Wave to its own test, and also create a test for Glare to
check its Generation 3 behavior as well.
2015-06-18 17:05:49 -07:00
Kevin Lau
9df3d0e42f Add Contrary tests for Mold Breaker and Belly Drum 2015-06-18 14:23:53 -07:00
Kevin Lau
ba35604c58 Add Sticky Hold and Knock Off tests 2015-06-17 15:39:32 -07:00
Kevin Lau
ba1f5df45c Release and improve pending Iron Ball/Thousand Arrows tests
Some tests had incorrect program flow that was resulting in incorrect
expected behaviors.

Improved the wording on some test descriptions.

Gave some of the Pokemon Shell Armor to negate test failures due to
critical hit messages appearing before the type effectiveness messages.
2015-06-16 00:11:08 -07:00
Kevin Lau
c5716272da Add Wonder Guard tests 2015-06-15 23:13:05 -07:00
Kevin Lau
34a0947eab Add Ingrain tests 2015-06-15 23:12:59 -07:00
Kevin Lau
4027fad468 Add working and pending tests for Pressure 2015-06-15 16:30:17 -07:00
Ivo Julca
21aebd070e Add pending tests for Iron Ball and Thousand Arrows 2015-06-15 04:48:15 -05:00
Ivo Julca
c08aba185b Implement JSCS rule to enforce switch cases not to be indented 2015-06-12 03:41:04 -05:00
Ivo Julca
b740197244 Implement JSCS rule to enforce PS conditionals' style 2015-06-12 03:36:36 -05:00
Kevin Lau
b8af0856f4 Add tests for type-immunity negating moves and items 2015-06-11 13:48:28 -07:00
Guangcong Luo
83a3540886 Merge pull request #1908 from ascriptmaster/tests
Add option for Mocha tests to use event handlers
2015-06-09 23:03:37 +00:00
Kevin Lau
6d76928ec3 Add Battle#on tests 2015-06-09 03:42:32 -07:00
Kevin Lau
26f88d2f89 Change weight tests to use the new event handlers 2015-06-09 03:42:27 -07:00
Kevin Lau
b59c53f886 Add tests for Levitate, Magic Guard, Sturdy, Focus Sash 2015-06-09 03:09:01 -07:00
Kevin Lau
d36ffabdd8 Add Belch Mocha tests 2015-06-03 20:04:17 -07:00
Kevin Lau
2d127ca355 Add Multiscale test 2015-05-31 05:05:07 -07:00
Kevin Lau
7607900160 Add Thick Fat tests 2015-05-31 03:54:41 -07:00
Kevin Lau
903295d642 Fix rare test failures from crits
Max damage critical hits would result in OHKOs.
2015-05-31 03:54:37 -07:00
Kevin Lau
c374656275 Add Unaware Mocha tests 2015-05-31 03:54:14 -07:00
Guangcong Luo
bc789f8d7f Merge pull request #1906 from ascriptmaster/tests
Battle Engine no longer sets EVs to 84 with blank EV sets
2015-05-30 02:00:09 +00:00
Kevin Lau
88827ff468 Fix hardcoded HP values for Mocha tests
Without the battle engine setting the HP EVs to 84, all HP values for
tests that involved set damage/healing were changed.
2015-05-29 11:32:21 -07:00
Guangcong Luo
066b1d6828 Merge pull request #1865 from ascriptmaster/move-fixes
Battle refactor: No longer reset ignore in Battle#update
2015-05-27 01:11:34 +00:00
Guangcong Luo
b7aa629703 Merge pull request #1889 from ascriptmaster/move-fixes-2
Battle refactor: New function isGrounded(), bug fixes
2015-05-26 07:09:19 +00:00
Kevin Lau
61996d3f6e Battle refactor: New function isGrounded(), bug fixes
Added BattlePokemon#isGrounded to check for the grounded-ness of a
Pokemon. Also BattlePokemon#isSemiInvulnerable for whether a Pokemon is
in the first turn of a two-turn move that makes them semi-invulnerable.

Fixed Terrain bugs involving Pokemon in a semi-invulnerable state.

Changed OHKO move check to use BattlePokemon#isSemiInvulnerable, fixing a
graphical bug that would display an immunity message when a Pokemon
attempted an OHKO move on a higher-leveled Pokemon that was being held by
the effect of Sky Drop.

Fixed Misty Terrain bug that was causing Rest and the effect of Yawn to
put Pokemon to sleep.

Fixed Misty Terrain bug that was causing Yawn to fail.

Fixed Electric Terrain bug that was causing Yawn to succeed.
2015-05-21 16:54:44 -07:00
Kevin Lau
c919f1504e Add and fix up Sheer Force, Rock Head, and Substitute tests
"Sheer Force should eliminate Life Orb recoil in a move with secondary
effects" would always pass even with wrong implementation because the
Sheer Force Pokemon being used was not holding a Life Orb.

Added tests related to Mummy to Sheer Force and Rock Head.
2015-05-21 13:52:01 -07:00
Kevin Lau
9851ef9838 Add tests for Klutz, Magic Room, Embargo 2015-05-18 02:44:42 -07:00
Kevin Lau
1f10dc1185 Add terrain tests, Arena Trap tests, Inverse Battle tests 2015-05-17 19:43:15 -07:00
Kevin Lau
a5bc0632b1 Upgrade Imprison Tests
Imprison should actively prevent the Pokemon from using imprisoned moves.
2015-05-14 14:18:07 -07:00
Guangcong Luo
8b7963e996 Merge pull request #1874 from ascriptmaster/tests
Upgrade tests
2015-05-12 06:25:38 +00:00
Ivo Julca
4222ffb5df Dependant support: make sure that relative paths are resolved properly 2015-05-11 15:38:18 -05:00
Kevin Lau
dd80e38322 Upgrade tests
- Improve the wording on tests for status moves to be more clear
- Add a test for Stealth Rocks
2015-05-10 15:40:52 -07:00
Guangcong Luo
383af9eea1 Merge pull request #1858 from ascriptmaster/move-fixes-2
Fix Rage Powder's interaction with Safety Goggles
2015-05-05 05:39:29 +00:00
Guangcong Luo
4f708b1240 Merge pull request #1849 from ascriptmaster/move-fixes
Refactor disabling moves, other miscellaneous bug fixes
2015-05-05 05:36:06 +00:00
Kevin Lau
4fe6fb16f4 Add mocha tests for moves and items that disable move choices 2015-05-04 21:16:52 -07:00
Juanma Serrano
0b7a0264e9 Add a Sheer Force test 2015-05-04 12:15:21 +02:00
Kevin Lau
b3f65f76a1 Add Follow Me and Rage Powder regression tests 2015-05-04 00:06:00 -07:00
Guangcong Luo
868ccb48c0 Merge pull request #1834 from ascriptmaster/tests
Fix up Desolate Land/Primordial Sea tests
2015-04-30 07:10:20 +00:00
Guangcong Luo
f8032a9a19 Merge pull request #1830 from ascriptmaster/move-fixes
Standard Weather always fails to activate when Primal Weather is active
2015-04-30 07:10:09 +00:00
Kevin Lau
6b1bedc706 Add some Cloud Nine tests 2015-04-29 00:25:51 -07:00
Kevin Lau
5f8ddde255 Fix Desolate Land/Primordial Sea to check for the correct event
Checking for damage could lead to off-by-one errors if the Pokemon are
different.
2015-04-28 02:47:56 -07:00
Ivo Julca
245f9bd8ac Hackmons: add failing test for choice parsing when a pokémon knows Struggle 2015-04-26 17:36:06 -05:00
Guangcong Luo
27f3ae2372 Merge pull request #1805 from ascriptmaster/move-fixes-2
Fix Flower Gift to properly use formeChange
2015-04-23 16:42:00 +00:00
Kevin Lau
1a285aa04e Add regression tests for ORAS Weathers 2015-04-22 15:59:23 -07:00
Guangcong Luo
dc9ba97551 Merge pull request #1790 from ascriptmaster/move-fixes
Have Burn calculate directly in getDamage
2015-04-21 19:30:42 +00:00
Kevin Lau
83bb400e0f Fix Thousand Arrows test
Zygarde's Thousand Arrows will KO Eelektross if it gets a critical hit,
meaning that the Weakness Policy being used to check if the move was
super-effective will not activate. Fixed by initializing the battle with a
seed that does not result in a critical hit from Thousand Arrows.
2015-04-20 12:43:28 -07:00
Juanma Serrano
06f5f5a360 Gen 1: Improve Haze tests
Add a test for removing volatiles as focus energy.
Add a test for removing screens.
2015-04-17 13:09:39 +02:00
Kevin Lau
5976efea2b Add Mocha tests for status effects 2015-04-16 15:50:11 -07:00
Guangcong Luo
8ef0d5c870 Merge pull request #1777 from ascriptmaster/tests
Add some regression tests for Substitute
2015-04-15 06:28:49 +00:00
Joimer
d46d5ca598 Properly add status immunity test
It must have its own case.
We must check Pokémon of a type with a status immunity are actually immune.
2015-04-15 01:24:58 +02:00
Joimer
7cec8b6831 Update statuses test
Test also Thunder Wave not paralysing a Ground-type
2015-04-15 00:29:07 +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
Kevin Lau
3632150521 Create some regression tests for Substitute 2015-04-13 15:44:53 -07:00
Ivo Julca
b9e972529b Actually make the regression tests meaningful
Also Boomburst did not exist before XY, and Uproar wasn't authentic either.
2015-04-13 02:25:34 -05:00
Ivo Julca
d367bf2650 Add regression tests for damaging moves affected by 58a5d91 2015-04-13 01:13:56 -05:00
Kevin Lau
f26b3fd279 Add type immunity tests in Mocha 2015-04-08 23:00:12 -07:00
Guangcong Luo
77b232ec25 Fix Substitute blocking foeSide moves
TryPrimaryHit, originally created for Substitute, is currently
being used for Substitute, gems, and auras. Neither of these
should affect all, foeSide, and allySide moves, so the event no
longer fires in these cases.

Included: Bonus: unit test for Substitute not blocking Stealth Rock
2015-04-03 22:48:24 -04:00
Marty-D
70e465157c Merge pull request #1656 from ascriptmaster/oldgens
Generation 4: Fix Transform's interaction with items
2015-03-26 18:23:59 -04:00
Ivo Julca
fe4eb481fa Simplify b6aea81 2015-03-24 14:37:23 -05:00
Ivo Julca
317389e2d2 Test: make sure that test server uses a clean port 2015-03-24 14:37:06 -05:00
Ivo Julca
03a8b03692 Test: remove unneeded tests for custom globals 2015-03-24 14:06:47 -05:00
Kevin Lau
a7d5199236 Add Regression Tests for Transform
Includes regression for Generation 4.
2015-03-21 19:03:38 -07:00
Kevin Lau
f60181ac91 Add Regression Tests for Weight-Based Abilities/Items/Moves 2015-03-18 18:39:01 -07:00
Kevin Lau
777b30b18f Add tests for Simple 2015-03-13 15:18:14 -07:00
Guangcong Luo
6f81899140 Fix typo in /joinbattle error 2015-03-03 04:10:27 -05:00
Guangcong Luo
8f81cfa4de Run tests on port 18003
Port 18003 was chosen at random, but the point is not to use the same
port as PS itself is running on.

This might not be the best approach, but it probably at least beats
running it on the port in config.js and conflicting with an active
PS process.
2015-03-03 01:52:50 -05:00
Kevin Lau
76484211b0 Update Unburden test
Using Leaf Storm gave the test a 10% chance to fail if it missed.
2015-02-26 12:27:31 -08:00
Kevin Lau
7cb80c7937 Add Item Removal tests
Added tests for Unburden, Pickup, and Mail.
2015-02-25 19:13:33 -08:00
Konrad Borowski
e7ac57c392 Initialize Haze test with values that don't fail.
Thunder Wave has a small chance to miss, setting seed to value that I
know doesn't fail the test fixes the problem.
2015-02-21 21:17:01 +01:00
Guangcong Luo
f874040753 Merge pull request #1546 from xfix/gen2-leftovers
Leftovers heal after switching in in Gen2
2015-02-21 13:00:18 -06:00
Konrad Borowski
815909eff2 Don't skip residuals after fainting in Gen2.
The original code was wrong, as all it did was skipping residuals.
Skipping moves is handled by `faintMessages`.
2015-02-21 11:37:39 +01:00
Slayer95
7e1a5145f0 Merge pull request #1545 from xfix/flameorb-test
Create Flame Orb test
2015-02-20 20:57:28 -05:00
Konrad Borowski
3446730787 Create Flame Orb test
Killing Focus Sash Magikarps with one attack is so amazing.
2015-02-20 12:15:42 +01:00
Guangcong Luo
4136f7a248 Merge pull request #1544 from xfix/knockoff-test
Create test for Knock Off.
2015-02-20 04:50:56 -06:00
Konrad Borowski
24c347f2e4 Create regression test for Haze (#1438). 2015-02-20 11:12:05 +01:00
Konrad Borowski
b4be85169c Create test for Knock Off. 2015-02-20 11:07:39 +01:00
Ivo Julca
03bbd985fc Test: add some tests for Magic Bounce 2015-02-19 19:52:23 -05:00
Ivo Julca
68aaa48974 Gulpfile: no files are exempt from style checks
- Streams are merged to make sure that all errors and warnings are reported.
- Adds dev dependencies: `merge-stream` and `lazypipe`.
- Tracks a fork of `gulp-jshint` to fix https://github.com/spalger/gulp-jshint/issues/88
2015-02-18 19:51:15 -05:00
Ivo Julca
5508777d97 Add first few battle simulation tests 2015-02-15 13:35:43 -05:00
Ivo Julca
18ee206833 Add some basic application tests 2015-02-15 13:28:03 -05:00
Ivo Julca
88c74abe76 Implement Mocha-based test suite 2015-02-15 13:27:36 -05:00