Starter kit for TypeScript-based Screeps AI codes.
This starter kit is a modified version of the original Screeps/TypeScript sample project by Marko Sulamägi.
DO NOT run the Steam client directly out of the same location as the gulp file watcher. The steam client will attempt to sync new files on the server back down to your local workspace.
After you create a spawn, this bot will create 4 creeps which will start to harvest the closest source. The bots harvest, then transfer energy back to Spawn. If a creep's lifespan has depleted enough, it will refill in Spawn.
- Node.js (v4.0.0+)
- Gulp -
npm install -g gulp
- TypeScript -
npm install -g typescript
- Typings -
npm install -g typings
First, create a copy of config.example.json
and rename it to config.json
.
$ cp config.example.json config.json
Then change the username
and password
properties with your Screeps credentials.
If you want to push your code to another branch, for example, if you have some sort of a staging branch where you test around in Simulation mode, we have left a branch
option for you to easily change the target branch of the upload process. The default
branch is set as the default.
WARNING: DO NOT commit this file into your repository!
Then run the following the command to install the required npm packages and TypeScript type definitions.
$ npm install
# To compile your TypeScript files on the fly
$ npm start
# To deploy the code to Screeps
$ npm run deploy
TypeScript developers disagree about whether the noImplicitAny
flag should be true
or false
. There is no correct answer and you can change the flag later. But your choice now can make a difference in larger projects so it merits discussion.
When the noImplicitAny
flag is false
(the default), the compiler silently defaults the type of a variable to any
if it cannot infer the type based on how the variable is used.
When the noImplicitAny
flag is true
and the TypeScript compiler cannot infer the type, it still generates the JavaScript files. But it also reports an error. Many seasoned developers prefer this stricter setting because type checking catches more unintentional errors at compile time.
In this starter kit, the noImplicitAny
compiler flag is set to false
to make it easier for beginners. If you want a more stricter environment, you can change the noImplicitAny
flag to true
on the tsconfig.json
file.
Source: https://angular.io/docs/ts/latest/guide/typescript-configuration.html
TSLint checks your TypeScript code for readability, maintainability, and functionality errors, and can also enforce coding style standards.
After each successful compiling of the project, TSLint will parse the TypeScript source files and display a warning for any issues it will find.
This project provides TSLint rules through a tslint.json
file, which extends the recommended set of rules from TSLint github repository: https://github.com/palantir/tslint/blob/next/src/configs/recommended.ts
We made some changes to those rules, which we considered necessary and/or relevant to a proper Screeps project:
- set the forin rule to
false
, it was forcingfor ( ... in ...)
loops to check if object members were not coming from the class prototype. - set the interface-name rule to
false
, in order to allow interfaces that are not prefixed withI
. - set the no-console rule to
false
, in order to allow usingconsole
. - in the variable-name rule, added
allow-leading-underscore
.
If you believe that some rules should not apply to a part of your code, you can use flags to let TSLint know about it: https://palantir.github.io/tslint/usage/rule-flags/
More info about TSLint: https://palantir.github.io/tslint/
- Fork it
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Create a new Pull Request
Marko Sulamägi, for the original Screeps/TypeScript sample project.