Commit Graph

255 Commits

Author SHA1 Message Date
Ivo Julca
7d1ee5fecd Confusion still has a 50% self-hit chance
Hypothesis of chance=1/3 can be rejected at a 0.0005 significance level.
2016-11-27 19:11:58 -05:00
Ivo Julca
2604dd1939 Trim megaOrZ argument of BattleSide#chooseMove() 2016-11-27 00:23:19 -05:00
Ivo Julca
318ca6ae9f Fix Destiny Bond 2016-11-25 15:38:25 -05:00
Ivo Julca
a14d1cc1f2 Add test for turn order for Mega Evos with Trace 2016-11-24 22:42:03 -05:00
Kevin Lau
7963c97894 Fix priority issues with Z-Moves (#2930) 2016-11-21 14:32:31 -05:00
Ivo Julca
cf35c0a8d7 Test: Fix Destiny Bond specification
It should fail deterministically every second time it's used.
2016-11-20 03:00:05 -05:00
Ivo Julca
632c04e6f1 Add failing tests for randbats generators 2016-11-20 00:24:28 -05:00
Ivo Julca
2bceebaac8 Test: Add coverage for random team generators 2016-11-19 16:11:50 -05:00
Slayer95
a3e3249a8f Spectral Thief should zero boosts despite of target abilities (#2906) 2016-11-19 14:38:54 -05:00
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