Sir Scrubbington's Blog

Competitive Pokemon (VGC) blog :^)

Version Control and Pokemon

Version Control and Pokemon

How you can use systems such as Git and Github to preserve your teams online
By Damon Murdoch

Introduction

For as long as I’ve been playing competitive Pokemon, Pokemon Showdown has been the primary platform for players to build and test teams before using them in tournaments, IRL or otherwise. The platform has an incredible built-in team builder which provides a filterable list of all Pokemon, moves and items and even does a validity check for you before letting you hop onto the ladder and play. However all teams created are hosted in your browser’s local storage, meaning that if you (or your automated system processes) do a cleanup all of your teams will be lost! This means that you will want to use Showdown’s built-in import/export feature frequently or risk losing your work. However, what is the best way of backing up your teams? There are a number of solutions to this problem, the most obvious of which will be briefly discussed below. In addition to this, I've taken the time to develop an application and process which I believe greatly enhances the readability and maintainability of Pokemon teams when storing them online.

Standard Solutions

The following sections will briefly discuss several different methods for storing teams online, and the pros and cons towards each discussed method.

 

1. Pokepaste / Pastebin / Cryptobin via Email

  • Very quick and easy
  • Accessible from anywhere
  • Can share via forwarding
  • Gets messy
  • Hard to track changes
  • Hard to navigate / maintain
  • No real-time collaboration
  • Pokepaste / Pastebin not secured, others may see your pastes

2. Raw Text Upload to Google Drive / Docs

  • Quick and easy
  • Accessible from anywhere
  • Can add other users to collaborate / view
  • Can track changes using google documents history
  • Hard to navigate / maintain

3. Raw Text Upload using Github / Gitlab

  • Relatively simple - Can be achieved using web interface or command line
  • Accessible from anywhere
  • Can add other users to collaborate / view
  • Can track changes using commit history
  • Provide comments on changes using commit messages
  • Hard to navigate / maintain

My Solution

The above solutions are most commonly used and are in most use cases, fine - however I disliked how hard it is to navigate and find teams in the single file format. As a result of this, I seeked to develop my own solution.

Introducing PSManage

[Repository][Download]

PSManage is an application I wrote which takes a given showdown export file and converts it to a folder structure of formats, showdown folders and teams stored in plain text files. For example, it would convert this:

[Example Pokepaste]

To this:

[Example Teams Repository on Github]

Which can be converted back into text and imported just as easily. This allows you to easily navigate and browse your teams after exporting them, as well as tracking changes between individual files (teams) much easier. This is achieved by using the following commands with the application.

To create / update a new folder structure, from a paste:

psmanage export [path-to-text-file] [path-to-folder]

To create / update a Pastebin, from a folder structure:

psmanage import [path-to-folder] [path-to-text-file]

This requires more effort than the other methods, however it is  actually pretty simple to follow once you get used to it and the end results are, in my opinion, worth the extra effort.

Installing PSManage

The executable can be downloaded from the GitHub releases page [link] or you are free to compile it from source yourself. The executable should be either left in a location added to your PATH variable (on Windows) or in the same directory as you plan on keeping your team file and folder.

Using PSManage

The following set of instructions is how I use the application personally, and are for use on Windows. Usage should be similar on other Go-compatible platforms.

Requirements

  • Git (Command Line Preferred) [Link]
  • A GitHub / GitLab / Other account
  • PSManage (Self-compiled or from releases) [Link]

Instructions

Exporting teams from a paste

  1. Open a command line window (PowerShell / CMD) at the folder you plan on saving your teams (e.g. C:/users/(your profile)/teams
  2. Create a new text file in that folder using your favorite text editor, and paste an export of your showdown teams in it
  3. Using your command line window, run PSManage on the text file using the following command:

psmanage export [path-to-text-file] [path-to-folder]

Ensuring that the path to the text file is the file you created containing the export and the path to the folder is where you would like the teams folder to be created.

      4. If this is your first export, you should see a new folder use been created. Move into it 

cd teams 

And create a new git repository.

git init .

      5. Create a new empty repository on your choice of hosting platform (in this tutorial we use GitHub) and add it as a remote location for your repository

  • Ensure that your new repository is private otherwise anybody will have the ability to view (but not edit) your teams!

Git remote add origin (link to github / gitlab repository)

      6. Add all of the content into the new Repository 

git add .

And commit it with a message.

git commit -m "Initial commit!"

Then, push it to the master branch.

git push origin master

      7. Congratulations, you've successfully created your first commit! You should now be able to browse the files online in your GitHub repository, and share them with other users via adding collaborators online.

Accessing your repository from another computer / accessing a repository you have been added to

  1. Open a command line window (PowerShell / CMD) at the folder you plan on saving your teams (e.g. C:/users/(your profile)/teams/
  2. If you have not done so yet, place the psmanage exe file in this folder.
  3. Clone the repository you have been granted access to
  4. Congratulations, you now can fully access the repository from this computer!

Importing teams from a paste

  1. Open a command line window (PowerShell / CMD) at the folder where your teams are stored

(E.g. C:/users/(your profile)/teams/teams)

      2. Ensure you have the latest working version of the teams

Git pull origin master

      3. Move to the parent folder where the text file should be imported 

cd ..

      4. Using your command line window, run PSManage on the text file using the following command:

psmanage import [path-to-folder] [path-to-text-file]

Ensuring that the path to the text file is the file the import should be dumped to and the path to the folder is where your teams are currently stored.

      5. Using your favorite text editor, open up the imported file and paste the contents into your Pokemon Showdown teambuilder.

      6. Congratulations, you've now successfully re-imported your teams!

Automation Scripts

If you get tired of the manual process of using the command line, it’s not too hard to write scripts to automate the process. I’ve created example scripts in my repository in the ‘scripts’ directory.

Automate pulling from the repository

The below script checks for any updates in the git repository, then opens up a new VS Code window 

[Example Script]

Automate pushing to and updating the repository

The below script opens a VS Code window on the file ‘teams.sd’, which you can paste your showdown export into. Once done, you can close the window and hit enter in the terminal and it will run the export, create a new repository (if required), add the remote github repository (if one is not present) and push the latest changes to the remote repository.

[Example Script]

Support

If you have any problems, or encounter bugs in the application you can report them as a problem on GitHub here, or contact me on twitter here.

Conclusion

While my solution may require more setup than any other method, I believe it to be a worthwhile investment for the long-term maintainability for large team libraries. However, basically any solution aside from raw pastebins via email / instant messaging provides the same level of security and access control as any other method, and is the recommended method of storage for overall simplicity and security. I hope that this has been useful for you, and that you find it easier to store and maintain your team libraries in the future. Thanks for reading!