mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-04-30 20:56:58 -05:00
47 lines
2.2 KiB
Markdown
47 lines
2.2 KiB
Markdown
Pokemon Showdown architecture
|
||
=============================
|
||
|
||
At the highest level, PS is split into three parts:
|
||
|
||
- Client
|
||
- Login server
|
||
- Game server
|
||
|
||
The game server is in this repository, **[smogon/pokemon-showdown](https://github.com/smogon/pokemon-showdown)**, while the client and login server are in **[smogon/pokemon-showdown-client](https://github.com/smogon/pokemon-showdown-client)**. All three communicate directly with each other.
|
||
|
||
|
||
Game server
|
||
-----------
|
||
|
||
The game server is written in TypeScript and runs on Node.js.
|
||
|
||
Its entry point is [server/index.ts](./server/index.ts), which launches several major components:
|
||
|
||
- [server/sockets.ts](./server/sockets.ts) sets up a SockJS (abstracted WebSocket) server to accept connections from clients
|
||
|
||
- [server/users.ts](./server/users.ts) sets up `Users`, which wraps the SockJS connections in a system that handles users
|
||
|
||
- [server/rooms.ts](./server/rooms.ts) sets up `Rooms`, which handles the individual chat rooms and battle rooms
|
||
|
||
- [server/chat.ts](./server/chat.ts) sets up `Chat`, which handles chat commands and messages coming in from users (all client-to-server commands are routed through there)
|
||
|
||
`Rooms` also includes support for battle rooms, which is where the game simulation itself is done. Game simulation code is in [sim/](./sim/).
|
||
|
||
|
||
Client
|
||
------
|
||
|
||
The client is built in a mix of TypeScript and JavaScript, with a mostly hand-rolled framework built on Backbone. There’s a rewrite to migrate it to Preact but it’s very stalled.
|
||
|
||
Its entry point is [index.template.html](https://github.com/smogon/pokemon-showdown-client/blob/master/index.template.html).
|
||
|
||
It was written long ago, so instead of a single JS entry point, it includes a lot of JS files. Everything important is launched from [js/client.js](https://github.com/smogon/pokemon-showdown-client/blob/master/js/client.js).
|
||
|
||
|
||
Login server
|
||
------------
|
||
|
||
The client’s login server, which handles logins and most database interaction, is written in PHP, with a rewrite to TypeScript in progress. The backend is split between a MySQL InnoDB database and a Percona database, with a migration to Postgres planned.
|
||
|
||
Its entry point is [action.php](https://github.com/smogon/pokemon-showdown-client/blob/master/action.php).
|