Skip to content

Commit

Permalink
Update (#2)
Browse files Browse the repository at this point in the history
* Gen 1: Paralysis should not reapply stat drop because of a failed move (smogon#5123)

* Random Battle: Fix Dedenne HP EVs (smogon#5122)

* Mafia Theme Update (smogon#5114)

* SSB: Fix Compost & Wonder trade with False (smogon#5124)

* Support custom rated messages

(For use in SPL)

* Fix dc6fc43

* Scavs: Award points for hosting automatically (smogon#5126)

* Mafia: Bugfixes for modifiers, allow searching for terms (smogon#5127)

* Better fix for dc6fc43

* Battle Factory: Split UU Hydreigon sets

* Let's Go OU: Remove suspect notice

* PU: Ban Alolan Exeggutor

* Fix crash, message for locks (smogon#5125)

* Datacenter: Add more ranges (smogon#5129)

* Battle Factory: Fix another Hydreigon set

* NU: Add Vanilluxe suspect notice

* Add ORAS 1v1 and DPP AG

* Update Trick Room's short description

* Add 2nd and 3rd place point information to trivia modlog

* Remove a comment in Trivia code about point values

They no longer need to be divisible by 5. The caps are unlikely
to change, however the technical limitation of values having to be
divisible by 5 no longer exists.

* Notify after, not before, deleting a help ticket (smogon#5130)

* Update CAP analysis links

* Support new avatars

This isn't full support, but it's the important part, the part that lets
you use past-gen avatars.

* Other Metagames of the Month February 2019 (smogon#5131)

* Add February RoA Spotlight

* Fix 'sage-gen2jp' avatar

* Update allowed avatars list

* Remove Pokebilities format

I'm no longer accepting non-TypeScripted formats.

* Fix missing comma

* Remove useless param from pokemon.transformInto

Introduced in 743c851

* Stadium: Fix Counter and probably other things

* Remove Simple Symphony

* Always display Alola formes in /ds (smogon#5133)

The Alola formes are so different to regular formes that displaying
both the regular form and Alola form is actually a useful
information.

* Fix some OMotM crashes (smogon#5132)

* Deprecate battleban

* Fix unnecessary ts-ignore

* Pokebilities: Ban Moody (smogon#5136)

* Update Me First

* Spotlights: Allow non-staff to see current spotlights

* Spotlights: allow multiline input

* Remove useless check from pokemon.transformInto

* Remove useless check

* Make it harder to timerstall

This commit is aimed at a particular kind of timerstalling: starting a
new game while letting the timer run out on your current game, instead
of just forfeiting.

Now you can't search for more battles if it's your turn to move, or if
your opponent takes less than 10 seconds to move (including animation).

1v1 and Metronome Battles asked for exemptions, and they've received
them.

* Pikachu-Alola is not an Alola form for dex search (smogon#5138)

The intent of a recent dexsearch change was to display Alola formes
separately as they are very different. However, this also meant showing
Pikachu-Alola which is not an Alola form despite having "Alola" as
a forme name.

* Gen II: Fix species items

* Reorder formats

* Formats: Fix typo and add more thread links

* Update command documentation (smogon#5128)

* 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.

* Fix formatText support for `&` `>` etc in URLs

* Fix StaticServer and loading rooms

* Revert url for chatrooms.json updates

* Fix Illusion when dragged out

* TypeScript globals

A few globals: Monitor, LoginServer, etc weren't being correctly
TypeScripted. This should change that.

* Datacenters: Add a range (smogon#5141)

* Fix Hotpatch

* Fix the rest of the hotpatches

* Add BH suspect test

* 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.

* Fix some LGTM alerts (smogon#5139)

* Pokebilities: fix special abilities as well as Gastro Acid (smogon#5140)

* STABmons: Ban Thundurus

* RU: Ban Stakataka

* Help tickets: Remove timerstalling

* Battlesearch improve UI

* LC: Ban Baton Pass

* Check capitalization in Factory sets

This might be debatably important, but if it's worth pointing it out
in reviews, we might as well automate it.

* Use `declare let` instead of `let` in globals.ts

* Fix chat plugin file I/O after server/ refactor

* Fix modlog search location

* Battle Factory: Update RU and LC (smogon#5143)

* Fix hotpatch uncaching

Chat.uncache functions now consistently take a path relative to repo
root, just like FS.

Next step will probably be to have FS handle all text-based databases.

* Fix crash in /data

* Mafia: Support hiding discards, starting from open signups (smogon#5142)

* Refactor Emoji regex to use \p syntax (smogon#5146)

(Increases minimum Node version requirement)

* Increase required version number in README

* Suppress LGTM's URL sanitization warning (smogon#5147)

This warning is strictly speaking correct, the URL isn't verified
properly. However, in this case, this isn't a practical issue, as
it's possible to use /forcebattleban command anyways.

* Add Recoil as Move Search Parameter (smogon#5149)

* Help Tickets: Require users to explain their issue before getting help (smogon#5148)

* Fix ticket activation when the creator is staff

* STABmons: Fix Thundurus ban (smogon#5150)

Only the base forme was supposed to be banned.

* Formats: Fix thread links

* Movesearch: Account for custom recoil (smogon#5151)

* README: Add notes on upgrading Node version

This should help Linux users.

* Add LGTM alert count badge (smogon#4843)

* Allow free multi-laddering in first five turns

Searching for multiple games in the first five turns is unlikely to be
timerstalling, so we allow it here.

* Improve choice error messages

This should make choice errors clearer.

* Fix crash in /processes

* Better support IPv6 in IP checker

* Fix minor typos

* Fix Help Tickets preview

* Add in-battle mod detection to /weak and /coverage (smogon#5144)

* Clarify message for multi-laddering

* Fix hotpatching battles/formats

Hotpatching battles only is no longer possible - it takes the same
amount of resources as hotpatching formats but is way more error-prone.

* Remove 7 second limit for multi-laddering

* Automatically end `BattleStream`s at end of battle

PS prefers to keep battle streams open (for `/evalbattle`) until
manually ended, but this is confusing some other users. We now
automatically end streams unless the `keepAlive` option is set.

Fixes smogon#5157

* Fix /hotpatch chat

Old chat plugin processes weren't getting correctly ended.

* Tweak ghost connection timeout, log their connection status

* Fix an edgecase regarding locks getting removed on guests
This caused /unnamelock to leave ghost users in the userlist

* Fix math for counting battle turns

Turns out, requestCount goes up by 2 every turn, not 1.

In hindsight, this makes sense because we're giving every player their
own request ID.

* Random Battle: Update Probopass (smogon#5159)

Earth Power is one of its most used moves because of Steel trapping with
Magnet Pull, while Pain Split is almost unheard of in standard tiers,
and isn't very useful on it unless it has Sturdy (but Magnet Pull is the
better move and is rated higher)

* Refactor formeChange

This fixes an obscure issue where we sent a formechange-to-self on
faint in certain obscure situations (apparently including Gen 4
Custap?)

In case anyone wants to investigate the details (this commit just
patches over some symptoms), the relevant replay is here:

https://replay.pokemonshowdown.com/smogtours-gen4ou-425031

* Require object literal method shorthand

* Deprecate /redir

* NU: Ban Vanilluxe

* Remove deprecated commands from /help

* Random Battle improvements

* Mafia: Fix starting games through the UI (smogon#5156)

* Add a PageContext for HTML pages and expand html page functionality (smogon#5160)

* Show deprecated status of commands in the command help

* This command is not technically deprecated but close enough

* Support the random battles damage calculator

* Random Battle: Update Rhyperior (smogon#5162)

* Random Battle: Update Rhyperior

- Although Rock Blast is the preferred move in RU, there are notably
fewer Sturdy mons in Random Battle and it struggles more with breaking
Substitutes with it.
- Aqua Tail gives very minimal meaningful coverage since it mostly is
super effective on Pokemon already weak to Ground. Instead, give it Ice
Punch since it's much more common on it.

* Update formats-data.js

* Update formats-data.js

* DPP LC: Ban Hypnosis

* Battle Factory: Remove unranked Pokemon and fix Snorlax (smogon#5164)

* Revamp evolution tables (smogon#4997)

* Add LC suspect notice (smogon#5169)

https://www.smogon.com/forums/threads/lc-suspect-bush-doesnt-care.3647220/

* Change (PU) to Untiered (smogon#5170)

* Prevent using Leppa Berry from triggering Endless Battle (smogon#5158)

Previously, using Leppa Berry by itself caused Endless Battle Clause
to consider Pokemon to be stale. However, it is reasonable to use
Leppa Berry without an intent to cause an endless battle - for
instance to increase the PP of a move with a low PP.

* Fix transformInto so OMs still work (smogon#5165)

* Add tests for Sleep Clause Mod (smogon#5171)

* Cafe: Fix path

* Fix terrain seed activation timing (smogon#5163)

* CAP: Nerf Crucibelle-Mega (smogon#5172)

* CAP: Nerf Crucibelle-Mega

* oops

* Revert "Fix terrain seed activation timing (smogon#5163)" (smogon#5173)

This reverts commit 250955e.

* Fix "Fix terrain seed activation timing (smogon#5163)"

Shouldn't of reverted this so quickly. Credit to the code goes to @MacChaeger

* Add alias for /hidetext

* Add Bottle Caps

* Mafia: Fix html room updates (smogon#5174)

* Battle Factory: Fix Espeon's ability in RU (smogon#5175)

* Fix crash in ghost connection fix

* 1v1: Unban Kyurem-Black (smogon#5176)

* Don't crash when using /data in with the camomons mod

* TCG: Update wiki domain

* Allow warning users outside the room in all global warn contexts

* Fix Chimecho's egg group

* Support custom hideReplay setting

* Use editprivacy permission for /ionext

This matches the permission for /ioo

* Update .gitignore for /server/

* Optimize Dex#getEffect by caching the result. (smogon#5181)

As outlined by pkmn.cc/optimize, this change should result in a ~30%
increase in Battle performance over repeated runs. Caching the
resultant effect is safe provided nothing mutates it.

* SSB: Fix Evoblast interaction with substitute; update ranks (smogon#5166)

* Learnsets: Fix Gen 4 tutor moves

* Refactor Dex#getEffect + Dex#getEffectInner back to one method (smogon#5182)

* Add evolution method information (smogon#5179)

* Improve data representation of evo method

* Simplify evo data representation

* Add 1v1 suspect notice (smogon#5186)

* Disallow 0 EVs even when EVs weren't sent (smogon#5187)

* Refactor remaining tests to use Battle#makeChoices (smogon#5183)

* Remove * from most permissions shown in /help (smogon#5168)

* Tours: Fix a forfeit being reported as failed even though it succeeded (smogon#5188)

* Finally remove deprecated legacy API

It's gone! The last remnants of the old choice parsing system is
finally gone!

* Lower tab size in !code

* Chat monitor: make inap pokemon names weeklock instead of namelock

* Fix random typos in tests (smogon#5190)

* Split `getRelevantEffectsInner`

This is mainly a readability refactor.

* Refactor getRelevantEffects -> findEventHandlers

This fixes getRelevantEffects's massively confusing call structure.

Most parameters relating to bubbling up and down have been removed
entirely, and traversing the many possible event handler types is now
simply done outside the callers.

In addition, a lot of variables/functions have been renamed for much
better clarity.

* Random Battle: Improve Toucannon

* Mafia: Resolve chat pages properly (smogon#5192)

* Datacenters: Add a range

* Refactor findEventHandlers further (smogon#5193)

- rename `thing` when we know what it will be.
- simplify `resolveLastPriority`
- remove `findBattleEventHandlers` param given that its always this
- avoid multiple lookups of the same attribute

These functions related to finding events are very hot
(pkmn.cc/optimize) and microbenchmarks indicate TurboFan is unable
to extract out the constants for us. As a side benefit, there's less
`// @ts-ignore` required, and future optimizations will use the
constants anyway. More extraction can be done in findEventHandlers,
but that will be left for a future change where the need becomes
more obvious.

* Mark Feebas's evolution in Gen4 as requiring high Beauty

Trade evolution for Feebas was introduced in Gen5.

* Remove 'server/process-manager.js' from tsconfig (smogon#5197)

'process-manager.js' now lives under 'lib/' which is already
included.

* Add 1v1 Sample Teams (smogon#5195)

* Add 1v1 Sample Teams

* Add missing comma

* Fix some Typescript related TODOs (smogon#5198)

* Datasearch: Fix event Pokemon showing in LC searches (smogon#5177)

* Document remaining message types in SIM-PROTOCOL (smogon#5196)

* Add Imprison switch-out test

Apparently we had zero tests to make sure volatile statuses go away
after switching out and back in!

* Further improve switch tests

- Test that Baton Pass passes Ingrain
- Test that Baton Pass doesn't pass Imprison
- Test that other forms of switching don't pass either

* Update TypeScript to version 3.3.3333

Using a tilde in a version number as TypeScript explicitly doesn't
follow semver according to microsoft/TypeScript#14116.

* Pokebilities: Ban Porygon-Z (smogon#5200)

* Refactor getFormat pattern and ordering for speed (smogon#5194)

Even though 31c6a32 added caching to make this method less of a
hotspot, there's no reason to use a pattern which is an order of
magnitude slower (https://jsperf.com/pokemon-showdown-getEffect).
Also, rearranges Format to get checked first as pkmn.cc/optimize
finds it to be the most frequently accessed.

* Revert "Refactor getFormat pattern and ordering for speed (smogon#5194)"

This reverts commit 9ce0066.

It doesn't account for bugs relating to Object.prototype

* Refactor getEffect for speed safely (smogon#5201)

Rollforward of 7a20245 which retains the `hasOwnProperty` checks.

Also changes the method to call `toId` earlier and use the id
as the key to the cache to ensure 'Stealth Rock' and 'stealthrock'
return the same. NOTE: 'move: Stealth Rock' and 'Stealth Rock' will
still continue to return different results.

* Translation support (smogon#5167)

* Fix field initialization ordering in Pokemon (smogon#5204)

* Random Battle improvements

* Random Battle: Properly increment tier counters

* Gen I: Stop trying to change a fainted Pokemon's stat stages

* Make sure Transform copies the correct type

* Cleanup tsconfig includes further (smogon#5202)

* Remove BH suspect

* Fix misplaced string in PT translation

* Fix an inaccurate simplified Chinese translation (smogon#5208)

Bumba's OS not showing those characters somehow

* Revert "Change (PU) to Untiered (smogon#5170)"

This reverts commit d40fe51.

* Formats: Update ladders

* Change Untiered to (DUU) for Doubles (smogon#5178)

* Don't add inactive rules as pseudoweathers (smogon#5206)

* Fix crash with PMs

* Pokebilities: Update Trace, Power of Alchemy, and Receiver (smogon#5203)

* Pokebilities: Update Trace, Power of Alchemy, and Receiver

Now Trace copies a random ability from a random target, regardless of whether it was originally an innate or not

* Send correct target in message to client

* Fill in Japanese aliases (smogon#5209)

* Fix Gen 1 bug involving last damage and Substitute (smogon#2598) (smogon#5211)

* Fix Counter/Mirror Coat to respect redirection (smogon#5212)

* Refactor `sim/` to be native Typescript (smogon#5210)

* Include data/mods/gen1/pokedex.js in tsconfig (smogon#5213)

* Add GSC NU

* Translations: fix missing english strings

* Add one more volatile switch test

* Run onModifyTemplate on rulesets (smogon#5207)

* SSB: Arrested -> Pablo; Fix Fake Claim & Sub Interaction (smogon#5205)

* Fix build/hotpatch process

Hotpatching and running `./pokemon-showdown` now automatically run
`./build`. There should now mostly not be any reason you'd want to
manually run `./build`, except if you're invoking tests directly.

In addition, a lot of redundant code has been removed.

I'm not 100% sure this works on Windows, but I'm sure I'll get reports
if anything breaks.

* Explicitly import readdirSync in dex.ts

This avoids ExperimentalWarnings caused by wildcard import of fs.

* Update Psych Up and Transform interactions with crit rate effects

* Datacenters: Add a range

* Make !rules broadcastable

This fixes a regression.

* Fix fs.promises warning properly

The modern `__esModule` fallback isn't compatible with Node, and also
entirely unnecessary in practice.

The approach of disabling all the fallback code allows us to once again
`import * as fs`.

* Fix crash in SSB import

* Fix Shell Trap behavior with Encore (smogon#5218)

* March RoA Spotlight

* Make modlog asynchronous

This should prevent issues in which the /modlog takes forever
because it's waiting for previous /modlog command.

* Log long modlog queries

* Rephrase LICENSE

GitHub couldn't identify the old license as the MIT license,
so I'm just copy/pasting the one from the damagecalc which
GitHub doesn't have a problem with.

* RU: Add Zygarde-10% suspect notice

* Datacenters: Add more ranges

* Random Battle fixes

* Update Other Metagames

* Make sure suspect notices only show up in the relevant format

* Update VS Code launch configurations

- Remove "start server" because it's incompatible with multiprocess PS
- Add "parse input log"

* Fix Other Metagames of the Month (smogon#5224)

* Tiers: Add March quick drops

* Added RBY UU (smogon#5225)

* Add BW Monotype

* Megamons: Ban Mega Rayquaza

And remove some unnecessary validator checks.

* Change the RoA Spotlight

DPP Ubers was wrongly announced.

* Pull large avatarTable out into a Set constant. (smogon#5228)

* Remove FIXME's in gen1/gen2 random-teams.js (smogon#5227)

* Fix /dt showing 'undefined' as Zygarde ability (smogon#5153)

* Refactor `lib/` to be native Typescript (smogon#5217)

* Random Battle: Improve Kyurem

* Fix Megamons and Chimera simplistically (smogon#5229)

* Remove LC suspect notice (smogon#5231)

* Update RU thread links (smogon#5230)

* Refactor sim/dex-data.ts to minimize @ts-ignore (smogon#5214)

* Fix crash in Anticipation (smogon#5232)

A battle has crashed: TypeError: Cannot read property 'fainted' of null
at Battle.onStart (/home/ps/showdown/data/abilities.js:150:16)

* Fix Protean and Color Change (smogon#5233)

* Fix dependency check in build script

(This error wasn't caught because it still works without installing
the dependency, but makes the build script far slower because
`npx replace` would reinstall `replace` every time it's used.)

* 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.

* Use array spread instead of Array.from

* LC: Unban Torchic (smogon#5234)

https://www.smogon.com/forums/threads/torchic-has-been-freed.3647800/

* Disallow non-standard Pokemon in Gen1/2 randbats (smogon#5235)

* Revert buggy Megamons "fix" (smogon#5236)

* Fix HP bug in Chimera (smogon#5237)

* Use FS when loading Scavengers' data (smogon#5238)

This prevents issues with loading old state while hotpatching.

* PU: Add Houndoom suspect notice

* Chimera: Fix remaining HP bug (smogon#5240)

* Fix `build` script on Windows. (smogon#5241)

On Windows,	`shell` doesn't glob for us and the literal
`.sim-dist/*` is passed to `replace` and it doesn't get expanded
into the list of paths.

* Chimera: Fix ability bugs (smogon#5244)

* Add suspect notice to Mix and Mega

* Add Type: Null to Random Battle

* Megamons: Fix bans
  • Loading branch information
thejetou authored Mar 4, 2019
1 parent 74656f9 commit 795eb9d
Show file tree
Hide file tree
Showing 435 changed files with 214,504 additions and 85,169 deletions.
27 changes: 27 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# see: http://EditorConfig.org

# end_of_line is unspecified so Windows users can use the repo in crlf mode

root = true

[*]
charset = utf-8
indent_style = tab
indent_size = 3
trim_trailing_whitespace = true
insert_final_newline = true

[*.{json,yml,webapp}]
# npm style
indent_style = space
indent_size = 2

[*.md]
indent_style = space
indent_size = 4
trim_trailing_whitespace = false

[*.tsv]
indent_style = tab
indent_size = 8
trim_trailing_whitespace = false
4 changes: 3 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
tournaments/lib/
server/tournaments/lib/
logs/
dev-tools/globals.js
node_modules/
.*-dist/
30 changes: 15 additions & 15 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"root": true,
"parserOptions": {
"ecmaVersion": 8,
"ecmaVersion": 9,
"sourceType": "script",
"ecmaFeatures": {
"globalReturn": true
Expand All @@ -14,7 +14,8 @@
"globals": {
"Config": false, "Monitor": false, "toId": false, "Dex": false, "LoginServer": false,
"Users": false, "Punishments": false, "Rooms": false, "Verifier": false, "Chat": false,
"Tournaments": false, "Dnsbl": false, "Sockets": false, "TeamValidator": false, "Ladders": false
"Tournaments": false, "Dnsbl": false, "Sockets": false, "TeamValidator": false,
"TeamValidatorAsync": false, "Ladders": false
},
"extends": "eslint:recommended",
"rules": {
Expand All @@ -25,6 +26,7 @@
"no-inner-declarations": ["error", "functions"],
"valid-jsdoc": "off",

"eol-last": ["error", "always"],
"array-callback-return": "error",
"block-scoped-var": "error",
"comma-dangle": ["error", "always-multiline"],
Expand Down Expand Up @@ -76,21 +78,19 @@
"radix": ["warn", "as-needed"],
"vars-on-top": "off",
"wrap-iife": ["error", "inside"],
"yoda": "off",
"yoda": ["error", "never", { "exceptRange": true }],

"strict": ["error", "global"],

"init-declarations": "off",
"no-catch-shadow": "off",
"no-shadow": "off",
"no-label-var": "error",
"no-restricted-globals": ["error", "Proxy", "Reflect", "Symbol", "WeakSet"],
"no-shadow-restricted-names": "error",
"no-shadow": "off",
"no-undef-init": "warn",
"no-undef": ["error", {"typeof": true}],
"no-undefined": "off",
"no-unused-vars": ["warn", {"args": "none"}],
"no-use-before-define": ["error", {"functions": false, "classes": false}],
"no-use-before-define": ["error", {"functions": false, "classes": false, "variables": false}],

"callback-return": [2, ["callback", "cb", "done"]],
"no-mixed-requires": "error",
Expand All @@ -102,7 +102,7 @@
"no-sync": "off",

"array-bracket-spacing": ["error", "never"],
"block-spacing": "off",
"block-spacing": ["error", "always"],
"brace-style": ["error", "1tbs", {"allowSingleLine": true}],
"camelcase": "off",
"comma-spacing": ["error", {"before": false, "after": true}],
Expand All @@ -114,14 +114,13 @@
"id-length": "off",
"id-match": "off",
"indent": ["error", "tab"],
"key-spacing": "off",
"key-spacing": "error",
"lines-around-comment": "off",
"max-nested-callbacks": "off",
"max-statements-per-line": "off",
"new-cap": ["error", {"newIsCap": true, "capIsNew": false}],
"new-parens": "error",
"newline-after-var": "off",
"newline-before-return": "off",
"padding-line-between-statements": "off",
"no-array-constructor": "error",
"no-continue": "off",
"no-inline-comments": "off",
Expand All @@ -131,12 +130,13 @@
"no-negated-condition": "off",
"no-nested-ternary": "off",
"no-new-object": "error",
"no-spaced-func": "error",
"func-call-spacing": "error",
"no-ternary": "off",
"no-trailing-spaces": "error",
"no-trailing-spaces": ["error", {"ignoreComments": false}],
"no-underscore-dangle": "off",
"no-unneeded-ternary": "error",
"object-curly-spacing": ["error", "never"],
"object-shorthand": ["error", "methods"],
"one-var": "off",
"operator-assignment": "off",
"operator-linebreak": ["error", "after"],
Expand All @@ -155,7 +155,7 @@
"space-unary-ops": ["error", {"words": true, "nonwords": false}],
"wrap-regex": "off",

"arrow-parens": ["error", "as-needed"],
"arrow-parens": "off",
"arrow-spacing": ["error", {"before": true, "after": true}],
"no-confusing-arrow": "off",
"no-useless-computed-key": "error",
Expand All @@ -166,6 +166,6 @@
"template-curly-spacing": ["error", "never"],
"no-restricted-syntax": ["error", "WithStatement"],

"validate-conditionals": "error",
"no-constant-condition": ["error", {"checkLoops": false}]
}
}
12 changes: 9 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@
/logs/*
/node_modules
/eslint-cache
/chat-plugins/private.js
/server/chat-plugins/private.js
/server/chat-plugins/*-private.js
npm-debug.log
.eslintcache
package-lock.json

# Typescript build artifacts
.*-dist/

# visual studio live share
.vs

# boilerplate #
###############
Expand All @@ -26,7 +34,6 @@ tmp/**/*
.installed.cfg

downloads
build
dist

# egg related
Expand All @@ -48,4 +55,3 @@ local_settings.py
.svn

pip-log.txt

3 changes: 3 additions & 0 deletions .lib-dist/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**NOTE**: This folder contains the compiled output of the `lib/` directory.
You should be editing the `.ts` files there and then running `npm run build` or
`./pokemon-showdown` to force these `.js` files to be recreated.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
3 changes: 3 additions & 0 deletions .sim-dist/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**NOTE**: This folder contains the compiled output of the `sim/` directory.
You should be editing the `.ts` files there and then running `npm run build` or
`./pokemon-showdown` to force these `.js` files to be recreated.
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
sudo: false
language: node_js
node_js:
- "7.7"
- '10'
cache:
directories:
- node_modules
- .eslintcache
notifications:
webhooks: https://www.travisbuddy.com/
on_success: change
travisBuddy:
insertMode: update
33 changes: 33 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Run Mocha Tests",
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
"args": [
"-u",
"tdd",
"--timeout",
"999999",
"--colors",
"-f",
// Make this string non-empty to run only tests whose names match it
""
],
"internalConsoleOptions": "openOnSessionStart"
},
{
"type": "node",
"request": "launch",
"name": "Parse input log (paste in terminal)",
"program": "${workspaceRoot}/pokemon-showdown",
"args": ["simulate-battle"],
"console": "integratedTerminal"
},
]
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"editor.insertSpaces": false,
"typescript.tsdk": "node_modules/typescript/lib"
}
38 changes: 31 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,27 +79,51 @@ Our current convention is to use `'` for IDs; `"` for names (i.e. usernames, mov

Unfortunately, since this is not a convention the linter can test for (and also because our older string standards predate PS), a lot of existing code is wrong on this, so you can't look at surrounding code to get an idea of what the convention should be. Refer to the above paragraph as the definitive rule.

### Optionals: `null` vs `undefined` vs `false`

PS convention is to use `null` for optionals. So a function that retrieves a possible `T` would return `T | null`. This is mostly because TypeScript expands `T?` to `T | null`.

Some old code returns `T | undefined` (our previous convention). This is a relatively common standard (ironically, TypeScript itself uses it). Feel free to convert to `T | null` where you see it.

Some even older code returns `T | false`. This is a very old PHP convention that has no place in modern PS code. Please convert to `T | null` if you see it.

### `false | null | undefined`

The simulator (code in `sim/` and `data/`) will often have functions with return signatures of the form `T | false | null | undefined`, especially in event handlers. These aren't optionals, they're different sentinel values.

Specifically:

* `false` means "this action failed"
* `null` means "this action failed silently; suppress any 'But it failed!' messages"
* `undefined` means "this action should be ignored, and treated as if nothing unexpected happened"

So, if Thunder Wave hits a Ground type, the immunity checker returns `false` to indicate the immunity.

If Volt Absorb absorbs Thunder Wave, Volt Absorb's TryHit handler shows the Volt Absorb message and returns `null` to indicate that no other failure message should be shown.

If Water Absorb doesn't absorb Thunder Wave, Water Absorb's TryHit handler returns `undefined`, to show that Water Absorb does not interact with Thunder Wave.


ES5 and ES6
------------------------------------------------------------------------

In general, use modern features only if they're supported in Node 6 and reasonably performant in the latest version of Node.
In general, use modern features; recent versions of V8 have fixed the performance problems they used to have.

- **let, const: ALWAYS** - Supported in Node 4+, good performance.

- **for-of on Arrays: SOMETIMES** - Poor performance. Acceptable outside of inner loops. For inner loops, use `for (let i = 0; i < array.length; i++)`
- **for-of on Arrays: ALWAYS** - Supported in Node 4+, good performance in Node 8+.

- **Array#forEach: NEVER** - Worse performance than `for-of` on Arrays. See `for-of`.
- **Array#forEach: NEVER** - Poor readability; we prefer `for-of`.

- **for-in on Arrays: NEVER** - Horrible performance, weird bugs due to string keys, poor interaction with Array prototype modification. Everyone tells you never to do it; we're no different. See `for-of`.

- **Map, Set: SOMETIMES** - Much worse write/iteration performance, much better read performance than `Object.create(null)`. Use whatever's faster for your use case.
- **Map, Set: SOMETIMES** - Worse write/iteration performance, better read performance than `Object.create(null)`. Use whatever's faster for your use case.

- **for-in on Objects: SOMETIMES** - `Object.keys` is apparently a lot faster. Use that if you can.
- **for-in on Objects: ALWAYS** - More readable; good performance in Node 8+.

- **for-of on Maps: NEVER** - Poor performance. Use `Map#forEach`.
- **for-of on Maps and Sets: ALWAYS** - Supported in Node 4+, good performance in Node 8+.

- **Map#forEach: ALWAYS** - This is our preferred method of iterating `Map`s.
- **Map#forEach, Set#forEach: NEVER** - Poor readability; we prefer `for-of`.

- **Object literal functions: ALWAYS** - Supported in Node 4+, good performance.

Expand Down
34 changes: 17 additions & 17 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
Copyright (c) 2011-2017 Guangcong Luo and other contributors
The MIT License (MIT)

Copyright (c) 2011-2019 Guangcong Luo and other contributors
http://pokemonshowdown.com/

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Loading

0 comments on commit 795eb9d

Please sign in to comment.