Pokémon Showdown
repository·master·Indexed 26 days ago
https://github.com/smogon/pokemon-showdownA comprehensive Pokémon battling platform featuring a battle simulation engine, game server for hosting communities, and a web API. It supports singles, doubles, and triples battles across Generations 1 through 9, including specialized mods for Gen 1, Gen 2, and Stadium versions. The project provides a JavaScript simulation library, CLI tools, and a server implementation requiring Node.js v16+.
What's inside pokemon-showdown
- The Stadium mod is a modification layer for the Pokémon Showdown engine. It functions by inheriting the Generation 1 engine, which in turn inherits from Generation 2, and then applying specific 'Stadium' rule changes on top of the Gen 1 mechanics.
Overview of Gen 1 Japanese Release mechanics
masterThe
gen1jpnmod implements Generation 1 mechanics based on the original Japanese releases. This version differs from the international releases used in later generations due to specific mechanical behaviors and move properties. Key differences include:- Blizzard: Has a 30.1% chance to freeze the target.
- Swift: Does not ignore accuracy checks (except when targeting Substitutes).
- Draining Moves: Moves like
AbsorborMega Drainfail when targeting a Substitute. - Event Moves: Access to specific Japanese event-only moves, such as Pikachu's
Flyor Fearow'sPay Day.
Overview of Pokémon Showdown components
masterPokémon Showdown is a multi-faceted project that can be used in several ways depending on your needs:
- Battle Simulation Library: A JavaScript library for simulating Pokémon battles and accessing Pokédex data.
- Game Server: A server implementation for hosting your own Pokémon Showdown community and custom game modes.
- Command-Line Tools: CLI tools for simulating battles, suitable for use in non-JavaScript environments.
- Web API: A web API used by the official Pokémon Showdown website.
The simulation engine supports singles, doubles, and triples battles across all generations (Generations 1 through 9).
Overview of the Stadium 2 mod
masterThe Stadium 2 mod is a modification for Pokémon Showdown that applies Stadium-specific mechanics to the Generation 2 engine. It follows a hierarchical inheritance: Gen 2 inherits from Gen 3, and the Stadium 2 mod applies its specific changes on top of the Gen 2 engine.Overview of Streams API
masterThe Streams API provides a way to interact with large amounts of data without loading everything into RAM. It offers simplified wrappers for Node.js streams and WHATWG streams.
There are several types of streams:
WriteStream: Writes strings or Buffers.ReadStream: Reads strings or Buffers.ReadWriteStream: A combined read/write stream for strings/Buffers.ObjectWriteStream: Writes arbitrary objects.ObjectReadStream: Reads arbitrary objects.ObjectReadWriteStream: A combined read/write stream for arbitrary objects.
Note: These streams are not API-compatible with Node.js streams, but they can wrap them.
Overview of @smogon/sets data sources
masterThe
@smogon/setspackage provides Pokémon sets from two primary sources:dex: Sets imported from Smogon.com's analyses. Note: These sets are copyrighted by Smogon.com and its contributors. You must obtain permission from Smogon.com before using this data source in your application.stats: Sets generated based on usage statistics from ladder play on the official Pokémon Showdown server.
Understand Generation 2 mechanics overview
masterGeneration 2 mechanics in Pokémon Showdown simulate the mechanics of Pokémon Crystal. Key characteristics of this generation include:
- Abilities: Pokémon have no abilities.
- Items: Most Pokémon are limited to using
Leftoverseffectively due to the meta's nature. - Metagame Style: Characterized by a 'stally' meta where defense often overcomes offense due to the prevalence of
RestandSleep Talk. - Stats: Special Attack and Special Defense share a single 'Special' stat for both EVs and IVs.
Understand Pokémon Showdown team formats
masterPokémon Showdown utilizes three primary team formats depending on the use case:
- Export format: Human-readable text used by the client for teambuilder import/export features.
- JSON format: Machine-readable format used within the codebase. In TypeScript, these are represented as
PokemonSet[]. - Packed format: A compressed string format used for sending data via text commands (like
/utm), command-line tools, and automated backups.
Understand the Pokémon Showdown Simulator Protocol
masterThe Pokémon Showdown simulator protocol uses a newline-and-pipe-delimited text stream. Messages are prefixed with a pipe|. For low-level details on reading from or writing to the text stream, refer tosim/SIMULATOR.md.Use Pokémon Showdown for battle simulation, team management, and Pokédex access
masterThe Pokémon Showdown Node.js package provides APIs for several core functionalities:
- Simulating battles: Use the simulator API to run battle simulations (also available via CLI).
- Validating, generating, and converting teams: Manage Pokémon teams (also available via CLI).
- Getting Pokédex information: Access data from the Pokédex.
Detailed documentation for these specific modules can be found in
sim/SIMULATOR.md,sim/TEAMS.md, andsim/DEX.mdrespectively.Understand the Pokémon Showdown high-level architecture
masterPokémon Showdown (PS) is composed of three primary interconnected components:
- Game server: Handles chat rooms, matchmaking, and battle simulation. It communicates with the Login server for replay uploads and ladder updates.
- Client: The user interface served via a web browser. It communicates with both the Login server (for authentication and database interfacing) and the Game server (via SockJS).
- Login server: Handles user logins and most database interactions. It is intended to replace legacy PHP code in the Client.
Communication flow: The Client connects to the Login server at
/api/and connects to the Game server using SockJS.Locate and access ladder data files
masterLadder data is stored in the
config/ladders/directory. Each ladder is contained within a TSV (Tab-Separated Values) file named using the formatFORMATID.tsv.To view or edit these files, it is recommended to use a spreadsheet application (such as Microsoft Excel or Google Sheets) rather than a standard text editor, as they are structured as spreadsheets.