├── .gitattributes ├── .gitignore ├── README.md ├── bower.json └── src ├── ConstructionSite.js ├── Creep.js ├── Energy.js ├── Flag.js ├── Game.js ├── Map.js ├── Room.js ├── RoomPosition.js ├── Source.js ├── Spawn.js ├── Structure.js └── screeps.js /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.json eol=lf 3 | *.md eol=lf 4 | *.js eol=lf 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /bower_components/ 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # *No longer maintained!* 2 | 3 | Screeps API 4 | =========== 5 | 6 | This library provides IDE type-hinting for the Screeps API, allowing you to use autocompletion within your project. 7 | 8 | Installation 9 | ============ 10 | 11 | The easiest and most recommended way to install the Screeps API library is [through Bower](http://bower.io/). 12 | 13 | Add the library to your bower.json dependencies: 14 | ```json 15 | { 16 | "dependencies": { 17 | "estelsmith-screeps-api": "0.0.1" 18 | } 19 | } 20 | ``` 21 | 22 | Then, simply run the Bower install command to install the library. 23 | ``` 24 | $ bower install 25 | ``` 26 | 27 | Usage 28 | ===== 29 | 30 | You will never directly use this library. Your IDE should automatically index the library, allowing you to utilize it 31 | for autocompletion. 32 | 33 | Happy Screeping! 34 | 35 | License 36 | ======= 37 | The Screeps API library is made available under the MIT license, making it free for anyone to use and modify. 38 | 39 | ``` 40 | Copyright (c) 2014-2015 Cascade Media, LLC 41 | 42 | Permission is hereby granted, free of charge, to any person obtaining a copy 43 | of this software and associated documentation files (the "Software"), to deal 44 | in the Software without restriction, including without limitation the rights 45 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 46 | copies of the Software, and to permit persons to whom the Software is 47 | furnished to do so, subject to the following conditions: 48 | 49 | The above copyright notice and this permission notice shall be included in 50 | all copies or substantial portions of the Software. 51 | 52 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 53 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 54 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 55 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 56 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 57 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 58 | THE SOFTWARE. 59 | ``` 60 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "estelsmith-screeps-api", 3 | "version": "0.0.1", 4 | "authors": [ 5 | "Estel Smith " 6 | ], 7 | "description": "Provides IDE type-hinting for the Screeps API", 8 | "main": "src/screeps.js", 9 | "keywords": [ 10 | "screeps", 11 | "api", 12 | "typehint" 13 | ], 14 | "license": "MIT" 15 | } 16 | -------------------------------------------------------------------------------- /src/ConstructionSite.js: -------------------------------------------------------------------------------- 1 | var ConstructionSite = function () {}; 2 | 3 | ConstructionSite.prototype = { 4 | /** 5 | * @type string 6 | */ 7 | id: '', 8 | 9 | /** 10 | * @type boolean 11 | */ 12 | my: false, 13 | 14 | /** 15 | * @type object 16 | */ 17 | owner: null, 18 | 19 | /** 20 | * @type RoomPosition 21 | */ 22 | pos: null, 23 | 24 | /** 25 | * @type number 26 | */ 27 | progress: 0, 28 | 29 | /** 30 | * @type number 31 | */ 32 | progressTotal: 0, 33 | 34 | /** 35 | * @type Room 36 | */ 37 | room: null, 38 | 39 | /** 40 | * @type {STRUCTURE_EXTENSION|STRUCTURE_RAMPART|STRUCTURE_ROAD|STRUCTURE_SPAWN|STRUCTURE_WALL|STRUCTURE_LINK} 41 | */ 42 | structureType: null, 43 | 44 | /** 45 | * @return {OK|ERR_NOT_OWNER} 46 | */ 47 | remove: function () {} 48 | }; 49 | -------------------------------------------------------------------------------- /src/Creep.js: -------------------------------------------------------------------------------- 1 | var Creep = function () {}; 2 | 3 | Creep.prototype = { 4 | /** 5 | * @type Array 6 | */ 7 | body: null, 8 | 9 | /** 10 | * @type number 11 | */ 12 | energy: 0, 13 | 14 | /** 15 | * @type number 16 | */ 17 | energyCapacity: 0, 18 | 19 | /** 20 | * @type number 21 | */ 22 | fatigue: 0, 23 | 24 | /** 25 | * @type number 26 | */ 27 | hits: 0, 28 | 29 | /** 30 | * @type number 31 | */ 32 | hitsMax: 0, 33 | 34 | /** 35 | * @type string 36 | */ 37 | id: '', 38 | 39 | /** 40 | * @type object 41 | */ 42 | memory: {}, 43 | 44 | /** 45 | * @type boolean 46 | */ 47 | my: false, 48 | 49 | /** 50 | * @type string 51 | */ 52 | name: '', 53 | 54 | /** 55 | * @type object 56 | */ 57 | owner: {}, 58 | 59 | /** 60 | * @type RoomPosition 61 | */ 62 | pos: null, 63 | 64 | /** 65 | * @type Room 66 | */ 67 | room: null, 68 | 69 | /** 70 | * @type boolean 71 | */ 72 | spawning: false, 73 | 74 | /** 75 | * @type number 76 | */ 77 | ticksToLive: 0, 78 | 79 | /** 80 | * @param {Creep|Spawn|Structure} target 81 | * @return {OK|ERR_NOT_OWNER|ERR_BUSY|ERR_INVALID_TARGET|ERR_NOT_IN_RANGE|ERR_NO_BODYPART} 82 | */ 83 | attack: function (target) {}, 84 | 85 | /** 86 | * @param {ConstructionSite} target 87 | * @return {OK|ERR_NOT_OWNER|ERR_BUSY|ERR_NOT_ENOUGH_ENERGY|ERR_INVALID_TARGET|ERR_NOT_IN_RANGE|ERR_NO_BODYPART|ERR_RCL_NOT_ENOUGH} 88 | */ 89 | build: function (target) {}, 90 | 91 | /** 92 | * @param {string} methodName 93 | * @return {OK|ERR_NOT_FOUND} 94 | */ 95 | cancelOrder: function (methodName) {}, 96 | 97 | /** 98 | * @param {Structure} target 99 | * @return {OK|ERR_NOT_OWNER|ERR_BUSY|ERR_INVALID_TARGET|ERR_NOT_IN_RANGE|ERR_GCL_NOT_ENOUGH} 100 | */ 101 | claimController: function (target) {}, 102 | 103 | /** 104 | * @param {number} amount 105 | * @return {OK|ERR_NOT_OWNER|ERR_BUSY|ERR_NOT_ENOUGH_ENERGY} 106 | */ 107 | dropEnergy: function (amount) {}, 108 | 109 | /** 110 | * @param {MOVE|WORK|CARRY|ATTACK|RANGED_ATTACK|HEAL|TOUGH} type 111 | * @return number 112 | */ 113 | getActiveBodyParts: function (type) {}, 114 | 115 | /** 116 | * @param {Source} target 117 | * @return {OK|ERR_NOT_OWNER|ERR_BUSY|ERR_NOT_ENOUGH_ENERGY|ERR_INVALID_TARGET|ERR_NOT_IN_RANGE|ERR_NO_BODYPART} 118 | */ 119 | harvest: function (target) {}, 120 | 121 | /** 122 | * @param {Creep} target 123 | * @return {OK|ERR_NOT_OWNER|ERR_BUSY|ERR_INVALID_TARGET|ERR_NOT_IN_RANGE|ERR_NO_BODYPART} 124 | */ 125 | heal: function (target) {}, 126 | 127 | /** 128 | * @param {TOP|TOP_RIGHT|RIGHT|BOTTOM_RIGHT|BOTTOM|BOTTOM_LEFT|LEFT|TOP_LEFT} direction 129 | * @return {OK|ERR_NOT_OWNER|ERR_BUSY|ERR_TIRED|ERR_NO_BODYPART} 130 | */ 131 | move: function (direction) {}, 132 | 133 | /** 134 | * @param {object} target 135 | * @param {object} options 136 | * @return {OK|ERR_NOT_OWNER|ERR_BUSY|ERR_TIRED|ERR_NO_BODYPART|ERR_INVALID_TARGET|ERR_NO_PATH} 137 | */ 138 | moveTo: function (target, options) {}, 139 | 140 | /** 141 | * @param {boolean} enabled 142 | * @return {OK|ERR_NOT_OWNER|ERR_INVALID_ARGS} 143 | */ 144 | notifyWhenAttacked: function (enabled) {}, 145 | 146 | /** 147 | * @param {Energy} target 148 | * @return {OK|ERR_NOT_OWNER|ERR_BUSY|ERR_INVALID_TARGET|ERR_FULL|ERR_NOT_IN_RANGE} 149 | */ 150 | pickup: function (target) {}, 151 | 152 | /** 153 | * @param {Creep|Spawn|Structure} target 154 | * @return {OK|ERR_NOT_OWNER|ERR_BUSY|ERR_INVALID_TARGET|ERR_NOT_IN_RANGE|ERR_NO_BODYPART} 155 | */ 156 | rangedAttack: function (target) {}, 157 | 158 | /** 159 | * @param {Creep} target 160 | * @return {OK|ERR_NOT_OWNER|ERR_BUSY|ERR_INVALID_TARGET|ERR_NOT_IN_RANGE|ERR_NO_BODYPART} 161 | */ 162 | rangedHeal: function (target) {}, 163 | 164 | /** 165 | * @return {OK|ERR_NOT_OWNER|ERR_BUSY|ERR_NO_BODYPART} 166 | */ 167 | rangedMassAttack: function () {}, 168 | 169 | /** 170 | * @param {Spawn|Structure} target 171 | * @return {OK|ERR_NOT_OWNER|ERR_BUSY|ERR_NOT_ENOUGH_ENERGY|ERR_INVALID_TARGET|ERR_NOT_IN_RANGE|ERR_NO_BODYPART} 172 | */ 173 | repair: function (target) {}, 174 | 175 | /** 176 | * @param {string} message 177 | * @return {OK|ERR_NOT_OWNER|ERR_BUSY} 178 | */ 179 | say: function (message) {}, 180 | 181 | /** 182 | * @return {OK|ERR_NOT_OWNER|ERR_BUSY} 183 | */ 184 | suicide: function () {}, 185 | 186 | /** 187 | * @param {Creep|Spawn|Structure} target 188 | * @param {number} amount 189 | * @return {OK|ERR_NOT_OWNER|ERR_BUSY|ERR_NOT_ENOUGH_ENERGY|ERR_INVALID_TARGET|ERR_FULL|ERR_NOT_IN_RANGE|ERR_INVALID_ARGS} 190 | */ 191 | transferEnergy: function (target, amount) {}, 192 | 193 | /** 194 | * @param {Structure} target 195 | * @return {OK|ERR_NOT_OWNER|ERR_BUSY|ERR_INVALID_TARGET|ERR_NOT_IN_RANGE} 196 | */ 197 | unclaimController: function (target) {}, 198 | 199 | /** 200 | * @param {Structure} target 201 | * @return {OK|ERR_NOT_OWNER|ERR_BUSY|ERR_NOT_ENOUGH_ENERGY|ERR_INVALID_TARGET|ERR_NOT_IN_RANGE|ERR_NO_BODYPART} 202 | */ 203 | upgradeController: function (target) {} 204 | }; 205 | -------------------------------------------------------------------------------- /src/Energy.js: -------------------------------------------------------------------------------- 1 | var Energy = function () {}; 2 | 3 | Energy.prototype = { 4 | /** 5 | * @type number 6 | */ 7 | energy: 0, 8 | 9 | /** 10 | * @type string 11 | */ 12 | id: '', 13 | 14 | /** 15 | * @type RoomPosition 16 | */ 17 | pos: null, 18 | 19 | /** 20 | * @type Room 21 | */ 22 | room: null 23 | }; 24 | -------------------------------------------------------------------------------- /src/Flag.js: -------------------------------------------------------------------------------- 1 | var Flag = function () {}; 2 | 3 | Flag.prototype = { 4 | /** 5 | * @type string 6 | */ 7 | id: '', 8 | 9 | /** 10 | * @type {COLOR_WHITE|COLOR_GREY|COLOR_RED|COLOR_PURPLE|COLOR_BLUE|COLOR_CYAN|COLOR_GREEN|COLOR_YELLOW|COLOR_ORANGE|COLOR_BROWN} 11 | */ 12 | color: null, 13 | 14 | /** 15 | * @type string 16 | */ 17 | name: '', 18 | 19 | /** 20 | * @type RoomPosition 21 | */ 22 | pos: null, 23 | 24 | /** 25 | * @type Room 26 | */ 27 | room: null, 28 | 29 | /** 30 | * @type string 31 | */ 32 | roomName: '', 33 | 34 | /** 35 | * @return {OK} 36 | */ 37 | remove: function () {} 38 | }; 39 | -------------------------------------------------------------------------------- /src/Game.js: -------------------------------------------------------------------------------- 1 | var Game = function () {}; 2 | 3 | Game.prototype = { 4 | /** 5 | * @type number 6 | */ 7 | cpuLimit: 0, 8 | 9 | /** 10 | * @type Creep[] 11 | */ 12 | creeps: [], 13 | 14 | /** 15 | * @type Flag[] 16 | */ 17 | flags: [], 18 | 19 | /** 20 | * @type Map 21 | */ 22 | map: null, 23 | 24 | /** 25 | * @type Room[] 26 | */ 27 | rooms: [], 28 | 29 | /** 30 | * @type Spawn[] 31 | */ 32 | spawns: [], 33 | 34 | /** 35 | * @type Structure[] 36 | */ 37 | structures: [], 38 | 39 | /** 40 | * @type number 41 | */ 42 | time: 0, 43 | 44 | /** 45 | * @param {string} id 46 | * @return object|null 47 | */ 48 | getObjectById: function (id) {}, 49 | 50 | /** 51 | * @return number 52 | */ 53 | getUsedCpu: function () {}, 54 | 55 | /** 56 | * @param {string} message 57 | * @param {number} groupInterval 58 | */ 59 | notify: function (message, groupInterval) {} 60 | }; 61 | -------------------------------------------------------------------------------- /src/Map.js: -------------------------------------------------------------------------------- 1 | var Map = function () {}; 2 | 3 | Map.prototype = { 4 | /** 5 | * @param {string|Room} fromRoom 6 | * @param {string|Room} toRoom 7 | * @return {FIND_EXIT_TOP|FIND_EXIT_RIGHT|FIND_EXIT_BOTTOM|FIND_EXIT_LEFT|ERR_NO_PATH|ERR_INVALID_ARGS} 8 | */ 9 | findExit: function (fromRoom, toRoom) {}, 10 | 11 | /** 12 | * @param {string|Room} fromRoom 13 | * @param {string|Room} toRoom 14 | * @return {Array|ERR_NO_PATH} 15 | */ 16 | findRoute: function (fromRoom, toRoom) {} 17 | }; 18 | -------------------------------------------------------------------------------- /src/Room.js: -------------------------------------------------------------------------------- 1 | var Room = function () {}; 2 | 3 | Room.prototype = { 4 | /** 5 | * @type Structure 6 | */ 7 | controller: null, 8 | 9 | /** 10 | * @type object 11 | */ 12 | memory: {}, 13 | 14 | /** 15 | * @type {MODE_SIMULATION|MODE_SURVIVAL|MODE_WORLD|MODE_ARENA} 16 | */ 17 | mode: null, 18 | 19 | /** 20 | * @type string 21 | */ 22 | name: '', 23 | 24 | /** 25 | * @type object 26 | */ 27 | survivalInfo: null, 28 | 29 | /** 30 | * @param {object|RoomPosition} pos 31 | * @param {STRUCTURE_EXTENSION|STRUCTURE_RAMPART|STRUCTURE_ROAD|STRUCTURE_SPAWN|STRUCTURE_WALL} structureType 32 | * @return {OK|ERR_INVALID_TARGET|ERR_INVALID_ARGS|ERR_RCL_NOT_ENOUGH} 33 | */ 34 | createConstructionSite: function (pos, structureType) {}, 35 | 36 | /** 37 | * @param {object|RoomPosition} pos 38 | * @param {string} name 39 | * @param {COLOR_WHITE|COLOR_GREY|COLOR_RED|COLOR_PURPLE|COLOR_BLUE|COLOR_CYAN|COLOR_GREEN|COLOR_YELLOW|COLOR_ORANGE|COLOR_BROWN} color 40 | */ 41 | createFlag: function (pos, name, color) {}, 42 | 43 | /** 44 | * @param {FIND_CREEPS|FIND_MY_CREEPS|FIND_HOSTILE_CREEPS|FIND_MY_SPAWNS|FIND_HOSTILE_SPAWNS|FIND_SOURCES|FIND_SOURCES_ACTIVE|FIND_DROPPED_ENERGY|FIND_STRUCTURES|FIND_MY_STRUCTURES|FIND_HOSTILE_STRUCTURES|FIND_FLAGS|FIND_CONSTRUCTION_SITES|FIND_EXIT_TOP|FIND_EXIT_RIGHT|FIND_EXIT_BOTTOM|FIND_EXIT_LEFT|FIND_EXIT} type 45 | * @param {object} opts 46 | * @return Array 47 | */ 48 | find: function (type, opts) {}, 49 | 50 | /** 51 | * @param {string|Room} room 52 | * @return {FIND_EXIT_TOP|FIND_EXIT_RIGHT|FIND_EXIT_BOTTOM|FIND_EXIT_LEFT|ERR_NO_PATH|ERR_INVALID_ARGS} 53 | */ 54 | findExitTo: function (room) {}, 55 | 56 | /** 57 | * @param {RoomPosition} fromPos 58 | * @param {RoomPosition} toPos 59 | * @param {object} opts 60 | * @return Array 61 | */ 62 | findPath: function (fromPos, toPos, opts) {}, 63 | 64 | /** 65 | * @param {number} x 66 | * @param {number} y 67 | * @return RoomPosition 68 | */ 69 | getPositionAt: function (x, y) {}, 70 | 71 | /** 72 | * @param {object|RoomPosition} target 73 | * @return Array 74 | */ 75 | lookAt: function (target) {}, 76 | 77 | /** 78 | * @param {number} top 79 | * @param {number} left 80 | * @param {number} bottom 81 | * @param {number} right 82 | * @return Array 83 | */ 84 | lookAtArea: function (top, left, bottom, right) {}, 85 | 86 | /** 87 | * @param {string} type 88 | * @param {object|RoomPosition} target 89 | * @return object 90 | */ 91 | lookForAt: function (type, target) {}, 92 | 93 | /** 94 | * @param {string} type 95 | * @param {number} top 96 | * @param {number} left 97 | * @param {number} bottom 98 | * @param {number} right 99 | * @return Array 100 | */ 101 | lookForAtArea: function (type, top, left, bottom, right) {}, 102 | 103 | /** 104 | * @param {string} description 105 | */ 106 | makeSnapshot: function (description) {} 107 | }; 108 | -------------------------------------------------------------------------------- /src/RoomPosition.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {number} x 3 | * @param {number} y 4 | * @param {string} roomName 5 | * @constructor 6 | */ 7 | var RoomPosition = function (x, y, roomName) {}; 8 | 9 | RoomPosition.prototype = { 10 | /** 11 | * @type string 12 | */ 13 | roomName: '', 14 | 15 | /** 16 | * @type number 17 | */ 18 | x: 0, 19 | 20 | /** 21 | * @type number 22 | */ 23 | y: 0, 24 | 25 | /** 26 | * @param {FIND_CREEPS|FIND_MY_CREEPS|FIND_HOSTILE_CREEPS|FIND_MY_SPAWNS|FIND_HOSTILE_SPAWNS|FIND_SOURCES|FIND_SOURCES_ACTIVE|FIND_DROPPED_ENERGY|FIND_STRUCTURES|FIND_MY_STRUCTURES|FIND_HOSTILE_STRUCTURES|FIND_FLAGS|FIND_CONSTRUCTION_SITES|FIND_EXIT_TOP|FIND_EXIT_RIGHT|FIND_EXIT_BOTTOM|FIND_EXIT_LEFT|FIND_EXIT} type 27 | * @param {object} opts 28 | * @return object 29 | */ 30 | findClosest: function (type, opts) {}, 31 | 32 | /** 33 | * @param {FIND_CREEPS|FIND_MY_CREEPS|FIND_HOSTILE_CREEPS|FIND_MY_SPAWNS|FIND_HOSTILE_SPAWNS|FIND_SOURCES|FIND_SOURCES_ACTIVE|FIND_DROPPED_ENERGY|FIND_STRUCTURES|FIND_MY_STRUCTURES|FIND_HOSTILE_STRUCTURES|FIND_FLAGS|FIND_CONSTRUCTION_SITES|FIND_EXIT_TOP|FIND_EXIT_RIGHT|FIND_EXIT_BOTTOM|FIND_EXIT_LEFT|FIND_EXIT} type 34 | * @param {number} range 35 | * @param {object} opts 36 | * @return Array 37 | */ 38 | findInRange: function (type, range, opts) {}, 39 | 40 | /** 41 | * @param {object|RoomPosition} target 42 | * @param {object} opts 43 | * @return Array 44 | */ 45 | findPathTo: function (target, opts) {}, 46 | 47 | /** 48 | * @param {object|RoomPosition} target 49 | * @return {TOP|TOP_RIGHT|RIGHT|BOTTOM_RIGHT|BOTTOM|BOTTOM_LEFT|LEFT|TOP_LEFT} 50 | */ 51 | getDirectionTo: function (target) {}, 52 | 53 | /** 54 | * @param {object|RoomPosition} target 55 | * @return number 56 | */ 57 | getRangeTo: function (target) {}, 58 | 59 | /** 60 | * @param {RoomPosition} toPos 61 | * @param {number} range 62 | * @return boolean 63 | */ 64 | inRangeTo: function (toPos, range) {}, 65 | 66 | /** 67 | * @param {object|RoomPosition} target 68 | * @return boolean 69 | */ 70 | isEqualTo: function (target) {}, 71 | 72 | /** 73 | * @param {object|RoomPosition} target 74 | * @return boolean 75 | */ 76 | isNearTo: function (target) {} 77 | }; 78 | -------------------------------------------------------------------------------- /src/Source.js: -------------------------------------------------------------------------------- 1 | var Source = function () {}; 2 | 3 | Source.prototype = { 4 | /** 5 | * @type number 6 | */ 7 | energy: 0, 8 | 9 | /** 10 | * @type number 11 | */ 12 | energyCapacity: 0, 13 | 14 | /** 15 | * @type string 16 | */ 17 | id: '', 18 | 19 | /** 20 | * @type RoomPosition 21 | */ 22 | pos: null, 23 | 24 | /** 25 | * @type Room 26 | */ 27 | room: null, 28 | 29 | /** 30 | * @type number 31 | */ 32 | ticksToRegeneration: 0 33 | }; 34 | -------------------------------------------------------------------------------- /src/Spawn.js: -------------------------------------------------------------------------------- 1 | var Spawn = function () {}; 2 | 3 | Spawn.prototype = { 4 | /** 5 | * @type number 6 | */ 7 | energy: 0, 8 | 9 | /** 10 | * @type number 11 | */ 12 | energyCapacity: 0, 13 | 14 | /** 15 | * @type number 16 | */ 17 | hits: 0, 18 | 19 | /** 20 | * @type number 21 | */ 22 | hitsMax: 0, 23 | 24 | /** 25 | * @type string 26 | */ 27 | id: '', 28 | 29 | /** 30 | * @type object 31 | */ 32 | memory: {}, 33 | 34 | /** 35 | * @type boolean 36 | */ 37 | my: false, 38 | 39 | /** 40 | * @type string 41 | */ 42 | name: '', 43 | 44 | /** 45 | * @type object 46 | */ 47 | owner: {}, 48 | 49 | /** 50 | * @type RoomPosition 51 | */ 52 | pos: null, 53 | 54 | /** 55 | * @type Room 56 | */ 57 | room: null, 58 | 59 | /** 60 | * @type STRUCTURE_SPAWN 61 | */ 62 | structureType: STRUCTURE_SPAWN, 63 | 64 | /** 65 | * @type object|null 66 | */ 67 | spawning: null, 68 | 69 | /** 70 | * @param {Array} body 71 | * @param {string} name 72 | * @return {OK|ERR_NOT_OWNER|ERR_NAME_EXISTS|ERR_BUSY|ERR_NOT_ENOUGH_ENERGY|ERR_INVALID_ARGS} 73 | */ 74 | canCreateCreep: function (body, name) {}, 75 | 76 | /** 77 | * @param {Array} body 78 | * @param {string} name 79 | * @param {object} memory 80 | * @return {string|ERR_NOT_OWNER|ERR_NAME_EXISTS|ERR_BUSY|ERR_NOT_ENOUGH_ENERGY|ERR_INVALID_ARGS} 81 | */ 82 | createCreep: function (body, name, memory) {}, 83 | 84 | /** 85 | * @param {Creep} target 86 | * @param {number} amount 87 | * @return {OK|ERR_NOT_OWNER|ERR_NOT_ENOUGH_ENERGY|ERR_INVALID_TARGET|ERR_FULL|ERR_NOT_IN_RANGE} 88 | */ 89 | transferEnergy: function (target, amount) {} 90 | }; 91 | -------------------------------------------------------------------------------- /src/Structure.js: -------------------------------------------------------------------------------- 1 | var Structure = function () {}; 2 | 3 | Structure.prototype = { 4 | /** 5 | * @type number 6 | */ 7 | hits: 0, 8 | 9 | /** 10 | * @type number 11 | */ 12 | hitsMax: 0, 13 | 14 | /** 15 | * @type string 16 | */ 17 | id: '', 18 | 19 | /** 20 | * @type boolean 21 | */ 22 | my: false, 23 | 24 | /** 25 | * @type object 26 | */ 27 | owner: {}, 28 | 29 | /** 30 | * @type RoomPosition 31 | */ 32 | pos: null, 33 | 34 | /** 35 | * @type Room 36 | */ 37 | room: null, 38 | 39 | /** 40 | * @type {STRUCTURE_EXTENSION|STRUCTURE_RAMPART|STRUCTURE_ROAD|STRUCTURE_WALL|STRUCTURE_KEEPER_LAIR|STRUCTURE_PORTAL|STRUCTURE_CONTROLLER|STRUCTURE_LINK} 41 | */ 42 | structureType: null, 43 | 44 | /** 45 | * @type number 46 | */ 47 | energy: 0, 48 | 49 | /** 50 | * @type number 51 | */ 52 | energyCapacity: 0, 53 | 54 | /** 55 | * @type number 56 | */ 57 | cooldown: 0, 58 | 59 | /** 60 | * @type number 61 | */ 62 | ticksToSpawn: 0, 63 | 64 | /** 65 | * @type number 66 | */ 67 | level: 0, 68 | 69 | /** 70 | * @type number 71 | */ 72 | progress: 0, 73 | 74 | /** 75 | * @type number 76 | */ 77 | progressTotal: 0, 78 | 79 | /** 80 | * @type number 81 | */ 82 | ticksToLive: 0, 83 | 84 | /** 85 | * @param {Creep|Structure} target 86 | * @param {number} amount 87 | * @return {OK|ERR_NOT_OWNER|ERR_NOT_ENOUGH_ENERGY|ERR_INVALID_TARGET|ERR_FULL|ERR_NOT_IN_RANGE|ERR_INVALID_ARGS|ERR_TIRED} 88 | */ 89 | transferEnergy: function (target, amount) {} 90 | }; 91 | -------------------------------------------------------------------------------- /src/screeps.js: -------------------------------------------------------------------------------- 1 | /* 2 | ************************* 3 | * Result Code Constants * 4 | ************************* 5 | */ 6 | var 7 | OK = 0, 8 | ERR_NOT_OWNER = -1, 9 | ERR_NO_PATH = -2, 10 | ERR_NAME_EXISTS = -3, 11 | ERR_BUSY = -4, 12 | ERR_NOT_FOUND = -5, 13 | ERR_NOT_ENOUGH_ENERGY = -6, 14 | ERR_INVALID_TARGET = -7, 15 | ERR_FULL = -8, 16 | ERR_NOT_IN_RANGE = -9, 17 | ERR_INVALID_ARGS = -10, 18 | ERR_TIRED = -11, 19 | ERR_NO_BODYPART = -12, 20 | ERR_NOT_ENOUGH_EXTENSIONS = -13, 21 | ERR_RCL_NOT_ENOUGH = -14, 22 | ERR_GCL_NOT_ENOUGH = -15 23 | ; 24 | 25 | /* 26 | *********************** 27 | * Room.find Constants * 28 | *********************** 29 | */ 30 | var 31 | FIND_EXIT_TOP = 1, 32 | FIND_EXIT_RIGHT = 3, 33 | FIND_EXIT_BOTTOM = 5, 34 | FIND_EXIT_LEFT = 7, 35 | FIND_EXIT = 10, 36 | FIND_CREEPS = 101, 37 | FIND_MY_CREEPS = 102, 38 | FIND_HOSTILE_CREEPS = 103, 39 | FIND_SOURCES_ACTIVE = 104, 40 | FIND_SOURCES = 105, 41 | FIND_DROPPED_ENERGY = 106, 42 | FIND_STRUCTURES = 107, 43 | FIND_MY_STRUCTURES = 108, 44 | FIND_HOSTILE_STRUCTURES = 109, 45 | FIND_FLAGS = 110, 46 | FIND_CONSTRUCTION_SITES = 111, 47 | FIND_MY_SPAWNS = 112, 48 | FIND_HOSTILE_SPAWNS = 113 49 | ; 50 | 51 | /* 52 | *********************** 53 | * Direction Constants * 54 | *********************** 55 | */ 56 | var 57 | TOP = 1, 58 | TOP_RIGHT = 2, 59 | RIGHT = 3, 60 | BOTTOM_RIGHT = 4, 61 | BOTTOM = 5, 62 | BOTTOM_LEFT = 6, 63 | LEFT = 7, 64 | TOP_LEFT = 8 65 | ; 66 | 67 | /* 68 | *********************** 69 | * Body Part Constants * 70 | *********************** 71 | */ 72 | var 73 | MOVE = 'move', 74 | WORK = 'work', 75 | CARRY = 'carry', 76 | ATTACK = 'attack', 77 | RANGED_ATTACK = 'ranged_attack', 78 | TOUGH = 'tough', 79 | HEAL = 'heal' 80 | ; 81 | 82 | /* 83 | **************************** 84 | * Structure Type Constants * 85 | **************************** 86 | */ 87 | var 88 | STRUCTURE_EXTENSION = 'extension', 89 | STRUCTURE_RAMPART = 'rampart', 90 | STRUCTURE_ROAD = 'road', 91 | STRUCTURE_SPAWN = 'spawn', 92 | STRUCTURE_WALL = 'constructedWall', 93 | STRUCTURE_KEEPER_LAIR = 'keeperLair', 94 | STRUCTURE_PORTAL = 'portal', 95 | STRUCTURE_CONTROLLER = 'controller', 96 | STRUCTURE_LINK = 'link' 97 | ; 98 | 99 | /* 100 | ******************* 101 | * Color Constants * 102 | ******************* 103 | */ 104 | var 105 | COLOR_RED = 'red', 106 | COLOR_PURPLE = 'purple', 107 | COLOR_BLUE = 'blue', 108 | COLOR_CYAN = 'cyan', 109 | COLOR_GREEN = 'green', 110 | COLOR_YELLOW = 'yellow', 111 | COLOR_ORANGE = 'orange', 112 | COLOR_BROWN = 'brown', 113 | COLOR_GREY = 'grey', 114 | COLOR_WHITE = 'white' 115 | ; 116 | 117 | /* 118 | *********************** 119 | * Room Mode Constants * 120 | *********************** 121 | */ 122 | var 123 | MODE_SIMULATION = 'simulation', 124 | MODE_SURVIVAL = 'survival', 125 | MODE_ARENA = 'arena', 126 | MODE_WORLD = 'world' 127 | ; 128 | --------------------------------------------------------------------------------