/screeps

screeps repo

Primary LanguageTypeScriptThe UnlicenseUnlicense

screeps-typescript-starter v2.0

Starter kit for TypeScript-based Screeps AI codes.


screeps-typescript-starter is a starter kit for building Screeps AIs in TypeScript. It is based on the original starter kit by Marko Sulamägi, but with extra tools for easy compiling/deploying of scripts to the Screeps server, as well as a base framework for running tests.

Download the latest zipped copy here.

What's new

  • @bonzaiferroni has put out some really useful guides to get started with TypeScript development on Screeps. Go read them! (Guide #1, Guide #2)
  • We've consolidated all of our guides into the wiki page. This README will be simplified to include the essentials to get you up and running. Feel free to contribute to the wiki as well!

Table of contents

Features

  • Automated deploy to public and private Screeps servers
  • Live reload compiling of typescript code
  • Highly configurable environment with sane defaults
  • Pre-configured linting rules customized for screeps
  • Typescript Screeps typings
  • Logger which links with source code and git repo
  • Screeps profiler
  • "Snippets" directory for code you want to save, but don't want compiled or linted
  • Modest starter code to get you started, but not hold your hand

Quick start

By far, the easiest and quickest way to get started with TypeScript development on Screeps is to follow @bonzaiferroni's guides on Screeps World. Go read them!

Requirements

We'll assume you have already downloaded/cloned the starter kit.

  • Node.js (latest LTS is recommended)
  • Yarn - Optional. You can use npm if you don't want to, but this is for your own sanity.

Why Yarn? Yarn has a stronger dependency tree, supports lockfiles, and fixes most of the issues pre-npm@5. It also has a host of unique features as described on their website, and is entirely compatible with npm.

Installing the modules

Run the following the command to install the required packages and TypeScript declaration files if you are using yarn:

$ yarn

or, for npm:

$ npm install

Initial configuration

Configuring Screeps credentials

Create a copy of config/credentials.example.json and rename it to config/credentials.json.

WARNING: This file contains your secret credentials. DO NOT commit it into your repository!

# config/credentials.json
$ cp config/credentials.example.json config/credentials.json

In the newly created credentials.json file, change the email and password properties with your Screeps credentials. The serverPassword, token, and gzip options are only for private servers that support them. If you are uploading to the public Screeps server, you should delete these fields from your credentials file.

Changing the upload branch

Go to config/config.dev.ts, and you'll find the following lines:

const credentials: Credentials = require("./credentials.json");
credentials.branch = "dev";

Change the credentials.branch property you want to initially build and upload to, e.g. "default". Note that due to the Screeps API limitations, you still have to create a branch with a matching name in the Screeps client by cloning an existing branch. The compiler will yell at you when you forgot to do so.

You can also set it to $activeWorld to upload to whatever branch is active in the Screeps world.

Advanced configuration

See Configuration page on the screeps-typescript-starter wiki for more in-depth info on configuration options.

Running the compiler

# To compile and upload your TypeScript files on the fly in "watch mode":
$ npm start

# To compile and deploy once:
$ npm run deploy

Further reading

To find out more about what else you can do with screeps-typescript-starter, head over to the screeps-typescript-starter wiki to find more guides, tips and tricks.

Contributing

Issues, Pull Requests, and Wiki contributions are welcome! Please read the Contributing Guidelines beforehand.

Special thanks

Marko Sulamägi, for the original Screeps/TypeScript sample project.