Skip to content

Commit

Permalink
Merge branch 'smogon:master' into modjoin
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirain1700 authored Dec 19, 2024
2 parents 224ae69 + 8f2e1cb commit 8ccb844
Show file tree
Hide file tree
Showing 539 changed files with 346,455 additions and 85,862 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Publish to npm
on:
push:
branches:
- master
paths:
- 'package.json'
jobs:
test:
uses: ./.github/workflows/test.yml
get-version:
runs-on: ubuntu-latest
outputs:
current_version: ${{ steps.current_version.outputs.version }}
last_version: ${{ steps.last_version.outputs.version }}
token_exists: ${{ steps.check_token.outputs.token }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 50
# Check if the package.json version field has changed since the last push
- name: Get current version from package.json
id: current_version
run: |
echo "version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT
- name: Get the version from the last push
id: last_version
run: |
git checkout ${{ github.event.before }}
echo "version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT
- name: Check if NPM_TOKEN exists
id: check_token
run: |
echo "token=$(if [ -n "${{ secrets.NPM_TOKEN }}" ]; then echo true; else echo false; fi)" >> $GITHUB_OUTPUT
npm-publish:
needs:
- test
- get-version
runs-on: ubuntu-latest
# We only want to publish if the package.json version field has changed
if: needs.get-version.outputs.current_version != needs.get-version.outputs.last_version && needs.get-version.outputs.token_exists == 'true'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm run build
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
52 changes: 51 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_call:

jobs:
build:
Expand All @@ -20,11 +21,60 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 100 # assumes PR/push to master is no larger than 100 commits. Other solutions are needlessly complex.

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- run: npm ci
- run: npm run full-test

- name: Determine which files to lint (if pull request)
if: ${{ github.event_name == 'pull_request' }}
id: changed-files
uses: tj-actions/changed-files@v35
with:
files: |
./config/*.ts
./data/**/*.ts
./lib/*.ts
./server/**/*.ts
./server/**/*.tsx
./sim/**/*.ts
./tools/set-import/*.ts
files_ignore: |
./logs/
./node_modules/
./dist/
./data/**/learnsets.ts
./tools/set-import/importer.js
./tools/set-import/sets
./tools/modlog/converter.js
./server/global-variables.d.ts
- name: Determine whether test/sim or test/random-battles need to run (if pull request)
if: ${{ github.event_name == 'pull_request' }}
id: changed-directories
uses: tj-actions/changed-files@v35
with:
files: |
config/formats.ts
data/**
sim/**
- name: Run selective lint & neccessary tests (if pull request)
if: ${{ github.event_name == 'pull_request' }}
run: npm run full-test-ci
env:
CI: true
FILES: ${{ steps.changed-files.outputs.all_changed_and_modified_files }}
SKIPSIMTESTS: ${{ steps.changed-directories.outputs.all_changed_and_modified_files == '' }}

- name: Run full lint & test (if push to master)
run: npm run full-test
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
env:
CI: true
42 changes: 42 additions & 0 deletions .github/workflows/update_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Update the npm package version

on:
workflow_dispatch:
inputs:
version:
required: true
type: choice
description: Version type
default: patch
options:
- major
- minor
- patch
- premajor
- preminor
- prepatch
- prerelease
jobs:
update_version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
- id: bump_version
run: |
echo "old_version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT
npm version ${{ github.event.inputs.version }} --no-git-tag-version
echo "new_version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT
- uses: peter-evans/create-pull-request@v4
with:
title: Bump package.json version to v${{ steps.bump_version.outputs.new_version }}}
body: |
Bump package.json version from `v${{ steps.bump_version.outputs.old_version }}` to `v${{ steps.bump_version.outputs.new_version }}`
commit-message: Bump package.json version to v${{ steps.bump_version.outputs.new_version }}
branch: npm-version-bump
base: master

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/config/*
!/config/formats.ts
/logs/*
/logs/**/*
/test/modlogs
/test/replays/*.html
/node_modules
Expand Down
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/config/*
!/config/formats.ts
!/config/config-example.js
/logs/*
/test/modlogs
/node_modules
Expand Down
28 changes: 19 additions & 9 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@ Pokemon Showdown architecture

At the highest level, PS is split into three parts:

- Client
- Login server
- Game server
- Game server (**[smogon/pokemon-showdown](https://github.com/smogon/pokemon-showdown)**)
- Client (**[smogon/pokemon-showdown-client](https://github.com/smogon/pokemon-showdown-client)**)
- Login server (**[smogon/pokemon-showdown-loginserver](https://github.com/smogon/pokemon-showdown-loginserver)**)

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.
All three communicate directly with each other.

A user starts by visiting `https://play.pokemonshowdown.com/`. This is handled by an Apache server (in the Client), which serves mostly static files but uses some PHP (legacy, intended to be migrated to Loginserver).

The user's web browser (running Client code) will then communicate with the Login server (mounted at `https://play.pokemonshowdown.com/api/` to handle logins mostly, or otherwise interface with the Client databases one way or another).

The user's web browser will also connect to the Game server, through SockJS. The Game server handles the chat rooms, matchmaking, and actual battle simulation.

The Game server also communicates with the Login server, to handle replay uploads (and, for the main server, ladder updates).


Game server
Expand All @@ -25,22 +33,24 @@ Its entry point is [server/index.ts](./server/index.ts), which launches several

- [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/).
`Rooms` also includes support for battle rooms, which is where the server connects to the game simulator itself. 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).
Its entry point is [index.template.html](https://github.com/smogon/pokemon-showdown-client/blob/master/play.pokemonshowdown.com/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).
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/play.pokemonshowdown.com/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.
The client’s login server, which handles logins and most database interaction, is written in TypeScript. The backend is currently split between a MySQL InnoDB database (for users, ladder, and most other things) and a Postgres (technically Cockroach) database (for Replays).

Its entry point is [server.ts](https://github.com/smogon/pokemon-showdown-loginserver/blob/master/src/server.ts).

Its entry point is [action.php](https://github.com/smogon/pokemon-showdown-client/blob/master/action.php).
It's intended to replace all of the old PHP code in the Client, but that migration is only halfway done at the moment.
8 changes: 6 additions & 2 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
config/formats.ts @KrisXV @Marty-D
data/mods/*/random-teams.ts @AnnikaCodes
data/mods/ssb/ @HoeenCoder @KrisXV
data/mods/gen9ssb/ @HoeenCoder @HisuianZoroark @KrisXV
data/random-sets.json @MathyFurret @ACakeWearingAHat @livid-washed @adrivrie
data/random-teams.ts @AnnikaCodes @KrisXV @MathyFurret @ACakeWearingAHat @livid-washed @adrivrie
data/text/ @Marty-D
databases/ @monsanto
lib/sql.ts @mia-pi-git
server/artemis/* @mia-pi-git
server/chat-plugins/abuse-monitor.ts @mia-pi-git
server/chat-plugins/friends.ts @mia-pi-git
Expand All @@ -13,15 +14,18 @@ server/chat-plugins/hosts.ts @AnnikaCodes
server/chat-plugins/helptickets*.ts @mia-pi-git
server/chat-plugins/mafia.ts @HoeenCoder
server/chat-plugins/othermetas.ts @KrisXV
server/chat-plugins/permalocks.ts @mia-pi-git
server/chat-plugins/quotes.ts @mia-pi-git @KrisXV
server/chat-plugins/random-battles.ts @KrisXV @AnnikaCodes
server/chat-plugins/repeats.ts @AnnikaCodes
server/chat-plugins/responder.ts @mia-pi-git
server/chat-plugins/rock-paper-scissors.ts @mia-pi-git
server/chat-plugins/sample-teams.ts @KrisXV
server/chat-plugins/scavenger*.ts @xfix @sparkychildcharlie @PartMan7
sever/chat-plugins/teams.ts @mia-pi-git
server/chat-plugins/the-studio.ts @KrisXV
server/chat-plugins/trivia/ @AnnikaCodes
server/friends.ts @mia-pi-git
server/private-messages/* @mia-pi-git
server/chat-plugins/username-prefixes.ts @AnnikaCodes
server/chat-plugins/wifi.ts @KrisXV
server/friends.ts @mia-pi-git
Expand Down
2 changes: 1 addition & 1 deletion COMMANDLINE.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Note: Commands that ask for a team want the team in [packed team format](./sim/T
- Simulates a battle, taking input to stdin and writing output to stdout

Using Pokémon Showdown as a command-line simulator is documented at:
[sim/README.md](./README.md)
[sim/README.md](./sim/README.md)

`./pokemon-showdown json-team`

Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ BAD:

```ts
// if ten seconds have passed and the user is staff
if (now > then + 10_000 && '&@%'.includes(user.tempGroup)) {
if (now > then + 10_000 && '~@%'.includes(user.tempGroup)) {
```
GOOD:
```ts
const tenSecondsPassed = now > then + 10_000;
const userIsStaff = '&@%'.includes(user.tempGroup);
const userIsStaff = '~@%'.includes(user.tempGroup);
if (tenSecondsPassed && userIsStaff) {
```
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2011-2022 Guangcong Luo and other contributors http://pokemonshowdown.com/
Copyright (c) 2011-2024 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
Expand Down
2 changes: 1 addition & 1 deletion PROTOCOL.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Messages from the user to the server are in the form:

`ROOMID` can optionally be left blank if unneeded (commands like `/join lobby`
can be sent anywhere). Responses will be sent to a PM box with no username
(so `|/command` is equivalent to `|/pm &, /command`).
(so `|/command` is equivalent to `|/pm ~, /command`).

`TEXT` can contain newlines, in which case it'll be treated the same
way as if each line were sent to the room separately.
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Pokémon Showdown is many things:

- [server/README.md](./server/README.md)

Pokémon Showdown simulates singles, doubles and triples battles in all the games out so far (Generations 1 through 8).
Pokémon Showdown simulates singles, doubles and triples battles in all the games out so far (Generations 1 through 9).


Documentation quick links
Expand Down Expand Up @@ -89,8 +89,10 @@ Staff
- Andrew Werner [HoeenHero] - Development
- Annika L. [Annika] - Development
- Chris Monsanto [chaos] - Development, Sysadmin
- Leonard Craft III - Research (game mechanics)
- Kris Johnson [dhelmise] - Development
- Leonard Craft III [DaWoblefet] - Research (game mechanics)
- Mathieu Dias-Martins [Marty-D] - Research (game mechanics), Development
- Mia A [Mia] - Development

Contributors

Expand Down
19 changes: 11 additions & 8 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"use strict";

try {
// technically this was introduced in Node 11, but we'll ask for the most recent LTS with it to be safe
[].flatMap(x => x);
// technically this was introduced in Node 15, but we'll ask for the most recent LTS with it to be safe
Promise.any([null]);
} catch (e) {
console.log("We require Node.js version 14 or later; you're using " + process.version);
console.log("We require Node.js version 16 or later; you're using " + process.version);
process.exit(1);
}

Expand All @@ -30,11 +30,6 @@ try {
console.log('Installing dependencies...');
shell('npm install');
}
// for some reason, esbuild won't be requirable until a tick has passed
// see https://stackoverflow.com/questions/53270058/node-cant-find-certain-modules-after-synchronous-install
setImmediate(() => {
require('./tools/build-utils').transpile(force, decl);
});

// Make sure config.js exists. If not, copy it over synchronously from
// config-example.js, since it's needed before we can start the server
Expand All @@ -49,3 +44,11 @@ try {
fs.readFileSync('config/config-example.js')
);
}

// for some reason, esbuild won't be requirable until a tick has passed
// see https://stackoverflow.com/questions/53270058/node-cant-find-certain-modules-after-synchronous-install
setImmediate(() => {
// npm package, don't rebuild
if (process.argv[2] === 'postinstall' && fs.existsSync('dist')) return;
require('./tools/build-utils').transpile(force, decl);
});
2 changes: 1 addition & 1 deletion config/CUSTOM-RULES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Pokémon Showdown supports custom rules in three ways:

- Tournaments, using the command `/tour rules RULES` (see the [Tournament command help][tour-help])

- Custom formats on your side server, by editing `config/formats.js`
- Custom formats on your side server, by editing `config/formats.ts`

[tour-help]: https://www.smogon.com/forums/threads/pok%C3%A9mon-showdown-forum-rules-resources-read-here-first.3570628/#post-6777489

Expand Down
Loading

0 comments on commit 8ccb844

Please sign in to comment.