Pokémon Showdown

repository·master·Indexed 26 days ago

https://github.com/smogon/pokemon-showdown

A 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+.

Tokens
22.8K
Snippets
40
Records
162
Agent score
91%

What's inside pokemon-showdown

  1. Overview of Gen 1 Japanese Release mechanics

    master

    The gen1jpn mod 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 Absorb or Mega Drain fail when targeting a Substitute.
    • Event Moves: Access to specific Japanese event-only moves, such as Pikachu's Fly or Fearow's Pay Day.
  2. Overview of Pokémon Showdown components

    master

    Poké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).

  3. Overview of Streams API

    master

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

  4. Overview of @smogon/sets data sources

    master

    The @smogon/sets package provides Pokémon sets from two primary sources:

    1. 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.
    2. stats: Sets generated based on usage statistics from ladder play on the official Pokémon Showdown server.
  5. Understand Generation 2 mechanics overview

    master

    Generation 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 Leftovers effectively due to the meta's nature.
    • Metagame Style: Characterized by a 'stally' meta where defense often overcomes offense due to the prevalence of Rest and Sleep Talk.
    • Stats: Special Attack and Special Defense share a single 'Special' stat for both EVs and IVs.
  6. Understand Pokémon Showdown team formats

    master

    Pokémon Showdown utilizes three primary team formats depending on the use case:

    1. Export format: Human-readable text used by the client for teambuilder import/export features.
    2. JSON format: Machine-readable format used within the codebase. In TypeScript, these are represented as PokemonSet[].
    3. Packed format: A compressed string format used for sending data via text commands (like /utm), command-line tools, and automated backups.
  7. Use Pokémon Showdown for battle simulation, team management, and Pokédex access

    master

    The 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, and sim/DEX.md respectively.

  8. Understand the Pokémon Showdown high-level architecture

    master

    Pokémon Showdown (PS) is composed of three primary interconnected components:

    1. Game server: Handles chat rooms, matchmaking, and battle simulation. It communicates with the Login server for replay uploads and ladder updates.
    2. 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).
    3. 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.

  9. Locate and access ladder data files

    master

    Ladder data is stored in the config/ladders/ directory. Each ladder is contained within a TSV (Tab-Separated Values) file named using the format FORMATID.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.