Commit Graph

68 Commits

Author SHA1 Message Date
bgsamm
b5022361fb Add King's Rock flags for Gens 2-4 (#4916) 2018-10-22 21:28:32 -05:00
HoeenHero
0a7ebcd076
Super Staff Bros Brawl (#4915)
Was a major project, credit also goes to @CheeseMuffin @KrisXV @ImLycan @MacChaeger @TheTiksiBranch and @Volco for helping to code this format!
2018-10-20 13:53:30 -04:00
Guangcong Luo
f008188b9f UnknownEffect Moves are always ActiveMoves 2018-10-10 18:52:21 -05:00
Guangcong Luo
affcad7873 Improve documentation of isZ vs isZPowered
move.zPowered is renamed move.isZPowered. It's now documented in JSDoc
exactly how it differs from move.isZ.

This commit includes several minor refactors to Z-move mechanics,
including a bug fix: Z-boosted called Weather Ball is now correctly
typed.
2018-10-10 18:44:05 -05:00
Guangcong Luo
ecb27edb4d
Introduce ActiveMove; make some types read-only (#4902)
The types Template, Move, Ability, and Item are now read-only. This
should guard against accidental writing to types that shouldn't be
written to.

A new type, ActiveMove, has been introduced. Like it sounds, it's
used for moves that are currently actively being used. A lot of
attributes that are only relevant to active moves, such as
`hasBounced`, are now only available on ActiveMove, not on Move.
ActiveMoves are mutable, unlike Moves.

getMoveCopy has been renamed getActiveMove, to better reflect its
role. `isCopy` has been deprecated, and distinguishing Moves from
ActiveMoves is now done by `typeof move.hit === 'number'` where
necessary.

ActiveMoves now internally track which hit of a multihit move
they're on, in move.hit, so move.hit doesn't need to be manually
incremented by Triple Kick and Parental Bond anymore.

move.hasParentalBond has been replaced by a more generic
move.multihitType.
2018-10-10 16:04:35 -05:00
Quinton Lee
94016f6218 Update Typescript to 3.1 (#4879) 2018-10-05 04:02:54 -05:00
The Immortal
d80c813118 Update Random Battle 2018-09-24 17:10:17 +04:00
Marty-D
952ccb2d80 Correct Soul-Heart activation order 2018-09-13 11:34:30 -04:00
MacChaeger
82c792f82c Update to TypeScript 3.0.1 (#4710) 2018-08-07 03:27:28 +09:00
urkerab
d8ebd62c87 Other Metagames of the Month August 2018 (#4782) 2018-08-03 13:49:06 +04:00
urkerab
89e33bc649 Fix Bestow, Covet, Symbiosis and Thief with a required item (#4715) 2018-07-02 17:36:37 -04:00
Kris Johnson
eda6cdc108 Add OMotM and LCotM for July 2018 (#4733) 2018-07-02 01:36:26 +08:00
Marty-D
538ac5ca55 Fix protection interaction with Z-Powered Z-Moves 2018-06-30 16:34:35 -04:00
MacChaeger
e3174ebc02 Fix type display in Gen 7 metas (#4655) 2018-05-21 17:27:23 -05:00
Quinton Lee
cf50a3d642 Typescript the rest of mods/ (#4588) 2018-05-05 14:56:45 -05:00
Guangcong Luo
322eb9fbf0 TypeScript: Start work on typing chat commands
Nothing is being checked yet because there's a whole bunch of
complication in there, but this is a start.
2018-05-02 17:45:15 -05:00
MacChaeger
711a0d4ce4 Check semi-invulnerability before immunities (#4574) 2018-04-14 10:27:45 -04:00
Quinton Lee
acd812c71e Typescript gens 1-4 (#4556) 2018-04-11 22:11:25 -05:00
Marty-D
ce38fe5c03 Fix Auras boosting only one hit of a spread move 2018-04-05 10:12:32 -04:00
Quinton Lee
c799393710 Typescript data/ and config/formats (#4513)
Also removes Battle Factory methods accidentally re-added in d0a4a689a7
2018-03-26 09:50:51 -05:00
CheeseMuffin
fbb916ff5f Add Chat to TypeScript globals (#4287) 2018-02-26 15:15:44 +09:00
Guangcong Luo
4c0699abc6 Implement inputLog
A battle's inputLog is now stored separately from the output log. It's
not an exact log of inputs, but rather just a collection of the inputs
that resulted in the battle: a default choice expands to the choice
that was actually used, and the starting seed is logged whether or not
it was explicitly passed into the battle stream.

Fixes #4348

Fixes #3201
2018-01-28 21:23:06 -06:00
Guangcong Luo
1531b662c6 Refactor battle stream system
This contains a lot of minor refactors, but the main thing that's going
on here is that battle stream writes have been streamlined to be a lot
easier for others to use.

We even support:

    ./pokemon-showdown simulate-battle

which provides a stdio interface for anyone using any programming
language to simulate a battle.
2018-01-28 21:06:49 -06:00
Guangcong Luo
9c037b17fe Refactor Battle constructor
`Sim.construct` no longer exists. Battles are now constructed directly
with `new Battle()`. Parameters other than formatid are now passed as
`options`.
2018-01-28 21:06:49 -06:00
Guangcong Luo
e8163824ff Remove validate-conditionals eslint rule
As far as I can tell, `curly, multi-line, consistent` does everything I
want; there's no reason to keep around a validate-conditionals rule.

Which is probably good, since eslint is deprecating the API for this,
anyway. The nice thing about not relying on deprecated APIs is that now
you can lint PS with `eslint` rather than needing to memorize
command-line switches.
2018-01-19 13:25:10 -06:00
Guangcong Luo
ab1f995daa Rewrite Process Manager
Process Manager is now lib/process-manager.js

It's been entirely rewritten to reflect what I think a process manager
API should look like.

In particular, there are now two Process Managers, QueryProcessManager
and StreamProcessManager.

Pass QueryProcessManager a pure-ish query function (sync or async) that
takes a JSON value and returns a JSON value, and PM.query() will
execute that function in a subprocess, and return a Promise for its
return value.

StreamProcessManager is the same idea: Pass it a function to create an
ObjectReadWriteStream, and PM.createStream() will create a stream in a
subprocess and return a stream connected to it.
2018-01-18 03:34:16 -06:00
Guangcong Luo
df4aeebcd5 Use new Streams for FS streams 2018-01-13 03:59:09 -06:00
CheeseMuffin
636b8d79ea Finish typescripting punishments.js (#4284) 2017-12-27 15:10:45 -06:00
Guangcong Luo
27070c589f Fix TypeScripting for users.js 2017-12-26 12:40:45 -06:00
CheeseMuffin
f27f0e21dd Typescript users.js (#4279) 2017-12-26 00:24:38 -06:00
Guangcong Luo
5094631fcf Implement Roomlog library
Rooms now have their logging abstracted into their own file, which also
allows the rest of rooms.js to be simplified by a decent margin.

This is in preparation for using Redis as a backing for scrollback log
storage, which will give us a lot more RAM to work with.

My newest newest plan is actually to locally cache room scrollback, and
only read battle logs from Redis. This will make chatroom-joining
faster.
2017-12-16 15:40:45 -06:00
Guangcong Luo
7e02b57016 Refactor Matchmaker to subclass Ladder
As expected, this resulted in zero API changes. (Aside from a minor
test change.)
2017-12-09 15:45:10 -06:00
Guangcong Luo
799a6a1e44 Improve Matchmaker API
Ladder is now a subclass of Matchmaker, and all the APIs previously
attached to Matchmaker are now directly available in Ladder.

In addition, all functions that take a formatid are now of the form
`Ladders(formatid).function(other arguments)`

TODO: Reverse polarity; it makes more sense for Matchmaker to be
a subclass of Ladder. Fortunately, this wouldn't involve API changes.
2017-12-09 15:04:29 -06:00
Guangcong Luo
56190af620 Fix up TypeScript errors
Also suppress TypeScript validation of various files we don't want
validated right now.
2017-11-08 01:23:04 -06:00
Guangcong Luo
844f461dbb TypeScript rooms.js 2017-11-06 21:56:33 -06:00
Guangcong Luo
7466edf24e Remove unused globals.js file 2017-11-06 21:19:54 -06:00
Guangcong Luo
2d9fc18280 TypeScript sim/team-validator.js 2017-11-02 00:15:04 -05:00
Guangcong Luo
0e728281e6 Move team-validator to sim/team-validator 2017-11-01 05:22:37 -05:00
Guangcong Luo
a47077bbe9 Split TeamValidator and TeamValidatorAsync
I'm not really sold on "TeamValidatorAsync" as a class name or file
name, so I'm open to suggestions.

The long-term plan is to put TeamValidator in sim/ but this is in three
commits because I really want the right file to retain blame history.
2017-10-31 15:49:09 -05:00
Quinton Lee
a0b8228592 TypeScript: Improve Sim typing (#4069)
Also improves intellisense for Visual Studio and Visual Studio Code.
2017-10-20 07:53:26 -05:00
Guangcong Luo
88159c41bc Refactor BattleRoom -> GameRoom
BattleRoom is now GameRoom, a slightly more abstract room type capable
of holding any of a number of possible roomgames. Currently, battles
are the only such roomgame, but any future roomgame could possibly use
it.

Differences between ChatRoom and GameRoom:

- GameRooms start at the left, ChatRooms start at the right
- GameRooms have chat on the right, and a game area on the left, with a
  view area at the top left and a controls area at the bottom left
- GameRooms retain all their logs, ChatRooms only retain the latest 100
  lines
- GameRooms expire after 40 minutes of inactivity or 10 minutes of zero
  online users (configurable in the future)
- GameRooms are guaranteed to have an associated game, while ChatRooms
  may or may not
2017-10-18 05:41:03 -05:00
Ben Davies
a5bc1e0045 Typescript: ladders-matchmaker.js (#3942) 2017-09-01 19:18:59 -04:00
Ben Davies
67b25950de Typescript: Declare all globals, refactor monitor.js (#3748) 2017-07-13 12:20:03 +09:00
Ben Davies
74131dbf58 Typescript: crashlogger.js (#3605)
Depended on by numerous other modules to be moved over to Typescript
before they can.
2017-06-11 11:16:21 -05:00
Guangcong Luo
149ca3759c Add classes for data
Having classes for data will make it better for documenting and make
for overall nicer code that's easier to statically analyze.
2017-05-17 04:10:01 -05:00
Guangcong Luo
e34c77930a Start creating classes for getEffect data
Currently, getEffect/getTemplate/getMove/etc return bare objects.
Refactoring their returns into classes will allow TypeScript to type
check them.
2017-05-09 16:00:11 -05:00
Ben Davies
8de4bdfecb Sockets: refactor to use maps (#3474) 2017-04-23 16:39:38 -07:00
Ben Davies
5031794f97 Sockets: fix unit tests (#3281)
* Sockets: fix Sockets.killWorker not disconnecting connections

* Sockets: fix unit tests

- Fix crash when constructing mock sockets in certain cases
- Properly prevent workers from writing to stdout
- Fix race conditions in workers-related tests that were causing false
  positives

* Tests: mock workers now more closely imitate sockets' workers

This helps catch cases where messages are being sent in the wrong order
to the workers, e.g. messages sent to sockets that no longer exist.
2017-02-24 05:38:37 -06: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
095652c9ee Exit process when child process exits
If a child process dies in a way that it can't recover from, the main
process now exits, to prevent loops of 'Error: channel closed'
thousands of times a second, filling up the error log and making it
hard to track down the real error.
2016-02-03 22:40:51 -06:00