Commit Graph

90 Commits

Author SHA1 Message Date
JetOU
85533ee3a0 Change forEach to for...of (#5269) 2019-03-08 11:24:58 -06:00
Guangcong Luo
39f0ca022e Fix validation of Gen 2 Marowak set
This was a lot of work for what turned out to be a really simple fix.
Gen 2 tradeback validation ended up being slightly too strict.
2019-03-03 08:45:45 -06:00
Kirk Scheibelhut
b09fd63377 Refactor sim/ to be native Typescript (#5210) 2019-02-26 11:03:30 -06:00
Konrad Borowski
7481ccc680 Disallow 0 EVs even when EVs weren't sent (#5187) 2019-02-20 00:05:12 -06:00
Guangcong Luo
70b3e9a525 Rename channel -> room, subchannel -> channel
"channel" is just a fancy way of saying "room, but in sockets".
Renaming them like this should make it clearer exactly what's going
on in sockets.
2019-02-05 16:55:37 -06:00
Guangcong Luo
b15c9a60f9 Fix formatText support for & > etc in URLs 2019-02-04 09:17:48 -06:00
Guangcong Luo
f3e45fbb72 Move server code to server/
Also move mods/ to data/mods/

This makes PS more monorepo-like. The intent is to further separate
the sim and the server code, but without fully committing to splitting
the repository itself.

We now support `./pokemon-showdown start` in addition to
`./pokemon-showdown`. I'm not clear which I want to be the default
yet.
2019-02-03 16:07:06 -06:00
Konrad Borowski
bd99a2b9b0 Support gTLDs in e-mail addresses (#4931)
Back when this code was introduced, the TLDs were relatively short,
with only two outliers: .museum and .travel.

Since then, a generic TLD system was introduced which opened
registration of top level domains. The number of TLDs registered this
way exceeds 1 200, with the longest TLDs having 18 characters.

Parsing longer TLDs for emails shouldn't cause practical issues, as
e-mail syntax is unusual enough. In fact, in the older versions, this
code was buggy as it linked example@example.exa in
example@example.example, not noticing that there should be a word
bounary.
2018-10-25 15:40:18 -05:00
Konrad Borowski
60c3fe5e05 Test links with parenthesis (#4932)
A lot of complexity in a chat formatter link regular expression is to
support links with parentheses in them. This commit introduces a test of
this to avoid accidentally breaking this functionality.
2018-10-25 15:37:28 -05:00
Marty-D
02332ce2fa
Test some more illegal egg move combinations 2018-08-21 13:47:21 -04:00
Quinton Lee
58b20d99eb Dex: Support custom rules altering complex bans (#4738)
Also adds some tests for custom rules
2018-07-03 17:22:28 -07:00
whales
eb61aac282 Tests#Ban: Ignore shared IPs (#4565) 2018-04-09 01:58:31 -05:00
asgdf
324e853f4a Enable explicit allowing/disallowing of renames in battles (#4510) 2018-03-22 10:07:47 -05:00
Guangcong Luo
8b19a546b8 Fix chainbreeding validator 2018-02-01 21:06:37 -06:00
Guangcong Luo
245af440d4 Fix style error 2018-01-31 22:26:24 -06:00
Guangcong Luo
78c327028e Fix Blissey Present + Heal Bell egg move bug
I originally thought this would have to be hardcoded, but actually this
can be coded slightly less hardly than expected!

Getting a Blissey with Present + Heal Bell in Gen 2 works like this:

- Teach Smeargle Present + Heal Bell
- Breed Present + Heal Bell into Snubbull
- Chainbreed Present + Heal Bell into Blissey

The main issue is that checking chainbreeding is very hard, so PS
mostly just takes the stance of "chainbreeding multiple moves is
probably impossible; hardcode exceptions".

BUT! BUT!!!!

Instead of hardcoding this exact move combination, we can actually
just hardcode the fact "the first step of chainbreeding is always legal
if the first father is Smeargle". Which I did and it works!
2018-01-31 21:53:11 -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
d395424fd3 TeamValidator: Return null, not false, for valid team
As usual, having `T | false` be our optional is a really old PHP
convention; we should be using `T | null` basically everywhere.
2018-01-18 03:32:32 -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
Bär Halberkamp
65a82f28f0 Add a system for subrooms (#4014) 2017-12-13 23:33:25 -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
5d11ec89f1 Fix base-pokemon banning 2017-12-08 22:27:30 -06:00
Guangcong Luo
0613939874 Refactor tournament rule validation
It was happening in two different places. It's been consolidated now.
2017-12-08 21:04:05 -06:00
Guangcong Luo
bb598ed6c2 Add rule validator for format rules 2017-12-07 22:07:12 -06:00
Quinton Lee
b13098a684 Formatter: fix linking text followed by > (#4222) 2017-12-07 16:13:35 -06:00
Guangcong Luo
f4e535bbd6 Enforce consistent key spacing
This was previously not enforced because we used `:1` in too many
places, but those places seem to all be refactored out at this point.
2017-12-01 08:16:23 -06:00
Guangcong Luo
1d41e73199 Formatter: Change rel="noopener" output
The client now interprets `rel="noopener"` to mean "check links for
interstice whitelist", and bypasses the interstice if it's not there.

This is is the best approach for [[google links]] to bypass the
interstice, while not whitelisting all of Google because Google
redirects are not generally trustworthy.
2017-11-28 09:53:21 -06:00
Bär Halberkamp
5b542c5f4c Formatter: re-implement [[pokemon: name]] and [[item: name]] 2017-11-28 16:34:48 +01:00
Guangcong Luo
fda5ab4fcc Support paren spans in chat formatter
This mainly adds support for parenthetical spoilers:

(parenthetical spoiler: these)

They'll be useful for closing any other autoclosing spans in the
future, but currently spoiler is the only one.
2017-11-28 08:34:21 -06:00
Guangcong Luo
3c5b4ca0fb Formatter: Fix parsing for [[wiki: links]] 2017-11-28 08:34:21 -06:00
Guangcong Luo
d0f66895c3 Update text formatter link syntax
Now matches old link syntax [[Text <uri>]]

Also now supports alternate search engines [[wiki: Text]]
2017-11-28 07:59:51 -06:00
Guangcong Luo
45dd012840 Refactor chat-formatter main loop
The new loop makes the loop invariant a lot easier to enforce, although
it makes certain parts less readable.
2017-11-28 07:17:36 -06:00
Guangcong Luo
65517f279c Rewrite chat formatter
This new version supports significantly more client chat formatting
than before, and is more readable.

Also new: the `code` formatting now uses basically the same system as
Markdown, where you can use as many `` ` `` in a row as you want as
your delimiter.
2017-11-27 12:16:15 -06:00
Guangcong Luo
e25eeb9eb0 Correctly validate Rockruff-Dusk 2017-11-16 21:45:24 -06:00
Guangcong Luo
e377d69395 Fix core team-validation intersection check 2017-11-05 00:11:51 -07:00
Guangcong Luo
7904e7791b Fix Gen 2 Hidden Power IV validation 2017-11-05 00:11:51 -07:00
Guangcong Luo
b01e4794a0 Rephrase team validator test 2017-11-04 12:14:21 -07:00
Guangcong Luo
011528bd5a Fix Hidden Ability validation
Previously, a mix of past-gen and modern event sources for a move would
confuse the validator. This case is now properly handled.
2017-11-02 13:36:05 -05:00
Guangcong Luo
0039db7a84 Add more tests for team validator 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
Guangcong Luo
d1bf3737a8 Improve chat formatter tests 2017-10-30 21:51:37 -05:00
Guangcong Luo
3f3eaa1ac0 Formatter: Fix subscript parsing 2017-10-30 21:48:14 -05:00
Guangcong Luo
39b52e7dda Rename Chat.parseText -> Chat.formatText
(And move it to its own file, chat-formatter.js)
2017-10-30 21:41:59 -05:00
Guangcong Luo
0ccf846eab Add tests for Chat.parseText 2017-10-30 21:31:03 -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
Guangcong Luo
8d12d1e0d2 Refactor matchmaker
This removes the outdated user.searching object, instead tracking all
searching state from inside the matchmaker.
2017-09-05 05:34:27 -04:00
Guangcong Luo
7a9310ac66 Fix Matchmaker hotpatching
Matchmaker is now globally accessible under Ladders, rather than
needing to be manually required.

This fixes a crash when hotpatching certain things.
2017-09-01 06:29:21 -04:00
Guangcong Luo
cb459a37bc Rename matchmaker.startBattle -> Rooms.createBattle 2017-09-01 04:46:37 -04:00