├── book ├── features.md ├── index.md ├── objects.md ├── syntax-changes │ ├── index.md │ ├── del-operator-overload.md │ ├── in-operator.md │ ├── object-iteration.md │ └── lists.md ├── methods.md ├── upgrading-transcrypt.md ├── SUMMARY.md ├── constants.md ├── lodash │ ├── as-arguments-to-api-methods.md │ └── introduction.md ├── constructors.md ├── optional-arguments.md ├── README.md ├── console-commands.md └── setup.md ├── README.md ├── requirements.txt ├── js_files └── .git_do_indeed_track_this_folder ├── config.default.json ├── config.private-server-example.json ├── book.json ├── package.json ├── src ├── defs │ ├── transcrypt.py │ ├── classes │ │ ├── __init__.py │ │ ├── memory.py │ │ ├── creep.py │ │ ├── other_js.py │ │ ├── misc_obj.py │ │ ├── room.py │ │ ├── game.py │ │ ├── structures.py │ │ └── lodash.py │ ├── __init__.py │ └── constants.py ├── main.py └── harvester.py ├── LICENSE ├── .gitignore └── file_expander.py /book/features.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /book/index.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | book/README.md -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | git+https://github.com/daboross/Transcrypt.git@screeps-transcrypt-0.3.3#egg=transcrypt 2 | -------------------------------------------------------------------------------- /js_files/.git_do_indeed_track_this_folder: -------------------------------------------------------------------------------- 1 | # empty file, just so that this folder exists in git repository 2 | -------------------------------------------------------------------------------- /config.default.json: -------------------------------------------------------------------------------- 1 | { 2 | "token": "token-created-from-account-management", 3 | "branch": "default", 4 | "ptr": false 5 | } 6 | -------------------------------------------------------------------------------- /config.private-server-example.json: -------------------------------------------------------------------------------- 1 | { 2 | "email": "your-username-here", 3 | "password": "plain-text-password-set-via-screepsmod-auth", 4 | "branch": "default", 5 | "url": "http://your-server-url-or-ip:21025" 6 | } 7 | -------------------------------------------------------------------------------- /book.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": "./book", 3 | "plugins": ["theme-api", "code"], 4 | "pluginsConfig": { 5 | "theme-api": { 6 | "languages": [ 7 | { 8 | "lang": "js", 9 | "name": "JavaScript" 10 | }, 11 | { 12 | "lang": "py", 13 | "name": "Python", 14 | "default": true 15 | } 16 | ] 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /book/objects.md: -------------------------------------------------------------------------------- 1 | # Objects 2 | 3 | Entities in the game world exist as object prototypes; if you've never used JavaScript before, you can think of these like instances of a class in Python. Prototypes have both attributes and methods and are accessed in JavaScript like they are in Python. 4 | 5 | #### Syntax: 6 | 7 | _Referencing a specific spawn through a variable:_ 8 | 9 | ```py 10 | spawn = Game.spawns.Spawn1 11 | ``` 12 | 13 | _Moving a Creep:_ 14 | 15 | ```py 16 | creep = Game.creeps['upgrader123'] 17 | creep.moveTo(creep.room.controller) 18 | ``` 19 | 20 | 21 | -------------------------------------------------------------------------------- /book/syntax-changes/index.md: -------------------------------------------------------------------------------- 1 | ## Syntax Changes: Transcrypt vs. Python 2 | 3 | - [`in` operator differences](./in-operator.md) 4 | - [list behavior differences](./lists.md) 5 | - [`del` operator differences](./del-operator-overload.md) 6 | 7 | If there is anything else you've found, do file an issue in the screeps-starter-python repository and I will include it here. 8 | Transcrypt uses the Python interpreter itself to parse source code, but it doesn't replicate the python runtime perfectly. 9 | When in doubt, looking at the created `main.js` file can provide a lot of insight into how things run. 10 | 11 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "screeps-starter-python", 3 | "version": "0.0.1", 4 | "description": "screeps-starter-python ==========", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/daboross/screeps-starter-python.git" 12 | }, 13 | "author": "", 14 | "license": "MIT", 15 | "bugs": { 16 | "url": "https://github.com/daboross/screeps-starter-python/issues" 17 | }, 18 | "homepage": "https://github.com/daboross/screeps-starter-python#readme", 19 | "devDependencies": { 20 | "rollup": "^2.35.1" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/defs/transcrypt.py: -------------------------------------------------------------------------------- 1 | from typing import Any, Union, TypeVar 2 | 3 | T = TypeVar('T') 4 | 5 | 6 | def __new__(arg: T) -> T: 7 | return arg 8 | 9 | 10 | # noinspection PyPep8Naming 11 | def js_isNaN(num: Union[float, int, str]) -> bool: 12 | return float(num) != float('nan') 13 | 14 | 15 | class Uint8Array(Any): 16 | """ 17 | WARNING: This is just here for autocompletion. 18 | If anyone feels like typing this go for it :) - Lisp 19 | """ 20 | 21 | 22 | js_global = None # type: Any 23 | 24 | __except0__ = None # type: Exception 25 | 26 | __all__ = [ 27 | '__new__', 28 | 'js_isNaN', 29 | 'js_global', 30 | '__except0__', 31 | 'Uint8Array', 32 | ] 33 | -------------------------------------------------------------------------------- /book/methods.md: -------------------------------------------------------------------------------- 1 | # Defining Methods 2 | 3 | Methods allow you to smoothly display code examples in different languages. 4 | 5 | {% method %} 6 | ## My first method 7 | 8 | My first method exposes how to print a message in JavaScript and Go. 9 | 10 | {% sample lang="js" %} 11 | Here is how to print a message to `stdout` using JavaScript. 12 | 13 | ```js 14 | console.log('My first method'); 15 | ``` 16 | 17 | {% sample lang="go" %} 18 | Here is how to print a message to `stdout` using Go. 19 | 20 | ```go 21 | fmt.Println("My first method") 22 | ``` 23 | 24 | {% common %} 25 | Whatever language you are using, the result will be the same. 26 | 27 | ```bash 28 | $ My first method 29 | ``` 30 | {% endmethod %} 31 | -------------------------------------------------------------------------------- /book/upgrading-transcrypt.md: -------------------------------------------------------------------------------- 1 | Upgrading screeps-transcrypt 2 | ============================ 3 | 4 | Transcrypt occasionally updates! To provide better compilations, or to provide other fixes. 5 | 6 | When this happens, `screeps-transcrypt`, the semi-fork of Transcrypt which includes extra changes for the Screeps environment, will also update, and an update will be pushed to this repository with a new `requirements.txt` file. 7 | 8 | If you've already got the new `requirements.txt`, simply delete `env/` and re-run `build.py` to re-download and reinstall transcrypt. Alternatively, you can run the environment's `pip` and update it yourself: 9 | 10 | ```bash 11 | ./env/bin/pip install --upgrade -r requirements.txt 12 | ``` 13 | 14 | I believe this steps will work for both Unix and Windows users, though they have only been tested on Linux so far. 15 | -------------------------------------------------------------------------------- /book/SUMMARY.md: -------------------------------------------------------------------------------- 1 | # Summary 2 | 3 | ## Logistics 4 | 5 | * [Setup](setup.md) 6 | * [Upgrading Transcrypt](upgrading-transcrypt.md) 7 | 8 | ## Screeps API Usage 9 | 10 | * [Constants](constants.md) 11 | * [Optional Arguments ](optional-arguments.md) 12 | * [Objects - Basic Interaction](objects.md) 13 | * [Objects - Creation and the Keyword "new"](constructors.md) 14 | 15 | ## Features 16 | 17 | * [Console Commands](console-commands.md) 18 | 19 | ## Lodash 20 | 21 | * [Introduction](lodash/introduction.md) 22 | * [As Arguments to API Methods](lodash/as-arguments-to-api-methods.md) 23 | 24 | ## Syntax Changes 25 | 26 | * [Summary](syntax-changes/index.md) 27 | * [`in` Opperator](syntax-changes/in-operator.md) 28 | * [List Behavior](syntax-changes/lists.md) 29 | * [`del` Operator](syntax-changes/del-operator-overload.md) 30 | * [`dict` Iteration](syntax-changes/object-iteration.md) 31 | -------------------------------------------------------------------------------- /book/syntax-changes/del-operator-overload.md: -------------------------------------------------------------------------------- 1 | ## Transcrypt vs. Python: `del` operator overload 2 | 3 | In python, `del list[0]` will delete the first item in the list, and truncate it. 4 | 5 | The same is not true in Transcrypt. Transcrypt translates `del` directly to JavaScript's `delete`, so you'll end up with an incoheret list if you use this operator. 6 | 7 | Instead, using the `pop` operator can work. 8 | 9 | 10 | ```py 11 | # in regular python: 12 | del list[0] 13 | # in Screeps via Transcrypt: 14 | list.pop(0) 15 | ``` 16 | 17 | If you need to delete a range, the JavaScript [`splice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice) method can help: 18 | ```py 19 | # in regular python: 20 | del list[1:3] # delete items 1 through 3, exclusive 21 | # in Screeps via Transcrypt: 22 | list.splice(1, 2) # delete 2 items, starting with index 1 23 | ``` -------------------------------------------------------------------------------- /book/constants.md: -------------------------------------------------------------------------------- 1 | # Constants 2 | 3 | Screeps provides a number of [constants](http://docs.screeps.com/api/#Constants) that hold references to everything from error codes to in-game resources. The constants themselves either store some kind of value (like a string or integer) or are a reference to data structures like arrays and objects. Some constants are provided for conveince while others are required for some API calls. 4 | 5 | Unlike optional named arguments, constants should be provided as is; constants are always uppercase with individual words seperated by underscores. 6 | 7 | #### Examples 8 | 9 | _Defining a creep's part list:_ 10 | ```py 11 | harvester_parts = [WORK, MOVE, CARRY] 12 | ``` 13 | 14 | _Referencing a resource and checking for an error code:_ 15 | ```py 16 | if creep.withdraw(creep.room.storage, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE: 17 | creep.moveTo(creep.room.storage) 18 | ``` 19 | -------------------------------------------------------------------------------- /book/lodash/as-arguments-to-api-methods.md: -------------------------------------------------------------------------------- 1 | # Option API Arguments - Lodash 2 | 3 | In addition to accepting standard optional arguments that modify some specific aspect of an API call, methods that return an array of objects (most notably `find*()` methods) accept a Lodash filter as an optional argument. While the example syntax provided by the game will not work in your Python code, only minor changes are needed to produce a similar result. 4 | 5 | #### Examples 6 | 7 | 8 | _Finding all extensions in a room:_ 9 | ```py 10 | extensions = creep.room.find(FIND_STRUCTURES, { 11 | "filter": lambda s: 12 | s.structureType == STRUCTURE_ROAD 13 | }) 14 | 15 | ``` 16 | 17 | _Finding the closest dropped resource that meets a multiple criteria:_ 18 | ```py 19 | dropped_energy = creep.pos.findClosestByRange(FIND_DROPPED_RESOURCES, { 20 | "filter": lambda r: 21 | r.resourceType == RESOURCE_ENERGY and r.amount >= 100 22 | }) 23 | 24 | ``` 25 | -------------------------------------------------------------------------------- /book/syntax-changes/in-operator.md: -------------------------------------------------------------------------------- 1 | ## Transcrypt vs. Python: the `in` operator 2 | 3 | In regular python, `in` opreators on lists, objects, and generally any container object. It also supports overloading via the `__contains__` method. 4 | 5 | Transcrypt's `in` operator supports neither of these things. In order to achieve better performance when used with dicts (javascript "object"s), it behaves very similarly to JavaScript's `in` operator. 6 | 7 | It will work the same on dictionaries, but does not support lists, and does not support custom containers. 8 | 9 | To find whether a list contains an item or a string contains a sub-string, one can use the [`includes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes) method: 10 | 11 | ```py 12 | # in regular python: 13 | if ('x' in 'asdf' 14 | and 'the_key' in the_dict 15 | and 'the_item' in the_list): 16 | pass 17 | # in Screeps via Transcrypt: 18 | if ('asdf'.includes('x') 19 | and 'the_key' in the_dict 20 | and the_list.includes('the_item')): 21 | pass 22 | ``` -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Dabo Ross 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /book/constructors.md: -------------------------------------------------------------------------------- 1 | # Object Creation 2 | 3 | While Transcrypt supports standard Python syntax for class instance creation and use, the JavaScript syntax for creating new objects must be used when interacting with a small number of Screeps prototypes. In Python, new objects are created by calling the class; in JavaScript, to create an instance of an object, the `new` keyword must be provided along with a call to the contruct that creates the object. 4 | 5 | Transcrypt provides a method, `__new__()`, that supports creating interacting with constructors in third party libraries. When working with code examples provided by the API, any instance of `new Constructor()` should be replaced with `__new__(Constructor())`. 6 | 7 | #### Examples 8 | 9 | _Creating a new [RoomPosition](http://docs.screeps.com/api/#RoomPosition) object:_ 10 | 11 | ```py 12 | room_pos = __new__(RoomPosition(25, 25, 'E34S25')) 13 | ``` 14 | 15 | _Creating a new [RoomVisual](http://docs.screeps.com/api/#RoomVisual):_ 16 | ```py 17 | # Displays the current tick in the upper-left corner of all rooms 18 | __new__(RoomVisual().text(Game.time, 0, 0, {'align': 'left', 'font': 0.6})) 19 | ``` 20 | 21 | _Creating a new [CostMatrix](http://docs.screeps.com/api/#PathFinder-CostMatrix):_ 22 | ```py 23 | costs = __new__(PathFinder.CostMatrix) 24 | ``` -------------------------------------------------------------------------------- /book/lodash/introduction.md: -------------------------------------------------------------------------------- 1 | # Lodash Overview 2 | [Lodash](https://lodash.com/) is a JavaScript library that provides utility methods for accomplishing tasks via functional programming. Screeps supports Lodash in its entirety; while using it isn't a requirement, it can make accomplishing some tasks in game substantially easier. 3 | 4 | 5 | #### Syntax Basics 6 | In respect to screeps, Lodash is useful when work needs to be performed on an object with numerous properties, or an array populated by objects (that also may have numerous properties). A typical Lodash method takes the form of `_.lodashMethod(collection, function)` where `collection` is your object or array, and `function` is an anonymous function that will be invoked for each iteration on the provided `collection`. 7 | 8 | This syntax is similar to the `key` arguments supported by some of Python's built in functions like `sorted()`, `min()`, `max()`, and so on. 9 | 10 | ##### Lambda Functions 11 | The [Lodash Documentation](https://lodash.com/docs/4.17.5) provides a good overview of how to use each method, and what those can be used to accomplish. While helpful examples are provided with each entry, Python's anonymous function syntax via [lambdas](http://www.secnetix.de/olli/Python/lambda_functions.hawk) must be used in place of JavaScript anonymous function syntax. 12 | -------------------------------------------------------------------------------- /book/optional-arguments.md: -------------------------------------------------------------------------------- 1 | # Optional Arguments 2 | 3 | Most methods provided through the API support a number of different optional arguments that that augment the behavior and/or return results of the process being called. Most optional arguments are provided through predefined variables that are grouped together in a single object. 4 | 5 | JavaScript does not natively support named keyword arguments like Python; so all named optional arguments must be provided using the single object format. 6 | 7 | ### Predefined Variable Syntax 8 | 9 | All predefined optional argument variable names must be provided as strings; while this isn't necessary when writing screeps code in JavaScript, failing to provide arguments as strings will either cause `build.py` to fail, or, Screeps itself won't recognize the variable name. This rule holds true for every API call except for arguments that allow for a custom `CostMatrix`; you can read more about this in the `PathFinder - CostMatrix` section. 10 | 11 | #### Examples 12 | 13 | _Modifying `.moveTo()` behavior:_ 14 | ```py 15 | creep.moveTo(creep.room.controller, {'maxRooms': 1, 'ignoreCreeps': True}) 16 | ``` 17 | 18 | _Spawning a creep with predefined memory:_ 19 | ```py 20 | name = "{}{}".format('harvester', Game.time) 21 | spawn.spawnCreep([WORK, CARRY, MOVE], name, {'memory': {'role': 'harvester'}}) 22 | ``` 23 | 24 | -------------------------------------------------------------------------------- /book/syntax-changes/object-iteration.md: -------------------------------------------------------------------------------- 1 | ## Transcrypt vs. Python: iterating dicts 2 | 3 | In Python, dictionaries are a special case - they have a different class than Object which allows for `[]` access to values, and iteration methods like `.keys()`, `.values()` and `.items()`. 4 | 5 | In JavaScript, all objects are "dictionaries". Screeps-transcrypt has made the choice to by default keep all dictionaries created in Python regular JS objects for consistency between JS-created dicts and Python-created dicts. 6 | 7 | While this is good for performance, it's not great for pythonic code. `.keys()`, `.values()` and `.items()` are not available in Transcrypt-python. 8 | 9 | Instead, there are two possibilities: 10 | 11 | ## 1) manually force things to be dictionaries 12 | 13 | `dict()` method does exist, and will turn a regular object into a dictionary with right methods. 14 | 15 | ```python 16 | my_stuff = dict({ 17 | "a": b, 18 | }) 19 | ``` 20 | 21 | ## 2) use JS-style or lodash access 22 | 23 | In JavaScript, lodash methods are often used for object iteration. 24 | 25 | Instead of: 26 | 27 | ```py 28 | for key, value in obj.items(): 29 | print(key, value) 30 | for key in obj.keys(): 31 | print(key) 32 | for value in obj.values(): 33 | print(value) 34 | ``` 35 | 36 | You can use: 37 | 38 | ```py 39 | for key, value in _.pairs(obj): 40 | print(key, value) 41 | for key in Object.keys(obj): # or _.keys(obj) 42 | print(key) 43 | for value in Object.values(obj): # or _.values(obj) 44 | print(value) 45 | ``` 46 | -------------------------------------------------------------------------------- /src/defs/classes/__init__.py: -------------------------------------------------------------------------------- 1 | from .creep import Creep 2 | from .game import Game, PathFinder 3 | # noinspection PyProtectedMember 4 | from .lodash import _ 5 | # noinspection PyProtectedMember 6 | from .memory import Memory, RawMemory, _Memory, _MemoryValue 7 | from .misc_obj import Flag, Mineral, Resource, RoomObject, Source 8 | from .other_js import Array, Infinity, JSON, Map, Math, Object, RegExp, Set, String, console, module, require, this, \ 9 | typeof, undefined 10 | # noinspection PyProtectedMember 11 | from .room import Room, RoomPosition, _PathPos 12 | from .structures import ConstructionSite, OwnedStructure, Structure, StructureContainer, StructureController, \ 13 | StructureExtension, StructureExtractor, StructureKeeperLair, StructureLab, StructureLink, StructureNuker, \ 14 | StructureObserver, StructurePortal, StructurePowerBank, StructurePowerSpawn, StructureRampart, StructureRoad, \ 15 | StructureSpawn, StructureStorage, StructureTerminal, StructureTower, StructureWall 16 | 17 | __all__ = [ 18 | 'Creep', 'Game', 'PathFinder', '_', 'Memory', 'RawMemory', '_Memory', '_MemoryValue', 'Flag', 'Mineral', 'Resource', 19 | 'RoomObject', 'Source', 'Infinity', 'JSON', 'Map', 'Set', 'Math', 'Object', 'RegExp', 'module', 'require', 'this', 20 | 'typeof', 'undefined', 'Room', 'RoomPosition', '_PathPos', 'String', 'Array', 'console', 21 | 'ConstructionSite', 'OwnedStructure', 'Structure', 22 | 'StructureContainer', 'StructureController', 23 | 'StructureExtension', 'StructureExtractor', 'StructureKeeperLair', 'StructureLab', 'StructureLink', 24 | 'StructureNuker', 'StructureObserver', 'StructurePortal', 'StructurePowerBank', 'StructurePowerSpawn', 25 | 'StructureRampart', 'StructureRoad', 'StructureSpawn', 'StructureStorage', 'StructureTerminal', 'StructureTower', 26 | 'StructureWall' 27 | ] 28 | -------------------------------------------------------------------------------- /src/defs/classes/memory.py: -------------------------------------------------------------------------------- 1 | from typing import Any, Dict, List, Optional, Union 2 | 3 | __all__ = ['Memory', 'RawMemory', '_Memory', '_MemoryValue'] 4 | 5 | _MemoryValue = Union[str, int, float, bool, '_Memory', List['_MemoryValue'], None] 6 | 7 | 8 | class _Memory(dict): 9 | def __getattr__(self, key: str) -> _MemoryValue: 10 | pass 11 | 12 | def __setattr__(self, key: str, value: _MemoryValue) -> None: 13 | pass 14 | 15 | 16 | Memory = _Memory() 17 | 18 | 19 | class _ForeignSegment: 20 | """ 21 | :type username: str 22 | :type id: int 23 | :type data: str 24 | """ 25 | 26 | def __init__(self, username: str, _id: int, data: str) -> None: 27 | """ 28 | WARNING: This constructor is purely for type completion, and does not exist in the game. 29 | """ 30 | self.data = data 31 | self.username = username 32 | self.id = _id 33 | 34 | 35 | # noinspection PyPep8Naming 36 | class RawMemory: 37 | """ 38 | :type segments: Dict[int, str] 39 | :type foreignSegment: _ForeignSegment | None 40 | """ 41 | segments = {} # type: Dict[int, str] 42 | foreignSegment = None # type: Optional[_ForeignSegment] 43 | 44 | @classmethod 45 | def get(cls) -> str: 46 | pass 47 | 48 | @classmethod 49 | def set(cls, value: str) -> None: 50 | pass 51 | 52 | @classmethod 53 | def setActiveSegments(cls, ids: List[int]) -> None: 54 | pass 55 | 56 | @classmethod 57 | def setActiveForeignSegment(cls, username: Optional[str], _id: Optional[int] = None) -> None: 58 | pass 59 | 60 | @classmethod 61 | def setDefaultPublicSegment(cls, _id: Optional[int]) -> None: 62 | pass 63 | 64 | @classmethod 65 | def setPublicSegments(cls, ids: List[int]) -> None: 66 | pass 67 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled source # 2 | ################### 3 | *.com 4 | *.dll 5 | *.exe 6 | *.o 7 | *.so 8 | __pycache__/ 9 | *.py[cod] 10 | __javascript__/ 11 | __target__/ 12 | target/ 13 | 14 | # Git # 15 | ####### 16 | .git 17 | 18 | # Packages # 19 | ############ 20 | *.7z 21 | *.dmg 22 | *.gz 23 | *.iso 24 | *.jar 25 | *.rar 26 | *.tar 27 | *.zip 28 | 29 | # Logs and databases # 30 | ###################### 31 | *.log 32 | *.sql 33 | *.sqlite 34 | *.db 35 | 36 | # OS generated files # 37 | ###################### 38 | .DS_Store 39 | ehthumbs.db 40 | Icon? 41 | Thumbs.db 42 | 43 | # Build files # 44 | ############### 45 | MANIFEST.MF 46 | dependency-reduced-pom.xml 47 | 48 | # Distribution / packaging # 49 | ############################ 50 | .Python 51 | env/ 52 | bin/ 53 | build/ 54 | develop-eggs/ 55 | dist/ 56 | eggs/ 57 | lib/ 58 | lib64/ 59 | parts/ 60 | sdist/ 61 | var/ 62 | *.egg-info/ 63 | .installed.cfg 64 | *.egg 65 | 66 | # Installer logs # 67 | ################## 68 | pip-log.txt 69 | pip-delete-this-directory.txt 70 | 71 | # Project files # 72 | ##################### 73 | .ropeproject 74 | .mr.developer.cfg 75 | .project 76 | .pydevproject 77 | .classpath 78 | .externalToolBuilders 79 | .idea 80 | .project 81 | .settings 82 | build 83 | dist 84 | nbproject 85 | atlassian-ide-plugin.xml 86 | build.xml 87 | nb-configuration.xml 88 | *.iml 89 | *.ipr 90 | *.iws 91 | node_modules 92 | env 93 | .screeps-password 94 | .screeps-email 95 | config.json 96 | __py_build__/ 97 | 98 | # Misc files # 99 | ############## 100 | *.bak 101 | *.log 102 | *.pot 103 | docs/_build/ 104 | *\ Notes.txt 105 | .mypy_cache 106 | # it's recommended that we check this in, but with how infrequently this project is updated, 107 | # that would cause everyone to end up with an extremely outdated rollup. 108 | package-lock.json 109 | 110 | # Unit test / coverage reports # 111 | ################################ 112 | htmlcov/ 113 | .tox/ 114 | .coverage 115 | .cache 116 | nosetests.xml 117 | coverage.xml 118 | /config.json 119 | /git-cloned/ 120 | /markdown/ 121 | -------------------------------------------------------------------------------- /src/main.py: -------------------------------------------------------------------------------- 1 | import harvester 2 | # defs is a package which claims to export all constants and some JavaScript objects, but in reality does 3 | # nothing. This is useful mainly when using an editor like PyCharm, so that it 'knows' that things like Object, Creep, 4 | # Game, etc. do exist. 5 | from defs import * 6 | 7 | # These are currently required for Transcrypt in order to use the following names in JavaScript. 8 | # Without the 'noalias' pragma, each of the following would be translated into something like 'py_Infinity' or 9 | # 'py_keys' in the output file. 10 | __pragma__('noalias', 'name') 11 | __pragma__('noalias', 'undefined') 12 | __pragma__('noalias', 'Infinity') 13 | __pragma__('noalias', 'keys') 14 | __pragma__('noalias', 'get') 15 | __pragma__('noalias', 'set') 16 | __pragma__('noalias', 'type') 17 | __pragma__('noalias', 'update') 18 | 19 | 20 | def main(): 21 | """ 22 | Main game logic loop. 23 | """ 24 | 25 | # Run each creep 26 | for name in Object.keys(Game.creeps): 27 | creep = Game.creeps[name] 28 | harvester.run_harvester(creep) 29 | 30 | # Run each spawn 31 | for name in Object.keys(Game.spawns): 32 | spawn = Game.spawns[name] 33 | if not spawn.spawning: 34 | # Get the number of our creeps in the room. 35 | num_creeps = _.sum(Game.creeps, lambda c: c.pos.roomName == spawn.pos.roomName) 36 | # If there are no creeps, spawn a creep once energy is at 250 or more 37 | if num_creeps < 0 and spawn.room.energyAvailable >= 250: 38 | spawn.createCreep([WORK, CARRY, MOVE, MOVE]) 39 | # If there are less than 15 creeps but at least one, wait until all spawns and extensions are full before 40 | # spawning. 41 | elif num_creeps < 15 and spawn.room.energyAvailable >= spawn.room.energyCapacityAvailable: 42 | # If we have more energy, spawn a bigger creep. 43 | if spawn.room.energyCapacityAvailable >= 350: 44 | spawn.createCreep([WORK, CARRY, CARRY, MOVE, MOVE, MOVE]) 45 | else: 46 | spawn.createCreep([WORK, CARRY, MOVE, MOVE]) 47 | 48 | 49 | module.exports.loop = main 50 | -------------------------------------------------------------------------------- /book/README.md: -------------------------------------------------------------------------------- 1 | screeps-starter-python 2 | ====================== 3 | 4 | [![MIT licensed][mit-badge]][mit-url] 5 | [![Slack Chat][slack-badge]][slack-url] 6 | [![Docs Built][docs-badge]][docs-url] 7 | 8 | This repository is a starter Python AI written for the JavaScript based MMO 9 | game, [screeps](https://screeps.com). 10 | 11 | 12 | While code uploaded to the server must be in JavaScript, this repository is 13 | written in Python. We use the [Transcrypt](https://github.com/QQuick/Transcrypt) 14 | transpiler to transpile the python programming into JavaScript. 15 | 16 | Specifically, it uses [my fork of 17 | transcrypt](https://github.com/daboross/Transcrypt) built with [a few 18 | modifications](https://github.com/daboross/Transcrypt/commits/screeps-safe-modifications) 19 | intended to reduce the overhead of running Python in the Screeps 20 | environment. Nothing against Transcrypt itself, and you're free to change the 21 | installed fork my modifying `requirements.txt`! I've just found a few changes 22 | useful that I've tested in node.js and the screeps environment, but that I don't 23 | have time to generalize enough to include in the main transcrypt codebase. 24 | 25 | This repository is intended as a base to be used for building more complex AIs, 26 | and has all the tooling needed to transpile Python into JavaScript set up. 27 | 28 | ## Install 29 | 30 | To get started, check out the [Setup 31 | Guide](https://daboross.gitbook.io/screeps-starter-python/logistics/setup). 32 | 33 | ## Docs 34 | 35 | For a documentation index, see [The 36 | Book](https://daboross.gitbooks.io/screeps-starter-python/), and for the 37 | main differences between Python and Transcrypt-flavored-Python, see [Syntax 38 | Changes](https://daboross.gitbooks.io/screeps-starter-python/syntax-changes/). 39 | 40 | ## Community 41 | 42 | Join us on the [Screeps Slack][slack-url]! We're in 43 | [#python](https://screeps.slack.com/archives/C2FNJBGH0) (though you need to sign 44 | up with the first link first :). 45 | 46 | [mit-badge]: https://img.shields.io/badge/license-MIT-blue.svg 47 | [mit-url]: https://github.com/daboross/screeps-starter-python/blob/master/LICENSE 48 | [slack-badge]: https://img.shields.io/badge/chat-slack-2EB67D 49 | [slack-url]: https://chat.screeps.com/ 50 | 51 | [docs-badge]: https://img.shields.io/badge/docs-built-blue 52 | [docs-url]: https://daboross.gitbook.io/screeps-starter-python/logistics/setup 53 | -------------------------------------------------------------------------------- /book/console-commands.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | In addition to supporting all API calls, The in-game console also allows you to call your own functions and methods. While your function/method can be defined in any file, it must be imported into `main.py` and added as an entry to a special object, `js_global`, which holds references to all API prototypes, objects, constants, and so on. 3 | 4 | You can call anything defined in `js_global` like you would a normal function. If you want to instantiate and class and call a method from the console, make all the necessary calls to the class from a function, and then store a reference to that function in `js_global` like you would a normal function call. 5 | 6 | #### Example 7 | 8 | _controller_properties.py_ 9 | 10 | ```py 11 | from defs import * 12 | 13 | __pragma__('noalias', 'name') 14 | __pragma__('noalias', 'undefined') 15 | __pragma__('noalias', 'Infinity') 16 | __pragma__('noalias', 'keys') 17 | __pragma__('noalias', 'get') 18 | __pragma__('noalias', 'set') 19 | __pragma__('noalias', 'type') 20 | __pragma__('noalias', 'update') 21 | 22 | def get_controller_level(room_name): 23 | """Returns the controller level for Game.rooms[room_name]""" 24 | 25 | room = Game.rooms[room_name] 26 | 27 | if room and room.controller: 28 | return room.controller.level 29 | else: 30 | return "Error: no access too {}".format(room_name) 31 | ``` 32 | 33 | _main.py_ 34 | 35 | ```py 36 | import controller_properties 37 | from defs import * 38 | 39 | __pragma__('noalias', 'name') 40 | __pragma__('noalias', 'undefined') 41 | __pragma__('noalias', 'Infinity') 42 | __pragma__('noalias', 'keys') 43 | __pragma__('noalias', 'get') 44 | __pragma__('noalias', 'set') 45 | __pragma__('noalias', 'type') 46 | __pragma__('noalias', 'update') 47 | 48 | # Create a new entry for each new command 49 | js_glboal.get_controller_level = controller_properties.get_controller_level 50 | 51 | def main(): 52 | """You normal screeps code here""" 53 | pass 54 | 55 | module.exports.loop = main 56 | ``` 57 | 58 | #### js_global 59 | 60 | `js_global` is a reference to a JavaScript `global` object, which is a globally scoped object that is always available to be referenced. Because `global` is already a keyword in Python, this alternate version is used. You can check the contents of `js_global` in-game at any time by entering `global` in the in-game console, but any time you want to reference it in your code, `js_global` must be used instead. 61 | 62 | -------------------------------------------------------------------------------- /book/syntax-changes/lists.md: -------------------------------------------------------------------------------- 1 | ## Transcrypt vs. Python: list methods 2 | 3 | Ideally, we'd have support for lists equivalent to Python itself. Unfortunately, this is not the case. 4 | 5 | Three are three differences between Python and Screeps/Transcrypt lists. 6 | 7 | ## 1) In non-IVM Screeps, there are two types of lists. 8 | 9 | If you're using the [IVM architecture], you can skip this section! The new architecture, when enabled on an account-level, fixes this problem. 10 | 11 | Lists created within our code, in general, support python methods. Lists created outside of our code do not. 12 | 13 | This means that if you are working with lists from `Memory`, lists from `room.fiynd()`, or any other non-user-javascript source, you won't be able to use Python prototype methods. 14 | 15 | Instead, it's possible to use JavaScript methods. As painful as this is, it's a temporary workaround that does work: 16 | 17 | ```py 18 | x = Memory.some_list 19 | 20 | # won't work :( 21 | x.append(3) 22 | # does work, but isn't great 23 | x.push(3) 24 | ``` 25 | 26 | The reason this is necessary is that the Screeps environment itself has two separate environments: the outside, where the game code exists, and our sandbox, where our code lives. We're allowed to add methods to types existing in our sandbox, but that doesn't translate to types outside the sandbox. 27 | 28 | Memory, lodash, and all game methods are created outside our sandbox and thus don't have any of the prototype methods Transcrypt adds to lists. 29 | 30 | [IVM architecture](http://blog.screeps.com/2018/03/changelog-2018-03-05/) 31 | 32 | ## 2) Negative indices don't work 33 | 34 | For performance, Transcrypt translates indexing into lists directly into JavaScript indexing. This works most of the time, but fails for negative list indices. 35 | 36 | ```py 37 | the_list = [1, 2, 3, 4] 38 | # in Python: 39 | assert the_list[-1] == 4 40 | # in Transcrypt: 41 | assert the_list[-1] == undefined # :( 42 | # instead, you can use: 43 | assert the_list[len(the_list) - 1] == 4 44 | ``` 45 | 46 | ## 3) Slicing outside of an array bounds gives extra items 47 | 48 | In regular Python, slicing outside of an array bounds will just give you till the end of the array. In Transcrypt, the same will pad the array with `undefined`. 49 | 50 | ```py 51 | the_list = [1, 2] 52 | # in Python: 53 | assert the_list[:5] == [1, 2] 54 | # in Transcrypt: 55 | assert the_list[:5] == [1, 2, undefined, undefined, undefined] 56 | ``` 57 | 58 | There isn't a good fix for this besides just expecting this behavior. 59 | -------------------------------------------------------------------------------- /src/harvester.py: -------------------------------------------------------------------------------- 1 | from defs import * 2 | 3 | __pragma__('noalias', 'name') 4 | __pragma__('noalias', 'undefined') 5 | __pragma__('noalias', 'Infinity') 6 | __pragma__('noalias', 'keys') 7 | __pragma__('noalias', 'get') 8 | __pragma__('noalias', 'set') 9 | __pragma__('noalias', 'type') 10 | __pragma__('noalias', 'update') 11 | 12 | 13 | def run_harvester(creep): 14 | """ 15 | Runs a creep as a generic harvester. 16 | :param creep: The creep to run 17 | """ 18 | 19 | # If we're full, stop filling up and remove the saved source 20 | if creep.memory.filling and _.sum(creep.carry) >= creep.carryCapacity: 21 | creep.memory.filling = False 22 | del creep.memory.source 23 | # If we're empty, start filling again and remove the saved target 24 | elif not creep.memory.filling and creep.carry.energy <= 0: 25 | creep.memory.filling = True 26 | del creep.memory.target 27 | 28 | if creep.memory.filling: 29 | # If we have a saved source, use it 30 | if creep.memory.source: 31 | source = Game.getObjectById(creep.memory.source) 32 | else: 33 | # Get a random new source and save it 34 | source = _.sample(creep.room.find(FIND_SOURCES)) 35 | creep.memory.source = source.id 36 | 37 | # If we're near the source, harvest it - otherwise, move to it. 38 | if creep.pos.isNearTo(source): 39 | result = creep.harvest(source) 40 | if result != OK: 41 | print("[{}] Unknown result from creep.harvest({}): {}".format(creep.name, source, result)) 42 | else: 43 | creep.moveTo(source) 44 | else: 45 | # If we have a saved target, use it 46 | if creep.memory.target: 47 | target = Game.getObjectById(creep.memory.target) 48 | else: 49 | # Get a random new target. 50 | target = _(creep.room.find(FIND_STRUCTURES)) \ 51 | .filter(lambda s: ((s.structureType == STRUCTURE_SPAWN or s.structureType == STRUCTURE_EXTENSION) 52 | and s.energy < s.energyCapacity) or s.structureType == STRUCTURE_CONTROLLER) \ 53 | .sample() 54 | creep.memory.target = target.id 55 | 56 | # If we are targeting a spawn or extension, we need to be directly next to it - otherwise, we can be 3 away. 57 | if target.energyCapacity: 58 | is_close = creep.pos.isNearTo(target) 59 | else: 60 | is_close = creep.pos.inRangeTo(target, 3) 61 | 62 | if is_close: 63 | # If we are targeting a spawn or extension, transfer energy. Otherwise, use upgradeController on it. 64 | if target.energyCapacity: 65 | result = creep.transfer(target, RESOURCE_ENERGY) 66 | if result == OK or result == ERR_FULL: 67 | del creep.memory.target 68 | else: 69 | print("[{}] Unknown result from creep.transfer({}, {}): {}".format( 70 | creep.name, target, RESOURCE_ENERGY, result)) 71 | else: 72 | result = creep.upgradeController(target) 73 | if result != OK: 74 | print("[{}] Unknown result from creep.upgradeController({}): {}".format( 75 | creep.name, target, result)) 76 | # Let the creeps get a little bit closer than required to the controller, to make room for other creeps. 77 | if not creep.pos.inRangeTo(target, 2): 78 | creep.moveTo(target) 79 | else: 80 | creep.moveTo(target) 81 | -------------------------------------------------------------------------------- /src/defs/classes/creep.py: -------------------------------------------------------------------------------- 1 | from typing import Any, ClassVar, Dict, List, Optional, Union 2 | 3 | from .memory import _Memory 4 | from .misc_obj import Mineral, Resource, RoomObject, Source, Store 5 | from .room import Room, RoomPosition, _Owner 6 | from .structures import ConstructionSite, Structure, StructureController 7 | 8 | 9 | class _CreepPart: 10 | """ 11 | :type boost: str | None 12 | :type type: str 13 | :type hits: int 14 | """ 15 | 16 | def __init__(self, _type: str, hits: int, boost: Optional[str]) -> None: 17 | """ 18 | WARNING: This constructor is purely for type completion, and does not exist in the game. 19 | """ 20 | self.type = _type 21 | self.hits = hits 22 | self.boost = boost 23 | 24 | 25 | # noinspection PyPep8Naming 26 | class Creep(RoomObject): 27 | """ 28 | :type body: list[_CreepPart] 29 | :type fatigue: int 30 | :type hits: int 31 | :type hitsMax: int 32 | :type id: str 33 | :type memory: _Memory 34 | :type my: bool 35 | :type name: str 36 | :type owner: _Owner 37 | :type saying: Optional[str] 38 | :type spawning: bool 39 | :type store: Store 40 | :type ticksToLive: int 41 | """ 42 | 43 | prototype = None # type: ClassVar[Any] 44 | 45 | def __init__(self, pos: RoomPosition, room: Room, body: List[_CreepPart], fatigue: int, 46 | hits: int, hitsMax: int, _id: str, memory: _Memory, my: bool, name: str, 47 | owner: _Owner, saying: Optional[str], spawning: bool, store: Store, ticksToLive: int) -> None: 48 | """ 49 | WARNING: This constructor is purely for type completion, and does not exist in the game. 50 | """ 51 | super().__init__(pos, room) 52 | self.body = body 53 | self.fatigue = fatigue 54 | self.hits = hits 55 | self.hitsMax = hitsMax 56 | self.id = _id 57 | self.memory = memory 58 | self.my = my 59 | self.name = name 60 | self.owner = owner 61 | self.saying = saying 62 | self.spawning = spawning 63 | self.store = store 64 | self.ticksToLive = ticksToLive 65 | 66 | def attack(self, target: Union[Structure, 'Creep']) -> int: 67 | pass 68 | 69 | def attackController(self, target: StructureController) -> int: 70 | pass 71 | 72 | def build(self, target: ConstructionSite) -> int: 73 | pass 74 | 75 | def cancelOrder(self, methodName: str) -> int: 76 | pass 77 | 78 | def claimController(self, target: StructureController) -> int: 79 | pass 80 | 81 | def dismantle(self, target: Structure) -> int: 82 | pass 83 | 84 | def drop(self, resourceType: str, amount: int = None) -> int: 85 | pass 86 | 87 | def generateSafeMode(self, target: StructureController) -> int: 88 | pass 89 | 90 | def getActiveBodyparts(self, _type: str) -> int: 91 | pass 92 | 93 | def harvest(self, target: Union[Source, Mineral]) -> int: 94 | pass 95 | 96 | def heal(self, target: 'Creep') -> int: 97 | pass 98 | 99 | def move(self, direction: int) -> int: 100 | pass 101 | 102 | def moveByPath(self, path: Union[list, str]) -> int: 103 | pass 104 | 105 | def moveTo(self, target: Union[RoomPosition, RoomObject], opts: Optional[Dict[str, Any]] = None) -> int: 106 | pass 107 | 108 | def notifyWhenAttacked(self, enabled: bool) -> int: 109 | pass 110 | 111 | def pickup(self, target: Resource) -> int: 112 | pass 113 | 114 | def rangedAttack(self, target: Union['Creep', Structure]) -> int: 115 | pass 116 | 117 | def rangedHeal(self, target: 'Creep') -> int: 118 | pass 119 | 120 | def rangedMassAttack(self) -> int: 121 | pass 122 | 123 | def repair(self, target: Structure) -> int: 124 | pass 125 | 126 | def reserveController(self, target: StructureController) -> int: 127 | pass 128 | 129 | def say(self, message: str, public: bool = False) -> int: 130 | pass 131 | 132 | def signController(self, target: StructureController, message: str) -> int: 133 | pass 134 | 135 | def suicide(self) -> int: 136 | pass 137 | 138 | def transfer(self, target: Union['Creep', Structure], resourceType: str, amount: int = None) -> int: 139 | pass 140 | 141 | def upgradeController(self, target: StructureController) -> int: 142 | pass 143 | 144 | def withdraw(self, target: Structure, resourceType: str, amount: int = None) -> int: 145 | pass 146 | -------------------------------------------------------------------------------- /file_expander.py: -------------------------------------------------------------------------------- 1 | """File Expansion of Nested screeps Source Code. 2 | 3 | This package provides file expansion operations that targets screeps code 4 | written in Python in order to allow files to be organized in a nested directory 5 | structure. 6 | 7 | Every time Transcrypt is run, user generated .py source code will be copied so 8 | that they all sit directly under __py_build__. Only new/updated files will 9 | actually be copied; unmodified files are not replaced in __py_build__. Files can 10 | reside directly under src/, or in subdirectories under src/. 11 | 12 | The -xpath option available through Transcrypt already provides this 13 | functionality; this package serves as a replacement for anyone experiencing 14 | problems with Transcrypt recognizing python modules stored in sub-folders, or 15 | for those looking for an alternative to -xpath itself.""" 16 | 17 | import pathlib 18 | import shutil 19 | import filecmp 20 | 21 | 22 | class FileExpander: 23 | """Class for managing file expansion operations. 24 | 25 | :type base_dir: pathlib.Path 26 | :type build_dir: pathlib.Path 27 | """ 28 | 29 | def __init__(self, base_dir): 30 | """ 31 | :param base_dir: absolute path of the screeps-starter-python directory 32 | :type base_dir: str 33 | 34 | """ 35 | self.base_dir = pathlib.Path(base_dir).joinpath('src') 36 | self.build_dir = self.verify_build_directory() 37 | 38 | def verify_build_directory(self): 39 | """Verifies existence and contents of __py_build__ directory. 40 | 41 | Missing directories are either created, or copied from its counterpart 42 | in src/"" 43 | 44 | :return: concrete Path object of the __py_build__ directory 45 | :rtype: pathlib.Path 46 | """ 47 | 48 | build_directory = self.base_dir.joinpath('__py_build__') 49 | 50 | defs_source_directory = self.base_dir.joinpath('defs') 51 | defs_build_directory = build_directory.joinpath('defs') 52 | 53 | defs_source_path = str(defs_source_directory.absolute()) 54 | defs_build_path = str(defs_build_directory.absolute()) 55 | 56 | if not build_directory.is_dir(): 57 | build_directory.mkdir(exist_ok=True) 58 | 59 | if not defs_build_directory.is_dir(): 60 | shutil.copytree(defs_source_path, defs_build_path) 61 | 62 | self.verify_defs_integrity(defs_source_directory, build_directory) 63 | 64 | return build_directory 65 | 66 | @staticmethod 67 | def verify_defs_integrity(source_dir, build_dir): 68 | """Verifies integrity of defs/ folder in __py_build__ 69 | 70 | File contents under src/defs are compared against __py_build__/defs; a 71 | file update will only be triggered by modifications to files under 72 | src/defs. 73 | 74 | :rtype: None 75 | """ 76 | 77 | defs_source_files = [f.absolute() for f in source_dir.glob('**/*.py')] 78 | 79 | for file in defs_source_files: 80 | slice_index = file.parts.index('src') + 1 81 | partner = build_dir.joinpath(*file.parts[slice_index:]) 82 | 83 | if not partner.is_file() or not filecmp.cmp(str(file), str(partner)): 84 | shutil.copy2(str(file), str(partner)) 85 | 86 | def expand_files(self): 87 | """Creates a flattened file structure of all user-defined screeps code 88 | 89 | Copies all modified or new .py files found directly under src/, or in 90 | subdirectories under src/, to __py_build__. 91 | 92 | :return: total number of files copied to __py_build__ 93 | :rtype: int 94 | """ 95 | 96 | target_files = self.find_target_file_paths() 97 | 98 | copied_files = 0 99 | for target in target_files: 100 | partner = self.build_dir.joinpath(target.name) 101 | 102 | target_path, partner_path = str(target.absolute()), str(partner.absolute()) 103 | 104 | if not (partner.is_file() and filecmp.cmp(target_path, partner_path)): 105 | shutil.copy2(target_path, partner_path) 106 | copied_files += 1 107 | 108 | return copied_files 109 | 110 | def find_target_file_paths(self): 111 | """Finds all potential target files for the file expansion operation 112 | 113 | :return: All files to be checked by self.expand_files 114 | :rtype: list[pathlib.Path] 115 | """ 116 | 117 | exclusions = [ 118 | '__pycache__', 119 | '__javascript__', 120 | '__py_build__', 121 | '.idea', 122 | '.git', 123 | 'defs' 124 | ] 125 | 126 | target_files, target_directories = [], [] 127 | for file_object in self.base_dir.iterdir(): 128 | 129 | if not any(entry in file_object.name for entry in exclusions): 130 | if file_object.is_file(): 131 | target_files.append(file_object) 132 | else: 133 | target_directories.append(file_object) 134 | 135 | # Directories processed separately to avoid performing glob on all of src/ 136 | for directory in target_directories: 137 | for file in directory.glob('**/*.py'): 138 | target_files.append(file) 139 | 140 | return target_files 141 | 142 | -------------------------------------------------------------------------------- /book/setup.md: -------------------------------------------------------------------------------- 1 | Software Setup 2 | ============== 3 | 4 | This repository is intended as a base to be used for building more complex AIs, and has all the tooling needed to 5 | transpile Python into JavaScript set up. 6 | 7 | The `./build.py` script does the majority of the work. It sets up the python 8 | environment, and installs all dependencies. However, you will still need some 9 | base software installed: 10 | 11 | - [`git`] 12 | - [`python`] version 3.7 or above 13 | - [`node.js`] 14 | - `npm` 15 | 16 | 17 | ### Linux Software Install 18 | 19 | Your Linux distribution should have python installed. Use your package manager 20 | (`apt`, `dnf`, etc.) to install `git`, `node` and `npm`. 21 | 22 | ### MacOS Software Setup 23 | 24 | Using [homebrew], install `git`, `python` and `node` (`npm` comes with `node`): 25 | 26 | ``` 27 | brew install git python@3 node 28 | ``` 29 | 30 | ### Windows Software Setup 31 | 32 | Install git from https://git-scm.com/download/win. Default options are fine. 33 | 34 | Install the latest version of Python from https://www.python.org/downloads/. 35 | Again, default options should be fine. 36 | 37 | Install node.js LTS Windows Installer from https://nodejs.org/en/download/. 38 | Default options should again be fine. 39 | 40 | Start "git bash" to start a terminal for the next step. 41 | 42 | [`git`]: https://git-scm.com/ 43 | [`python`]: https://www.python.org/downloads/ 44 | [`node.js`]: https://nodejs.org/en/download/ 45 | [homebrew]: https://brew.sh/ 46 | 47 | 48 | Repository Setup 49 | ================ 50 | 51 | Next, if you haven't already cloned this repository, you'll want to. Use a git 52 | gui if you have one, or: 53 | 54 | ``` 55 | git clone https://github.com/daboross/screeps-starter-python.git 56 | ``` 57 | 58 | Next, you'll want to open this repository in your file manager, copy 59 | `config.default.json` to `config.json` and proceed to [Post Installation 60 | Steps](#post-installation-steps) 61 | 62 | 63 | Post Installation Steps 64 | ======================= 65 | 66 | The last step to setting up `screeps-game-api` is to create and configure the 67 | build. This will allow `build.py` to upload files directly to the screeps server 68 | after building. 69 | 70 | Copy the contents of `config.default.json` into `config.json`. [Generate an 71 | auth-token](https://docs.screeps.com/auth-tokens.html#Using-Auth-Tokens) with 72 | full access rights through your screep's account management page, then copy the 73 | token and paste it to the `token` key in `config.json`. 74 | 75 | Alternatively, you can use your username and password for authentication. To 76 | do this, remove the `token` line, and add `username` and `password` fields to 77 | `config.json`. Be careful about commas - all lines except the last should have 78 | trailing commas. 79 | 80 | Deploying to Screeps 81 | ==================== 82 | 83 | Following that, you're all set up! `build.py` will automatically download and 84 | install the rest of the dependencies into a local environment when it is first 85 | run. 86 | 87 | To run `build.py` on a Unix system (Linux, MacOS), use: 88 | 89 | ``` 90 | python3 build.py 91 | ``` 92 | 93 | To run `build.py` on Windows with raw Python installed from python.org: 94 | 95 | ``` 96 | py build.py 97 | ``` 98 | 99 | On first run, this will install remaining dependencies, then compile, build, and 100 | deploy your code to Screeps! On subsequent runs, it will simply call installed 101 | tools and deploy code from there. 102 | 103 | Installing under Windows using 'conda' 104 | ===================================== 105 | 106 | If you're having trouble running `build.py` in Windows, it might be worth trying 107 | out an alternative installation method. 108 | 109 | For Windows users, running `build.py` may fail if `virtualenv` cannot be 110 | detected in your `PATH`. The setup procedure here should only be used if the 111 | primary installation method at this top of this README does not work. 112 | 113 | This setup procedure uses `conda`, which is provided through the [Miniconda 114 | installer](https://conda.io/miniconda.html) If you already have something 115 | like [Anaconda](https://www.anaconda.com/what-is-anaconda/) on your system, 116 | you can skip this step. If you are new to `conda`, the [official quick start 117 | guide](https://conda.io/docs/user-guide/getting-started.html) does a great job 118 | of covering the basics. 119 | 120 | While Miniconda will install its own version of Python to your system, you do 121 | not need to modify or uninstall any version already in place. The installer 122 | will ask if you want Miniconda to be used as your default version of Python; 123 | if you plan to use conda only for screeps, you can decline. 124 | 125 | Once the installation is complete, look for a program icon labeled `Anaconda 126 | Prompt` and run it. All commands listed for the rest of the guide must be 127 | entered in the terminal created by `Anaconda Prompt`. 128 | 129 | Enter the following commands in the order listed: 130 | 131 | 1. `conda create -n screeps python=3.8` 132 | 2. `activate screeps` 133 | 3. `conda install git` 134 | 135 | Once finished, you can now try `python build.py` again. 136 | 137 | To transpile your Python code to JavaScript, `build.py` must be called from an 138 | Anaconda Prompt using the `screeps` environment; this can be achieved through 139 | the following steps: 140 | 141 | 1. Open an Anaconda Prompt 142 | 2. enter the command: `activate screeps` 143 | 144 | The above steps only need to be performed when opening a new Anaconda Prompt, 145 | you can keep it running in the background while you make changes to your code 146 | and switch to it only when you need to run `build.py`. To deactivate the 147 | `screeps` environment, you can either enter the command `deactivate screeps`, 148 | or you can close the prompt itself. 149 | -------------------------------------------------------------------------------- /src/defs/classes/other_js.py: -------------------------------------------------------------------------------- 1 | from typing import Any, Callable, Dict, Generic, Iterable, Iterator, List, Optional, Tuple, TypeVar, Union 2 | 3 | _K = TypeVar('_K') 4 | _V = TypeVar('_V') 5 | 6 | 7 | # noinspection PyPep8Naming 8 | class Object: 9 | """ 10 | https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object 11 | """ 12 | 13 | @classmethod 14 | def assign(cls, target: Any, *sources: Any) -> None: 15 | pass 16 | 17 | @classmethod 18 | def create(cls, proto: Any, propertiesObject: Any = None) -> None: 19 | pass 20 | 21 | @classmethod 22 | def defineProperties(cls, obj: Any, props: Dict[str, Any]) -> None: 23 | pass 24 | 25 | @classmethod 26 | def defineProperty(cls, obj: Any, prop: str, descriptor: Dict[str, Any]) -> None: 27 | pass 28 | 29 | @classmethod 30 | def freeze(cls, obj: Any) -> None: 31 | pass 32 | 33 | @classmethod 34 | def keys(cls, obj: Dict[_K, _V]) -> List[_K]: 35 | pass 36 | 37 | 38 | class Math: 39 | """ 40 | https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math 41 | """ 42 | 43 | @staticmethod 44 | def abs(x: Union[int, float]) -> Union[int, float]: 45 | pass 46 | 47 | @staticmethod 48 | def exp(x: Union[int, float]) -> Union[int, float]: 49 | pass 50 | 51 | @staticmethod 52 | def sign(x: Union[int, float]) -> int: 53 | pass 54 | 55 | @staticmethod 56 | def random() -> float: 57 | pass 58 | 59 | @staticmethod 60 | def floor(x: Union[int, float]) -> int: 61 | pass 62 | 63 | 64 | # noinspection PyPep8Naming 65 | class String: 66 | @staticmethod 67 | def fromCodePoint(number: int) -> str: 68 | pass 69 | 70 | 71 | # noinspection PyUnusedLocal 72 | def typeof(x: Any) -> str: 73 | pass 74 | 75 | 76 | # noinspection PyUnusedLocal 77 | def require(name: str) -> Any: 78 | pass 79 | 80 | 81 | class JSON: 82 | @classmethod 83 | def parse(cls, s: str) -> Dict[str, Any]: 84 | pass 85 | 86 | @classmethod 87 | def stringify(cls, v: Any, _filter: Any = None, indent: int = 0) -> str: 88 | pass 89 | 90 | 91 | this = None # type: Any 92 | 93 | 94 | # noinspection PyPep8Naming,PyShadowingBuiltins 95 | class module: 96 | # noinspection PyPep8Naming 97 | class exports: 98 | loop = None # type: Optional[Callable[[], None]] 99 | 100 | 101 | class RegExp(str): 102 | def __init__(self, regex: str, args: Optional[str] = None) -> None: 103 | """ 104 | NOTE: In order to use this, you must surround it with `__new__`: `__new__(RegExp(expression))` 105 | """ 106 | super().__init__(regex) 107 | self.ignoreCase = False 108 | self.js_global = False 109 | self.multiline = False 110 | 111 | self.source = regex 112 | 113 | if args is not None: 114 | for char in args: 115 | if char == 'i': 116 | self.ignoreCase = True 117 | elif char == 'g': 118 | self.js_global = True 119 | elif char == 'm': 120 | self.multiline = True 121 | 122 | def __new__(cls, regex: str, args: Optional[str] = None) -> 'RegExp': 123 | return RegExp(regex, args) 124 | 125 | def exec(self, string: str) -> Optional[List[str]]: 126 | pass 127 | 128 | def test(self, string: str) -> bool: 129 | pass 130 | 131 | 132 | _T = TypeVar('_T') 133 | 134 | 135 | class Array(list): 136 | @staticmethod 137 | def js_from(v: Iterable[_T]) -> List[_T]: 138 | pass 139 | 140 | 141 | # noinspection PyPep8Naming 142 | class console: 143 | @staticmethod 144 | def log(string: str) -> None: 145 | pass 146 | 147 | @staticmethod 148 | def addVisual(roomName: str, data: Any) -> None: 149 | pass 150 | 151 | @staticmethod 152 | def getVisualSize(roomName: str) -> int: 153 | pass 154 | 155 | @staticmethod 156 | def clearVisual(roomName: str) -> None: 157 | pass 158 | 159 | 160 | K = TypeVar("K") 161 | V = TypeVar("V") 162 | 163 | 164 | class Map(Generic[K, V]): 165 | def __init__(self, iterable: Optional[List[Tuple[K, V]]] = None) -> None: 166 | """ 167 | NOTE: In order to use this, you must surround it with `__new__`: `__new__(Map(iterable))` 168 | """ 169 | pass 170 | 171 | @property 172 | def size(self) -> int: 173 | return 0 174 | 175 | def clear(self) -> None: 176 | pass 177 | 178 | def delete(self, key: K) -> None: 179 | pass 180 | 181 | def entries(self) -> Iterator[Tuple[K, V]]: 182 | pass 183 | 184 | def forEach(self, callback: Callable[[V, K, 'Map[K, V]'], None]) -> None: 185 | pass 186 | 187 | def get(self, key: K) -> Optional[V]: 188 | pass 189 | 190 | def has(self, key: K) -> bool: 191 | pass 192 | 193 | def keys(self) -> Iterator[K]: 194 | pass 195 | 196 | def set(self, key: K, value: V) -> 'Map[K, V]': 197 | pass 198 | 199 | def values(self) -> Iterator[V]: 200 | pass 201 | 202 | 203 | class Set(Generic[K]): 204 | def __init__(self, iterable: Optional[List[K]] = None) -> None: 205 | """ 206 | NOTE: In order to use this, you must surround it with `__new__`: `__new__(Set(iterable))` 207 | """ 208 | pass 209 | 210 | def has(self, key: K) -> bool: 211 | pass 212 | 213 | def add(self, key: K) -> None: 214 | pass 215 | 216 | def delete(self, key: K) -> None: 217 | pass 218 | 219 | def keys(self) -> Iterable[K]: 220 | pass 221 | 222 | def values(self) -> Iterable[K]: 223 | pass 224 | 225 | def js_clear(self) -> None: 226 | pass 227 | 228 | @property 229 | def size(self) -> int: 230 | return 0 231 | 232 | 233 | Infinity = float('inf') 234 | 235 | undefined = None # type: None 236 | 237 | __all__ = [ 238 | "Object", 239 | "Math", 240 | "String", 241 | "typeof", 242 | "require", 243 | "JSON", 244 | "this", 245 | "module", 246 | "RegExp", 247 | "Array", 248 | "console", 249 | "Map", 250 | "Set", 251 | "Infinity", 252 | "undefined", 253 | ] 254 | -------------------------------------------------------------------------------- /src/defs/classes/misc_obj.py: -------------------------------------------------------------------------------- 1 | # noinspection PyPep8Naming 2 | from typing import Optional, Type, Union, Dict, List 3 | 4 | from .memory import _Memory 5 | from .room import Room, RoomPosition 6 | from .structures import Structure 7 | from .creep import Creep 8 | 9 | 10 | # noinspection PyPep8Naming 11 | class _Effect: # type: List[_Effect] 12 | """ 13 | Applied effects, an array of objects with the following properties 14 | 15 | :type effect: int 16 | :type level: int 17 | :type ticksRemaining: int 18 | """ 19 | def __init__(self, effect: int, level: Optional[int], ticksRemaining: int): 20 | """ 21 | WARNING: This constructor is purely for type completion, and does not exist in the game. 22 | """ 23 | self.effect = effect 24 | self.level = level 25 | self.ticksRemaining = ticksRemaining 26 | 27 | 28 | _Effect = List[_Effect] 29 | 30 | 31 | # noinspection PyPep8Naming 32 | class RoomObject: 33 | """ 34 | Any object with a position in a room. Almost all game objects prototypes are derived from RoomObject. 35 | 36 | :type effects: _Effect 37 | :type pos: RoomPosition 38 | :type room: Room 39 | """ 40 | 41 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Room) -> None: 42 | """ 43 | WARNING: This constructor is purely for type completion, and does not exist in the game. 44 | """ 45 | self.effects = effects 46 | self.pos = pos 47 | self.room = room 48 | 49 | 50 | # noinspection PyPep8Naming 51 | class Flag(RoomObject): 52 | """ 53 | :type effects: _Effect 54 | :type room: Room | None 55 | :type color: int 56 | :type memory: _Memory 57 | :type name: str 58 | :type secondaryColor: int 59 | """ 60 | prototype = None # type: Type[Flag] 61 | 62 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Optional[Room], color: int, memory: _Memory, 63 | name: str, secondaryColor: int) -> None: 64 | """ 65 | WARNING: This constructor is purely for type completion, and does not exist in the game. 66 | """ 67 | super().__init__(effects, pos, room) 68 | self.color = color 69 | self.memory = memory 70 | self.name = name 71 | self.secondaryColor = secondaryColor 72 | 73 | def remove(self) -> int: 74 | pass 75 | 76 | def setColor(self, color: int, secondaryColor: int = None) -> int: 77 | pass 78 | 79 | def setPosition(self, x: Union[int, RoomPosition, RoomObject], y: int = None) -> int: 80 | pass 81 | 82 | @property 83 | def hint(self) -> int: 84 | return 0 85 | 86 | 87 | Flag.prototype = Flag 88 | 89 | 90 | # noinspection PyPep8Naming 91 | class Source(RoomObject): 92 | """ 93 | :type energy: int 94 | :type energyCapacity: int 95 | :type id: str 96 | :type ticksToRegeneration: int 97 | """ 98 | 99 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Optional[Room], energy: int, energyCapacity: int, _id: str, 100 | ticksToRegeneration: int) -> None: 101 | """ 102 | WARNING: This constructor is purely for type completion, and does not exist in the game. 103 | """ 104 | super().__init__(effects, pos, room) 105 | self.energy = energy 106 | self.energyCapacity = energyCapacity 107 | self.id = _id 108 | self.ticksToRegeneration = ticksToRegeneration 109 | 110 | 111 | # noinspection PyPep8Naming 112 | class Mineral(RoomObject): 113 | """ 114 | :type density: int 115 | :type mineralAmount: int 116 | :type mineralType: str 117 | :type id: str 118 | :type ticksToRegeneration: int 119 | """ 120 | 121 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Optional[Room], density: int, mineralAmount: int, mineralType: str, 122 | _id: str, ticksToRegeneration: int) -> None: 123 | """ 124 | WARNING: This constructor is purely for type completion, and does not exist in the game. 125 | """ 126 | super().__init__(effects, pos, room) 127 | self.density = density 128 | self.mineralAmount = mineralAmount 129 | self.mineralType = mineralType 130 | self.id = _id 131 | self.ticksToRegeneration = ticksToRegeneration 132 | 133 | 134 | # noinspection PyPep8Naming 135 | class Resource(RoomObject): 136 | """ 137 | :type amount: int 138 | :type id: str 139 | :type resourceType: str 140 | """ 141 | 142 | def __init__(self, effects: _Effect, pos: RoomPosition, 143 | room: Room, _id: str, amount: int, resourceType: str) -> None: 144 | """ 145 | WARNING: This constructor is purely for type completion, and does not exist in the game. 146 | """ 147 | super().__init__(effects, pos, room) 148 | self.id = _id 149 | self.amount = amount 150 | self.resourceType = resourceType 151 | 152 | 153 | # noinspection PyPep8Naming 154 | class Store: 155 | """ 156 | WARNING: This constructor is purely for type completion, and does not exist in the game. 157 | """ 158 | def getCapacity(self, resource: str = None) -> Union[Dict[str, int], int]: 159 | pass 160 | 161 | def getFreeCapacity(self, resource: str = None) -> Union[Dict[str, int], int]: 162 | pass 163 | 164 | def getUsedCapacity(self, resource: str = None) -> Union[Dict[str, int], int]: 165 | pass 166 | 167 | 168 | # noinspection PyPep8Naming 169 | class Ruin(RoomObject): 170 | """ 171 | :type destroyTime: int 172 | :type id: str 173 | :type store: dict[str, int] 174 | :type _Structure: Structure 175 | :type ticksToDecay: int 176 | """ 177 | 178 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Optional[Room], destroyTime: int, _id: str, 179 | store: Dict[str, int], _Structure: Structure, ticksToDecay: int) -> None: 180 | """ 181 | WARNING: This constructor is purely for type completion, and does not exist in the game. 182 | """ 183 | super().__init__(effects, pos, room) 184 | self.destroyTime = destroyTime 185 | self.id = _id 186 | self.store = store 187 | self.Structure = _Structure 188 | self.ticksToDecay = ticksToDecay 189 | 190 | 191 | # noinspection PyPep8Naming 192 | class Tombstone(RoomObject): 193 | """ 194 | :type deathTime: int 195 | :type id: str 196 | :type store: dict[str, int] 197 | :type _Structure: Structure 198 | :type ticksToDecay: int 199 | """ 200 | 201 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Optional[Room], 202 | creep: Creep, deathTime: int, _id: str, 203 | store: Store, ticksToDecay: int) -> None: 204 | """ 205 | WARNING: This constructor is purely for type completion, and does not exist in the game. 206 | """ 207 | super().__init__(effects, pos, room) 208 | self.creep = creep 209 | self.deathTime = deathTime 210 | self.id = _id 211 | self.store = store 212 | self.ticksToDecay = ticksToDecay 213 | -------------------------------------------------------------------------------- /src/defs/classes/room.py: -------------------------------------------------------------------------------- 1 | from typing import Any, Callable, Dict, List, Optional, Type, Union 2 | 3 | # noinspection PyProtectedMember 4 | from .memory import _Memory 5 | from .misc_obj import RoomObject 6 | from .structures import StructureController, StructureStorage, StructureTerminal 7 | from ..transcrypt import Uint8Array 8 | 9 | _HasPosition = Union['RoomPosition', 'RoomObject'] 10 | _FindParameter = Union[int, List[_HasPosition]] 11 | 12 | 13 | # noinspection PyPep8Naming 14 | class _Event: 15 | """ 16 | :type event: int 17 | :type objectId: str 18 | :type data: Dict[str, Any] 19 | """ 20 | 21 | def __init__(self, event: int, objectId: str, data: Dict[str, Any]) -> None: 22 | """ 23 | WARNING: This constructor is purely for type completion, and does not exist in the game. 24 | """ 25 | self.event = event # type: int 26 | self.objectId = objectId # type: str 27 | self.data = data # type: Dict[str, Any] 28 | 29 | 30 | class _Owner: 31 | """ 32 | :type username: str 33 | """ 34 | 35 | def __init__(self, username: str) -> None: 36 | """ 37 | WARNING: This constructor is purely for type completion, and does not exist in the game. 38 | """ 39 | self.username = username 40 | 41 | 42 | class _PathPos: 43 | """ 44 | :type x: int 45 | :type y: int 46 | :type dx: int 47 | :type dy: int 48 | :type direction: int 49 | """ 50 | 51 | def __init__(self, x: int, y: int, dx: int, dy: int, direction: int) -> None: 52 | """ 53 | WARNING: This constructor is purely for type completion, and does not exist in the game. 54 | """ 55 | self.x = x 56 | self.y = y 57 | self.dx = dx 58 | self.dy = dy 59 | self.direction = direction 60 | 61 | 62 | # noinspection PyPep8Naming 63 | class RoomPosition: 64 | """ 65 | :type x: int 66 | :type y: int 67 | :type roomName: str 68 | :type prototype: Type[RoomPosition] 69 | """ 70 | prototype = None # type: Type[RoomPosition] 71 | 72 | def __init__(self, x: int, y: int, roomName: str) -> None: 73 | """ 74 | NOTE: In order to use this, you must surround it with `__new__`: `__new__(RoomPosition(x, y, roomName))` 75 | """ 76 | self.x = x 77 | self.y = y 78 | self.roomName = roomName 79 | 80 | def createConstructionSite(self, structureType: str) -> int: 81 | pass 82 | 83 | def createFlag(self, name: str = None, color: int = None, secondaryColor: int = None) -> Union[str, int]: 84 | pass 85 | 86 | def findClosestByPath(self, source: _FindParameter, opts: Optional[Dict[str, Any]] = None) -> Optional[RoomObject]: 87 | pass 88 | 89 | def findClosestByRange(self, source: _FindParameter, opts: Optional[Dict[str, Any]] = None) -> Optional[RoomObject]: 90 | pass 91 | 92 | def findInRange(self, source: _FindParameter, _range: int, opts: Optional[Dict[str, Any]] = None) \ 93 | -> List[RoomObject]: 94 | pass 95 | 96 | def findPathTo(self, source: _FindParameter, opts: Optional[Dict[str, Any]] = None) \ 97 | -> List[_PathPos]: 98 | pass 99 | 100 | def getDirectionTo(self, x: Union[int, 'RoomPosition', RoomObject], y: int = None) -> int: 101 | pass 102 | 103 | def getRangeTo(self, x: Union[int, 'RoomPosition', RoomObject], y: int = None) -> int: 104 | pass 105 | 106 | def inRangeTo(self, x: Union[int, 'RoomPosition', RoomObject], y_or_range: int = None, 107 | _range: int = None) -> bool: 108 | pass 109 | 110 | def isEqualTo(self, x: Union[int, 'RoomPosition', RoomObject], y: int = None) -> bool: 111 | pass 112 | 113 | def isNearTo(self, x: Union[int, 'RoomPosition', RoomObject], y: int = None) -> bool: 114 | pass 115 | 116 | def look(self) -> List[Dict[str, Any]]: 117 | pass 118 | 119 | def lookFor(self, _type: str) -> List[RoomObject]: 120 | pass 121 | 122 | 123 | RoomPosition.prototype = RoomPosition 124 | 125 | 126 | # noinspection PyPep8Naming 127 | class Room: 128 | """ 129 | :type controller: Optional[StructureController] 130 | :type storage: Optional[StructureStorage] 131 | :type terminal: Optional[StructureTerminal] 132 | :type energyAvailable: int 133 | :type energyCapacityAvailable: int 134 | :type memory: _Memory 135 | :type mode: str 136 | :type name: str 137 | :type visual: Any 138 | """ 139 | 140 | # noinspection PyPep8Naming 141 | class Terrain: 142 | """ 143 | :type roomName: str 144 | """ 145 | 146 | def __init__(self, roomName: str) -> None: 147 | """ 148 | WARNING: This constructor is purely for type completion, and does not exist in the game. 149 | """ 150 | self.roomName = roomName 151 | 152 | def get(self, x: int, y: int) -> int: 153 | pass 154 | 155 | def getRawBuffer(self, destinationArray: Optional[Uint8Array]) -> None: 156 | pass 157 | 158 | def __init__(self, controller: Optional[StructureController], storage: Optional[StructureStorage], 159 | terminal: Optional[StructureTerminal], energyAvailable: int, energyCapacityAvailable: int, 160 | memory: _Memory, mode: str, name: str, visual: Any) -> None: 161 | """ 162 | WARNING: This constructor is purely for type completion, and does not exist in the game. 163 | """ 164 | self.controller = controller # type: Optional[StructureController] 165 | self.storage = storage # type: Optional[StructureStorage] 166 | self.terminal = terminal # type: Optional[StructureTerminal] 167 | self.energyAvailable = energyAvailable # type: int 168 | self.energyCapacityAvailable = energyCapacityAvailable # type: int 169 | self.memory = memory # type: _Memory 170 | self.mode = mode # type: str 171 | self.name = name # type: str 172 | self.visual = visual # type: Any 173 | 174 | @classmethod 175 | def serializePath(cls, path: List[Union[_PathPos, Dict[str, Any], RoomPosition]]) -> str: 176 | pass 177 | 178 | @classmethod 179 | def deserializePath(cls, path: str) -> List[_PathPos]: 180 | pass 181 | 182 | def createConstructionSite(self, x: Union[int, RoomPosition, RoomObject], y: Union[int, str], 183 | structureType: str = None) -> int: 184 | pass 185 | 186 | def createFlag(self, pos: Union[RoomPosition, RoomObject], name: str = None, color: int = None, 187 | secondaryColor: int = None) -> Union[str, int]: 188 | pass 189 | 190 | def find(self, _type: _FindParameter, 191 | opts: Optional[Dict[str, Union[Callable[[RoomObject], bool], Dict[str, Any]]]] = None) \ 192 | -> List[RoomObject]: 193 | pass 194 | 195 | def findExitTo(self, room: str) -> int: 196 | pass 197 | 198 | def findPath(self, fromPos: RoomPosition, toPos: RoomPosition, opts: Dict[str, Any]) \ 199 | -> List[Union[_PathPos, Dict[str, Any]]]: 200 | pass 201 | 202 | def getEventLog(self, raw: bool = False) -> List[_Event]: 203 | pass 204 | 205 | def getPositionAt(self, x: int, y: int) -> RoomPosition: 206 | pass 207 | 208 | def getTerrain(self) -> 'Room.Terrain': 209 | pass 210 | 211 | def lookAt(self, x: Union[int, RoomPosition, RoomObject], y: int = None) -> List[Dict[str, Any]]: 212 | pass 213 | 214 | def lookAtArea(self, top: int, left: int, bottom: int, right: int, asArray: bool = False) \ 215 | -> Union[List[Dict[str, Any]], Dict[int, Dict[int, Dict[str, Any]]]]: 216 | pass 217 | 218 | def lookForAt(self, _type: str, x: Union[int, RoomPosition, RoomObject], y: int = None) -> List[RoomObject]: 219 | pass 220 | 221 | def lookForAtArea(self, _type: str, top: int, left: int, bottom: int, right: int, asArray: bool = False) \ 222 | -> Union[List[Dict[str, RoomObject]], Dict[int, Dict[int, Dict[str, RoomObject]]]]: 223 | pass 224 | -------------------------------------------------------------------------------- /src/defs/classes/game.py: -------------------------------------------------------------------------------- 1 | from typing import Any, Callable, Dict, List, Optional, Union 2 | import warnings 3 | 4 | from .creep import Creep 5 | from .misc_obj import Flag, RoomObject 6 | # noinspection PyProtectedMember 7 | from .room import Room, RoomPosition, _Owner 8 | from .structures import ConstructionSite, OwnedStructure, Structure, StructureSpawn 9 | 10 | 11 | # noinspection PyPep8Naming 12 | class _GameCpu: 13 | """ 14 | :type limit: int 15 | :type tickLimit: int 16 | :type bucket: int 17 | :type shardLimits: Dict[str, int] 18 | """ 19 | 20 | def __init__(self, limit: int, tickLimit: int, bucket: int, shardLimits: Dict[str, int]) -> None: 21 | """ 22 | WARNING: This constructor is purely for type completion, and does not exist in the game. 23 | """ 24 | self.limit = limit 25 | self.tickLimit = tickLimit 26 | self.bucket = bucket 27 | self.shardLimits = shardLimits 28 | 29 | def getUsed(self) -> float: 30 | pass 31 | 32 | def setShardLimits(self, shardLimits: Dict[str, int]) -> int: 33 | pass 34 | 35 | 36 | class _GameShard: 37 | """ 38 | :type name: str 39 | :type type: str 40 | :type ptr: bool 41 | """ 42 | 43 | def __init__(self, name: str, type: str, ptr: bool) -> None: 44 | """ 45 | WARNING: This constructor is purely for type completion, and does not exist in the game. 46 | """ 47 | self.name = name 48 | self.type = type 49 | self.ptr = ptr 50 | 51 | 52 | # noinspection PyPep8Naming 53 | class _GameGcl: 54 | """ 55 | :type level: int 56 | :type progress: int 57 | :type progressTotal: int 58 | """ 59 | 60 | def __init__(self, level: int, progress: int, progressTotal: int) -> None: 61 | """ 62 | WARNING: This constructor is purely for type completion, and does not exist in the game. 63 | """ 64 | self.level = level 65 | self.progress = progress 66 | self.progressTotal = progressTotal 67 | 68 | 69 | # noinspection PyPep8Naming 70 | class _GameGpl: 71 | """ 72 | Your Global Power Level, an object with the following properties : 73 | 74 | :type level: int 75 | :type progress: int 76 | :type progressTotal: int 77 | """ 78 | 79 | def __init__(self, level: int, progress: int, progressTotal: int) -> None: 80 | """ 81 | WARNING: This constructor is purely for type completion, and does not exist in the game. 82 | """ 83 | self.level = level 84 | self.progress = progress 85 | self.progressTotal = progressTotal 86 | 87 | 88 | # noinspection PyPep8Naming 89 | class _GameMap: 90 | def describeExits(self, roomName: str) -> Dict[int, str]: 91 | pass 92 | 93 | def findExit(self, fromRoom: str, toRoom: str, opts: Dict[str, Any]) -> int: 94 | pass 95 | 96 | def findRoute(self, fromRoom: str, toRoom: str, opts: Dict[str, Any]) -> List[Dict[str, Union[int, str]]]: 97 | pass 98 | 99 | def getRoomLinearDistance(self, roomName1: str, roomName2: str, terminalDistance: bool = False) -> int: 100 | pass 101 | 102 | def getRoomTerrain(self, roomName: str) -> Room.Terrain: 103 | pass 104 | 105 | def getTerrainAt(self, x: Union[int, RoomPosition], y: int = None, roomName: str = None) -> str: 106 | warnings.warn("This method is deprecated and will be removed soon. \n" 107 | "Please use a faster method Game.map.getRoomTerrain instead.", DeprecationWarning) 108 | pass 109 | 110 | def getWorldSize(self, roomName: str) -> int: 111 | pass 112 | 113 | def isRoomAvailable(self, roomName: str) -> bool: 114 | pass 115 | 116 | 117 | class _MarketTransactionOrder: 118 | """ 119 | :type id: str 120 | :type type: str 121 | :type price: float 122 | """ 123 | 124 | def __init__(self, _id: str, _type: str, price: int) -> None: 125 | """ 126 | WARNING: This constructor is purely for type completion, and does not exist in the game. 127 | """ 128 | self.id = _id 129 | self.type = _type 130 | self.price = price 131 | 132 | 133 | # noinspection PyPep8Naming 134 | class _MarketTransaction: 135 | """ 136 | :type transactionId: str 137 | :type time: int 138 | :type sender: _Owner 139 | :type recipient: _Owner 140 | :type resourceType: str 141 | :type amount: int 142 | :type js_from: str 143 | :type to: str 144 | :type description: str 145 | :type order: _MarketTransactionOrder | None 146 | """ 147 | 148 | def __init__(self, transactionId: str, time: int, sender: _Owner, recipient: _Owner, resourceType: str, 149 | amount: int, js_from: str, to: str, description: str, order: Optional[_MarketTransactionOrder]) \ 150 | -> None: 151 | """ 152 | WARNING: This constructor is purely for type completion, and does not exist in the game. 153 | """ 154 | self.transactionId = transactionId 155 | self.time = time 156 | self.sender = sender 157 | self.recipient = recipient 158 | self.resourceType = resourceType 159 | self.amount = amount 160 | self.js_from = js_from 161 | self.to = to 162 | self.description = description 163 | self.order = order 164 | 165 | 166 | # noinspection PyPep8Naming 167 | class _MarketOrder: 168 | """ 169 | :type id: str 170 | :type created: int 171 | :type type: str 172 | :type resourceType: str 173 | :type roomName: str 174 | :type amount: int 175 | :type remainingAmount: int 176 | :type price: float 177 | """ 178 | 179 | def __init__(self, _id: str, created: int, _type: str, resourceType: str, roomName: str, amount: int, 180 | remainingAmount: int, price: float) -> None: 181 | """ 182 | WARNING: This constructor is purely for type completion, and does not exist in the game. 183 | """ 184 | self.id = _id 185 | self.created = created 186 | self.type = _type 187 | self.resourceType = resourceType 188 | self.roomName = roomName 189 | self.amount = amount 190 | self.remainingAmount = remainingAmount 191 | self.price = price 192 | 193 | 194 | # noinspection PyPep8Naming 195 | class _MarketHistory: 196 | """ 197 | :type resourceType: str 198 | :type date: str 199 | :type transactions: int 200 | :type volume: int 201 | :type avgPrice: float 202 | :type stddevPrice: float 203 | """ 204 | 205 | def __init__(self, resourceType: str, date: str, transactions: int, volume: int, avgPrice: float, 206 | stddevPrice: float) -> None: 207 | """ 208 | WARNING: This constructor is purely for type completion, and does not exist in the game. 209 | """ 210 | self.resourceType = resourceType 211 | self.date = date 212 | self.transactions = transactions 213 | self.volume = volume 214 | self.avgPrice = avgPrice 215 | self.stddevPrice = stddevPrice 216 | 217 | 218 | # noinspection PyPep8Naming 219 | class _OwnedMarketOrder(_MarketOrder): 220 | """ 221 | :type active: bool 222 | :type totalAmount: int 223 | """ 224 | 225 | def __init__(self, _id: str, created: int, _type: str, resourceType: str, roomName: str, amount: int, 226 | remainingAmount: int, price: float, active: bool, totalAmount: int) -> None: 227 | """ 228 | WARNING: This constructor is purely for type completion, and does not exist in the game. 229 | """ 230 | super().__init__(_id, created, _type, resourceType, roomName, amount, remainingAmount, price) 231 | self.active = active 232 | self.totalAmount = totalAmount 233 | 234 | 235 | # noinspection PyPep8Naming 236 | class _GameMarket: 237 | """ 238 | :type credits: int 239 | :type incomingTransactions: list[_MarketTransaction] 240 | :type outgoingTransactions: list[_MarketTransaction] 241 | :type orders: dict[str, _OwnedMarketOrder] 242 | """ 243 | 244 | def __init__(self, _credits: int, incomingTransactions: List[_MarketTransaction], 245 | outgoingTransactions: List[_MarketTransaction], orders: Dict[str, _OwnedMarketOrder]) -> None: 246 | """ 247 | WARNING: This constructor is purely for type completion, and does not exist in the game. 248 | """ 249 | self.credits = _credits 250 | self.incomingTransactions = incomingTransactions 251 | self.outgoingTransactions = outgoingTransactions 252 | self.orders = orders 253 | 254 | def calcTransactionCost(self, amount: Union[int, float], roomName1: str, roomName2: str) -> int: 255 | pass 256 | 257 | def cancelOrder(self, orderId: str) -> int: 258 | pass 259 | 260 | def changeOrderPrice(self, orderId: str, newPrice: float) -> int: 261 | pass 262 | 263 | def createOrder(self, _type: str, resourceType: str, price: float, totalAmount: int, roomName: str = None) \ 264 | -> int: 265 | pass 266 | 267 | def deal(self, orderId: str, amount: Union[int, float], yourRoomName: str = None) -> int: 268 | pass 269 | 270 | def extendOrder(self, orderId: str, addAmount: int) -> int: 271 | pass 272 | 273 | def getAllOrders(self, _filter: Union[Dict[str, Union[int, str]], Callable[[_MarketOrder], bool]]) \ 274 | -> List[_MarketOrder]: 275 | pass 276 | 277 | def getHistory(self, resourceType: [str]) -> _MarketHistory: 278 | pass 279 | 280 | def getOrderById(self, _id: str) -> _MarketOrder: 281 | pass 282 | 283 | 284 | # noinspection PyPep8Naming 285 | class Game: 286 | """ 287 | :type constructionSites: dict[str, ConstructionSite] 288 | :type cpu: _GameCpu 289 | :type creeps: dict[str, Creep] 290 | :type flags: dict[str, Flag] 291 | :type gcl: _GameGcl 292 | :type map: _GameMap 293 | :type market: _GameMarket 294 | :type resources: dict[str, int] 295 | :type rooms: dict[str, Room] 296 | :type spawns: dict[str, StructureSpawn] 297 | :type structures: dict[str, Structure] 298 | :type time: int 299 | """ 300 | constructionSites = {} # type: Dict[str, ConstructionSite] 301 | cpu = None # type: _GameCpu 302 | creeps = {} # type: Dict[str, Creep] 303 | flags = {} # type: Dict[str, Flag] 304 | gcl = None # type: _GameGcl 305 | gpl = None # type: _GameGpl 306 | map = None # type: _GameMap 307 | market = None # type: _GameMarket 308 | resources = {} # type: Dict[str, int] 309 | rooms = {} # type: Dict[str, Room] 310 | shard = None # type: _GameShard 311 | spawns = {} # type: Dict[str, StructureSpawn] 312 | structures = {} # type: Dict[str, OwnedStructure] 313 | time = 0 # type: int 314 | 315 | @classmethod 316 | def getObjectById(cls, _id: str) -> Optional[RoomObject]: 317 | pass 318 | 319 | @classmethod 320 | def notify(cls, message: str, groupInterval: int = 0) -> None: 321 | pass 322 | 323 | 324 | class _PathFinderResult: 325 | """ 326 | :type path: List[RoomPosition] 327 | :type ops: int 328 | :type cost: int 329 | :type incomplete: bool 330 | """ 331 | 332 | def __init__(self, path: List[RoomPosition], ops: int, cost: int, incomplete: bool) -> None: 333 | """ 334 | WARNING: This constructor is purely for type completion, and does not exist in the game. 335 | """ 336 | self.path = path 337 | self.ops = ops 338 | self.cost = cost 339 | self.incomplete = incomplete 340 | 341 | 342 | class PathFinder: 343 | @staticmethod 344 | def search(origin: RoomPosition, goal: Union[Dict[str, Any], List[Dict[str, Any]]], 345 | opts: Optional[Dict[str, Any]] = None) -> _PathFinderResult: 346 | pass 347 | 348 | class CostMatrix: 349 | def __init__(self) -> None: 350 | """ 351 | NOTE: In order to use this, you must surround it with `__new__`: `__new__(CostMatrix())` 352 | """ 353 | pass 354 | 355 | def set(self, x: int, y: int, cost: int) -> None: 356 | pass 357 | 358 | def get(self, x: int, y: int) -> int: 359 | pass 360 | 361 | def clone(self) -> 'PathFinder.CostMatrix': 362 | pass 363 | 364 | def serialize(self) -> List[int]: 365 | pass 366 | 367 | @staticmethod 368 | def deserialize(x: List[int]) -> 'PathFinder.CostMatrix': 369 | pass 370 | -------------------------------------------------------------------------------- /src/defs/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | This directory contains mock-up objects for many of Screep's JavaScript game objects. 3 | 4 | There are not typings for everything, and some, such as those for `_` (lodash), exist but are incomplete. 5 | 6 | I'll continue to add things to this, but if there's something in particular you need, it's very 7 | easy to either add it yourself and submit a PR to this repository, or submit an issue asking 8 | for the class. 9 | 10 | A few notes: 11 | 12 | - None of the constructors for game objects are accurate. It's not reliable to create these in game, 13 | but a 'fake' constructor with all attributes as arguments is created to give type checkers correct 14 | thoughts on what properties should exist. 15 | - All methods and properties are typed with python-3.5+ annotations, and all properties are *also* 16 | typed with `:type x: y` style types, for editors such as PyCharm which do not fully use annotations 17 | for type hinting. 18 | """ 19 | 20 | # noinspection PyUnboundLocalVariable,PyUnresolvedReferences 21 | __pragma__('skip') 22 | 23 | from typing import TYPE_CHECKING 24 | 25 | if TYPE_CHECKING: 26 | from transcrypt.modules.org.transcrypt.stubs.browser import __pragma__ 27 | 28 | from .constants import * 29 | from .classes import * 30 | from .transcrypt import * 31 | 32 | # Generated manually using regexes on the sub files 33 | __all__ = [ 34 | # constants 35 | "OK", 36 | "ERR_NOT_OWNER", 37 | "ERR_NO_PATH", 38 | "ERR_NAME_EXISTS", 39 | "ERR_BUSY", 40 | "ERR_NOT_FOUND", 41 | "ERR_NOT_ENOUGH_ENERGY", 42 | "ERR_NOT_ENOUGH_RESOURCES", 43 | "ERR_INVALID_TARGET", 44 | "ERR_FULL", 45 | "ERR_NOT_IN_RANGE", 46 | "ERR_INVALID_ARGS", 47 | "ERR_TIRED", 48 | "ERR_NO_BODYPART", 49 | "ERR_NOT_ENOUGH_EXTENSIONS", 50 | "ERR_RCL_NOT_ENOUGH", 51 | "ERR_GCL_NOT_ENOUGH", 52 | 53 | "FIND_EXIT_TOP", 54 | "FIND_EXIT_RIGHT", 55 | "FIND_EXIT_BOTTOM", 56 | "FIND_EXIT_LEFT", 57 | "FIND_EXIT", 58 | "FIND_CREEPS", 59 | "FIND_MY_CREEPS", 60 | "FIND_HOSTILE_CREEPS", 61 | "FIND_SOURCES_ACTIVE", 62 | "FIND_SOURCES", 63 | "FIND_DROPPED_RESOURCES", 64 | "FIND_STRUCTURES", 65 | "FIND_MY_STRUCTURES", 66 | "FIND_HOSTILE_STRUCTURES", 67 | "FIND_FLAGS", 68 | "FIND_CONSTRUCTION_SITES", 69 | "FIND_MY_SPAWNS", 70 | "FIND_HOSTILE_SPAWNS", 71 | "FIND_MY_CONSTRUCTION_SITES", 72 | "FIND_HOSTILE_CONSTRUCTION_SITES", 73 | "FIND_MINERALS", 74 | "FIND_NUKES", 75 | "FIND_TOMBSTONES", 76 | "FIND_MY_POWER_CREEPS", 77 | 'FIND_HOSTILE_POWER_CREEPS', 78 | 'FIND_DEPOSITS', 79 | 'FIND_RUINS', 80 | 81 | "TOP", 82 | "TOP_RIGHT", 83 | "RIGHT", 84 | "BOTTOM_RIGHT", 85 | "BOTTOM", 86 | "BOTTOM_LEFT", 87 | "LEFT", 88 | "TOP_LEFT", 89 | 90 | "COLOR_RED", 91 | "COLOR_PURPLE", 92 | "COLOR_BLUE", 93 | "COLOR_CYAN", 94 | "COLOR_GREEN", 95 | "COLOR_YELLOW", 96 | "COLOR_ORANGE", 97 | "COLOR_BROWN", 98 | "COLOR_GREY", 99 | "COLOR_WHITE", 100 | 101 | "LOOK_CREEPS", 102 | "LOOK_ENERGY", 103 | "LOOK_RESOURCES", 104 | "LOOK_SOURCES", 105 | "LOOK_MINERALS", 106 | "LOOK_STRUCTURES", 107 | "LOOK_FLAGS", 108 | "LOOK_CONSTRUCTION_SITES", 109 | "LOOK_NUKES", 110 | "LOOK_TERRAIN", 111 | 'LOOK_TOMBSTONES', 112 | 'LOOK_POWER_CREEPS', 113 | 'LOOK_RUINS', 114 | 115 | 116 | "OBSTACLE_OBJECT_TYPES", 117 | 118 | "MOVE", 119 | "WORK", 120 | "CARRY", 121 | "ATTACK", 122 | "RANGED_ATTACK", 123 | "TOUGH", 124 | "HEAL", 125 | "CLAIM", 126 | 127 | "BODYPART_COST", 128 | 129 | "WORLD_WIDTH", 130 | "WORLD_HEIGHT", 131 | 132 | "CREEP_LIFE_TIME", 133 | "CREEP_CLAIM_LIFE_TIME", 134 | "CREEP_CORPSE_RATE", 135 | 'CREEP_PART_MAX_ENERGY', 136 | 137 | "CARRY_CAPACITY", 138 | "HARVEST_POWER", 139 | "HARVEST_MINERAL_POWER", 140 | "REPAIR_POWER", 141 | "DISMANTLE_POWER", 142 | "BUILD_POWER", 143 | "ATTACK_POWER", 144 | "UPGRADE_CONTROLLER_POWER", 145 | "RANGED_ATTACK_POWER", 146 | "HEAL_POWER", 147 | "RANGED_HEAL_POWER", 148 | "REPAIR_COST", 149 | "DISMANTLE_COST", 150 | 151 | "RAMPART_DECAY_AMOUNT", 152 | "RAMPART_DECAY_TIME", 153 | "RAMPART_HITS", 154 | "RAMPART_HITS_MAX", 155 | 156 | "ENERGY_REGEN_TIME", 157 | "ENERGY_DECAY", 158 | 159 | "SPAWN_HITS", 160 | "SPAWN_ENERGY_START", 161 | "SPAWN_ENERGY_CAPACITY", 162 | "CREEP_SPAWN_TIME", 163 | "SPAWN_RENEW_RATIO", 164 | 165 | "SOURCE_ENERGY_CAPACITY", 166 | "SOURCE_ENERGY_NEUTRAL_CAPACITY", 167 | "SOURCE_ENERGY_KEEPER_CAPACITY", 168 | 169 | "WALL_HITS", 170 | "WALL_HITS_MAX", 171 | 172 | "EXTENSION_HITS", 173 | "EXTENSION_ENERGY_CAPACITY", 174 | 175 | "ROAD_HITS", 176 | "ROAD_WEAROUT", 177 | "ROAD_DECAY_AMOUNT", 178 | "ROAD_DECAY_TIME", 179 | 180 | "LINK_HITS", 181 | "LINK_HITS_MAX", 182 | "LINK_CAPACITY", 183 | "LINK_COOLDOWN", 184 | "LINK_LOSS_RATIO", 185 | 186 | "STORAGE_CAPACITY", 187 | "STORAGE_HITS", 188 | 189 | "STRUCTURE_SPAWN", 190 | "STRUCTURE_EXTENSION", 191 | "STRUCTURE_ROAD", 192 | "STRUCTURE_WALL", 193 | "STRUCTURE_RAMPART", 194 | "STRUCTURE_KEEPER_LAIR", 195 | "STRUCTURE_PORTAL", 196 | "STRUCTURE_CONTROLLER", 197 | "STRUCTURE_LINK", 198 | "STRUCTURE_STORAGE", 199 | "STRUCTURE_TOWER", 200 | "STRUCTURE_OBSERVER", 201 | "STRUCTURE_POWER_BANK", 202 | "STRUCTURE_POWER_SPAWN", 203 | "STRUCTURE_EXTRACTOR", 204 | "STRUCTURE_LAB", 205 | "STRUCTURE_TERMINAL", 206 | "STRUCTURE_CONTAINER", 207 | "STRUCTURE_NUKER", 208 | 'STRUCTURE_FACTORY', 209 | 'STRUCTURE_INVADER_CORE', 210 | 211 | 212 | "CONSTRUCTION_COST", 213 | "CONSTRUCTION_COST_ROAD_SWAMP_RATIO", 214 | 'CONSTRUCTION_COST_ROAD_WALL_RATIO', 215 | 216 | "CONTROLLER_LEVELS", 217 | "CONTROLLER_STRUCTURES", 218 | "CONTROLLER_DOWNGRADE", 219 | 'CONTROLLER_DOWNGRADE_RESTORE', 220 | 'CONTROLLER_DOWNGRADE_SAFEMODE_THRESHOLD', 221 | "CONTROLLER_CLAIM_DOWNGRADE", 222 | "CONTROLLER_RESERVE", 223 | "CONTROLLER_RESERVE_MAX", 224 | "CONTROLLER_MAX_UPGRADE_PER_TICK", 225 | "CONTROLLER_ATTACK_BLOCKED_UPGRADE", 226 | "CONTROLLER_NUKE_BLOCKED_UPGRADE", 227 | 228 | "SAFE_MODE_DURATION", 229 | "SAFE_MODE_COOLDOWN", 230 | "SAFE_MODE_COST", 231 | 232 | "TOWER_HITS", 233 | "TOWER_CAPACITY", 234 | "TOWER_ENERGY_COST", 235 | "TOWER_POWER_ATTACK", 236 | "TOWER_POWER_HEAL", 237 | "TOWER_POWER_REPAIR", 238 | "TOWER_OPTIMAL_RANGE", 239 | "TOWER_FALLOFF_RANGE", 240 | "TOWER_FALLOFF", 241 | 242 | "OBSERVER_HITS", 243 | "OBSERVER_RANGE", 244 | 245 | "POWER_BANK_HITS", 246 | "POWER_BANK_CAPACITY_MAX", 247 | "POWER_BANK_CAPACITY_MIN", 248 | "POWER_BANK_CAPACITY_CRIT", 249 | "POWER_BANK_DECAY", 250 | "POWER_BANK_HIT_BACK", 251 | "POWER_SPAWN_HITS", 252 | "POWER_SPAWN_ENERGY_CAPACITY", 253 | "POWER_SPAWN_POWER_CAPACITY", 254 | "POWER_SPAWN_ENERGY_RATIO", 255 | 256 | "EXTRACTOR_HITS", 257 | "EXTRACTOR_COOLDOWN", 258 | 259 | "LAB_HITS", 260 | "LAB_MINERAL_CAPACITY", 261 | "LAB_ENERGY_CAPACITY", 262 | "LAB_BOOST_ENERGY", 263 | "LAB_BOOST_MINERAL", 264 | "LAB_COOLDOWN", 265 | "LAB_REACTION_AMOUNT", 266 | 'LAB_UNBOOST_ENERGY', 267 | 'LAB_UNBOOST_MINERAL', 268 | 269 | "GCL_POW", 270 | "GCL_MULTIPLY", 271 | "GCL_NOVICE", 272 | 273 | "MODE_SIMULATION", 274 | "MODE_WORLD", 275 | 276 | "TERRAIN_MASK_WALL", 277 | "TERRAIN_MASK_SWAMP", 278 | "TERRAIN_MASK_LAVA", 279 | 280 | "MAX_CONSTRUCTION_SITES", 281 | "MAX_CREEP_SIZE", 282 | 283 | "MINERAL_REGEN_TIME", 284 | "MINERAL_MIN_AMOUNT", 285 | "MINERAL_RANDOM_FACTOR", 286 | 287 | "MINERAL_DENSITY", 288 | "MINERAL_DENSITY_PROBABILITY", 289 | "MINERAL_DENSITY_CHANGE", 290 | 291 | "DENSITY_LOW", 292 | "DENSITY_MODERATE", 293 | "DENSITY_HIGH", 294 | "DENSITY_ULTRA", 295 | 296 | "TERMINAL_CAPACITY", 297 | "TERMINAL_HITS", 298 | "TERMINAL_SEND_COST", 299 | "TERMINAL_MIN_SEND", 300 | 'TERMINAL_COOLDOWN', 301 | 302 | "CONTAINER_HITS", 303 | "CONTAINER_CAPACITY", 304 | "CONTAINER_DECAY", 305 | "CONTAINER_DECAY_TIME", 306 | "CONTAINER_DECAY_TIME_OWNED", 307 | 308 | "NUKER_HITS", 309 | "NUKER_COOLDOWN", 310 | "NUKER_ENERGY_CAPACITY", 311 | "NUKER_GHODIUM_CAPACITY", 312 | "NUKE_LAND_TIME", 313 | "NUKE_RANGE", 314 | "NUKE_DAMAGE", 315 | 'FACTORY_HITS', 316 | 'FACTORY_CAPACITY', 317 | 'TOMBSTONE_DECAY_PER_PART', 318 | 'TOMBSTONE_DECAY_POWER_CREEP', 319 | 'RUIN_DECAY', 320 | 'RUIN_DECAY_STRUCTURES', 321 | 322 | "PORTAL_DECAY", 323 | 324 | "ORDER_SELL", 325 | "ORDER_BUY", 326 | 327 | "MARKET_FEE", 328 | 329 | 'MARKET_MAX_ORDERS', 330 | 'MARKET_ORDER_LIFE_TIME', 331 | 332 | "FLAGS_LIMIT", 333 | 334 | "SUBSCRIPTION_TOKEN", 335 | 336 | "RESOURCE_ENERGY", 337 | "RESOURCE_POWER", 338 | 339 | "RESOURCE_HYDROGEN", 340 | "RESOURCE_OXYGEN", 341 | "RESOURCE_UTRIUM", 342 | "RESOURCE_LEMERGIUM", 343 | "RESOURCE_KEANIUM", 344 | "RESOURCE_ZYNTHIUM", 345 | "RESOURCE_CATALYST", 346 | "RESOURCE_GHODIUM", 347 | 348 | "RESOURCE_HYDROXIDE", 349 | "RESOURCE_ZYNTHIUM_KEANITE", 350 | "RESOURCE_UTRIUM_LEMERGITE", 351 | 352 | "RESOURCE_UTRIUM_HYDRIDE", 353 | "RESOURCE_UTRIUM_OXIDE", 354 | "RESOURCE_KEANIUM_HYDRIDE", 355 | "RESOURCE_KEANIUM_OXIDE", 356 | "RESOURCE_LEMERGIUM_HYDRIDE", 357 | "RESOURCE_LEMERGIUM_OXIDE", 358 | "RESOURCE_ZYNTHIUM_HYDRIDE", 359 | "RESOURCE_ZYNTHIUM_OXIDE", 360 | "RESOURCE_GHODIUM_HYDRIDE", 361 | "RESOURCE_GHODIUM_OXIDE", 362 | 363 | "RESOURCE_UTRIUM_ACID", 364 | "RESOURCE_UTRIUM_ALKALIDE", 365 | "RESOURCE_KEANIUM_ACID", 366 | "RESOURCE_KEANIUM_ALKALIDE", 367 | "RESOURCE_LEMERGIUM_ACID", 368 | "RESOURCE_LEMERGIUM_ALKALIDE", 369 | "RESOURCE_ZYNTHIUM_ACID", 370 | "RESOURCE_ZYNTHIUM_ALKALIDE", 371 | "RESOURCE_GHODIUM_ACID", 372 | "RESOURCE_GHODIUM_ALKALIDE", 373 | 374 | "RESOURCE_CATALYZED_UTRIUM_ACID", 375 | "RESOURCE_CATALYZED_UTRIUM_ALKALIDE", 376 | "RESOURCE_CATALYZED_KEANIUM_ACID", 377 | "RESOURCE_CATALYZED_KEANIUM_ALKALIDE", 378 | "RESOURCE_CATALYZED_LEMERGIUM_ACID", 379 | "RESOURCE_CATALYZED_LEMERGIUM_ALKALIDE", 380 | "RESOURCE_CATALYZED_ZYNTHIUM_ACID", 381 | "RESOURCE_CATALYZED_ZYNTHIUM_ALKALIDE", 382 | "RESOURCE_CATALYZED_GHODIUM_ACID", 383 | "RESOURCE_CATALYZED_GHODIUM_ALKALIDE", 384 | 385 | 'RESOURCE_OPS', 386 | 387 | 'RESOURCE_UTRIUM_BAR', 388 | 'RESOURCE_LEMERGIUM_BAR', 389 | 'RESOURCE_ZYNTHIUM_BAR', 390 | 'RESOURCE_KEANIUM_BAR', 391 | 'RESOURCE_GHODIUM_MELT', 392 | 'RESOURCE_OXIDANT', 393 | 'RESOURCE_REDUCTANT', 394 | 'RESOURCE_PURIFIER', 395 | 'RESOURCE_BATTERY', 396 | 397 | 'RESOURCE_COMPOSITE', 398 | 'RESOURCE_CRYSTAL', 399 | 'RESOURCE_LIQUID', 400 | 401 | 'RESOURCE_WIRE', 402 | 'RESOURCE_SWITCH', 403 | 'RESOURCE_TRANSISTOR', 404 | 'RESOURCE_MICROCHIP', 405 | 'RESOURCE_CIRCUIT', 406 | 'RESOURCE_DEVICE', 407 | 'RESOURCE_CELL', 408 | 'RESOURCE_PHLEGM', 409 | 'RESOURCE_TISSUE', 410 | 'RESOURCE_MUSCLE', 411 | 'RESOURCE_ORGANOID', 412 | 'RESOURCE_ORGANISM', 413 | 414 | 'RESOURCE_ALLOY', 415 | 'RESOURCE_TUBE', 416 | 'RESOURCE_FIXTURES', 417 | 'RESOURCE_FRAME', 418 | 'RESOURCE_HYDRAULICS', 419 | 'RESOURCE_MACHINE', 420 | 421 | 'RESOURCE_CONDENSATE', 422 | 'RESOURCE_CONCENTRATE', 423 | 'RESOURCE_EXTRACT', 424 | 'RESOURCE_SPIRIT', 425 | 'RESOURCE_EMANATION', 426 | 'RESOURCE_ESSENCE', 427 | 428 | "REACTIONS", 429 | 430 | "BOOSTS", 431 | 432 | 'REACTION_TIME', 433 | 434 | "PORTAL_UNSTABLE", 435 | "PORTAL_MIN_TIMEOUT", 436 | "PORTAL_MAX_TIMEOUT", 437 | "POWER_BANK_RESPAWN_TIME", 438 | 439 | "INVADERS_ENERGY_GOAL", 440 | 441 | "SYSTEM_USERNAME", 442 | 443 | "SIGN_NOVICE_AREA", 444 | "SIGN_RESPAWN_AREA", 445 | "SIGN_PLANNED_AREA", 446 | 447 | "EVENT_ATTACK", 448 | "EVENT_OBJECT_DESTROYED", 449 | "EVENT_ATTACK_CONTROLLER", 450 | "EVENT_BUILD", 451 | "EVENT_HARVEST", 452 | "EVENT_HEAL", 453 | "EVENT_REPAIR", 454 | "EVENT_RESERVE_CONTROLLER", 455 | "EVENT_UPGRADE_CONTROLLER", 456 | "EVENT_EXIT", 457 | 'EVENT_POWER', 458 | 'EVENT_TRANSFER', 459 | 460 | "EVENT_ATTACK_TYPE_MELEE", 461 | "EVENT_ATTACK_TYPE_RANGED", 462 | "EVENT_ATTACK_TYPE_RANGED_MASS", 463 | "EVENT_ATTACK_TYPE_DISMANTLE", 464 | "EVENT_ATTACK_TYPE_HIT_BACK", 465 | "EVENT_ATTACK_TYPE_NUKE", 466 | 467 | "EVENT_HEAL_TYPE_MELEE", 468 | "EVENT_HEAL_TYPE_RANGED", 469 | 470 | 'POWER_LEVEL_MULTIPLY', 471 | 'POWER_LEVEL_POW', 472 | "POWER_CREEP_SPAWN_COOLDOWN", 473 | "POWER_CREEP_DELETE_COOLDOWN", 474 | "POWER_CREEP_MAX_LEVEL", 475 | "POWER_CREEP_LIFE_TIME", 476 | 477 | "POWER_CLASS", 478 | 479 | "PWR_GENERATE_OPS", 480 | "PWR_OPERATE_SPAWN", 481 | "PWR_OPERATE_TOWER", 482 | "PWR_OPERATE_STORAGE", 483 | "PWR_OPERATE_LAB", 484 | "PWR_OPERATE_EXTENSION", 485 | "PWR_OPERATE_OBSERVER", 486 | "PWR_OPERATE_TERMINAL", 487 | "PWR_DISRUPT_SPAWN", 488 | "PWR_DISRUPT_TOWER", 489 | "PWR_DISRUPT_SOURCE", 490 | "PWR_SHIELD", 491 | "PWR_REGEN_SOURCE", 492 | "PWR_REGEN_MINERAL", 493 | "PWR_DISRUPT_TERMINAL", 494 | "PWR_OPERATE_POWER", 495 | "PWR_FORTIFY", 496 | "PWR_OPERATE_CONTROLLER", 497 | "PWR_OPERATE_FACTORY", 498 | 499 | 'EFFECT_INVULNERABILITY', 500 | "EFFECT_COLLAPSE_TIMER", 501 | 502 | "INVADER_CORE_HITS", 503 | "INVADER_CORE_CREEP_SPAWN_TIME", 504 | 'INVADER_CORE_EXPAND_TIME', 505 | 'INVADER_CORE_CONTROLLER_POWER', 506 | 'INVADER_CORE_CONTROLLER_DOWNGRADE', 507 | 'STRONGHOLD_RAMPART_HITS', 508 | "STRONGHOLD_DECAY_TICKS", 509 | 510 | "BODYPARTS_ALL", 511 | 512 | "RESOURCES_ALL", 513 | 514 | "COLORS_ALL", 515 | 516 | # classes 517 | 'Creep', 'Game', 'PathFinder', '_', 'Memory', 'RawMemory', '_Memory', '_MemoryValue', 'Flag', 'Mineral', 'Resource', 518 | 'RoomObject', 'Source', 'Infinity', 'JSON', 'Map', 'Set', 'Math', 'Object', 'RegExp', 'module', 'require', 'this', 519 | 'typeof', 'undefined', 'Room', 'RoomPosition', '_PathPos', 'String', 'Array', 'console', 520 | 'ConstructionSite', 'OwnedStructure', 'Structure', 'StructureContainer', 'StructureController', 521 | 'StructureExtension', 'StructureExtractor', 'StructureKeeperLair', 'StructureLab', 'StructureLink', 522 | 'StructureNuker', 'StructureObserver', 'StructurePortal', 'StructurePowerBank', 'StructurePowerSpawn', 523 | 'StructureRampart', 'StructureRoad', 'StructureSpawn', 'StructureStorage', 'StructureTerminal', 'StructureTower', 524 | 'StructureWall', 525 | 526 | # misc 527 | "__pragma__", 528 | 529 | # transcrypt 530 | "__new__", 531 | "js_isNaN", 532 | 'js_global', 533 | "__except0__", 534 | "Uint8Array", 535 | ] 536 | 537 | __pragma__('noskip') 538 | -------------------------------------------------------------------------------- /src/defs/classes/structures.py: -------------------------------------------------------------------------------- 1 | from typing import Any, Dict, List, Optional, Union 2 | import warnings 3 | 4 | from .creep import Creep 5 | # noinspection PyProtectedMember 6 | from .memory import _Memory 7 | from .misc_obj import RoomObject, Store, _Effect 8 | # noinspection PyProtectedMember 9 | from .room import Room, RoomPosition, _Owner 10 | 11 | 12 | # noinspection PyPep8Naming 13 | class Structure(RoomObject): 14 | """ 15 | 16 | :type id: str 17 | :type structureType: str 18 | :type hits: int 19 | :type hitsMax: int 20 | """ 21 | 22 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Room, structureType: str, _id: str, 23 | hits: int, hitsMax: int) -> None: 24 | """ 25 | WARNING: This constructor is purely for type completion, and does not exist in the game. 26 | """ 27 | super().__init__(effects, pos, room) 28 | self.structureType = structureType 29 | self.id = _id 30 | self.hits = hits 31 | self.hitsMax = hitsMax 32 | 33 | def destroy(self) -> int: 34 | pass 35 | 36 | def isActive(self) -> bool: 37 | pass 38 | 39 | def notifyWhenAttacked(self, enabled: bool) -> int: 40 | pass 41 | 42 | 43 | # noinspection PyPep8Naming 44 | class OwnedStructure(Structure): 45 | """ 46 | :type my: bool 47 | :type owner: _Owner 48 | """ 49 | 50 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Room, structureType: str, _id: str, 51 | hits: int, hitsMax: int, my: bool, owner: _Owner) -> None: 52 | """ 53 | WARNING: This constructor is purely for type completion, and does not exist in the game. 54 | """ 55 | super().__init__(effects, pos, room, structureType, _id, hits, hitsMax) 56 | self.my = my 57 | self.owner = owner 58 | 59 | 60 | # noinspection PyPep8Naming 61 | class ConstructionSite(RoomObject): 62 | """ 63 | :type effects: _Effect 64 | :type id: str 65 | :type my: bool 66 | :type owner: _Owner 67 | :type progress: int 68 | :type progressTotal: int 69 | :type structureType: str 70 | """ 71 | 72 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Room, _id: str, my: bool, 73 | owner: _Owner, progress: int, progressTotal: int, structureType: str) -> None: 74 | """ 75 | WARNING: This constructor is purely for type completion, and does not exist in the game. 76 | """ 77 | super().__init__(effects, pos, room) 78 | self.id = _id 79 | self.my = my 80 | self.owner = owner 81 | self.progress = progress 82 | self.progressTotal = progressTotal 83 | self.structureType = structureType 84 | 85 | def remove(self) -> int: 86 | pass 87 | 88 | 89 | # noinspection PyPep8Naming 90 | class StructureContainer(Structure): 91 | """ 92 | :type effects: _Effect 93 | :type store: Store 94 | :type ticksToDecay: int 95 | """ 96 | 97 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Room, structureType: str, 98 | _id: str, hits: int, hitsMax: int, store: Store, ticksToDecay: int) -> None: 99 | """ 100 | WARNING: This constructor is purely for type completion, and does not exist in the game. 101 | """ 102 | super().__init__(effects, pos, room, structureType, _id, hits, hitsMax) 103 | self.store = store 104 | self.ticksToDecay = ticksToDecay 105 | 106 | 107 | # noinspection PyPep8Naming 108 | class _RoomReservation: 109 | """ 110 | :type username: str 111 | :type ticksToEnd: int 112 | """ 113 | 114 | def __init__(self, username: str, ticksToEnd: int) -> None: 115 | """ 116 | WARNING: This constructor is purely for type completion, and does not exist in the game. 117 | """ 118 | self.username = username 119 | self.ticksToEnd = ticksToEnd 120 | 121 | 122 | class _ControllerSign: 123 | """ 124 | :type username: str 125 | :type text: str 126 | :type time: int 127 | :type datetime: Any 128 | """ 129 | 130 | def __init__(self, username: str, text: str, time: int, datetime: Any) -> None: 131 | """ 132 | WARNING: This constructor is purely for type completion, and does not exist in the game. 133 | """ 134 | self.time = time 135 | self.text = text 136 | self.username = username 137 | self.datetime = datetime 138 | 139 | 140 | # noinspection PyPep8Naming 141 | class StructureController(OwnedStructure): 142 | """ 143 | :type effects: _Effect 144 | :type level: int 145 | :type progress: int 146 | :type progressTotal: int 147 | :type reservation: _RoomReservation | None 148 | :type safeMode: int 149 | :type safeModeAvailable: int 150 | :type safeModeCooldown: int 151 | :type sign: _ControllerSign | None 152 | :type ticksToDowngrade: int 153 | :type upgradeBlocked: int 154 | """ 155 | 156 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Room, structureType: str, 157 | _id: str, hits: int, hitsMax: int, my: bool, owner: _Owner, isPowerEnabled: bool, 158 | level: int, progress: int, progressTotal: int, reservation: Optional[_RoomReservation], 159 | safeMode: int, safeModeAvailable: int, safeModeCooldown: int, sign: Optional[_ControllerSign], 160 | ticksToDowngrade: int, upgradeBlocked: int) -> None: 161 | """ 162 | WARNING: This constructor is purely for type completion, and does not exist in the game. 163 | """ 164 | super().__init__(effects, pos, room, structureType, _id, hits, hitsMax, my, owner) 165 | self.isPowerEnabled = isPowerEnabled 166 | self.level = level 167 | self.progress = progress 168 | self.progressTotal = progressTotal 169 | self.reservation = reservation 170 | self.safeMode = safeMode 171 | self.safeModeAvailable = safeModeAvailable 172 | self.safeModeCooldown = safeModeCooldown 173 | self.sign = sign 174 | self.ticksToDowngrade = ticksToDowngrade 175 | self.upgradeBlocked = upgradeBlocked 176 | 177 | def activateSafeMode(self) -> int: 178 | pass 179 | 180 | def unclaim(self) -> int: 181 | pass 182 | 183 | 184 | # noinspection PyPep8Naming 185 | class StructureExtension(OwnedStructure): 186 | """ 187 | :type effects: _Effect 188 | :type store: Store() 189 | """ 190 | 191 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Room, structureType: str, 192 | _id: str, hits: int, hitsMax: int, 193 | my: bool, owner: _Owner, store: Store) -> None: 194 | """ 195 | WARNING: This constructor is purely for type completion, and does not exist in the game. 196 | """ 197 | super().__init__(effects, pos, room, structureType, _id, hits, hitsMax, my, owner) 198 | self.store = store 199 | 200 | 201 | # noinspection PyPep8Naming 202 | class StructureExtractor(OwnedStructure): 203 | """ 204 | :type effects: _Effect 205 | :type cooldown: int 206 | """ 207 | 208 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Room, 209 | structureType: str, _id: str, hits: int, hitsMax: int, 210 | my: bool, owner: _Owner, cooldown: int) -> None: 211 | """ 212 | WARNING: This constructor is purely for type completion, and does not exist in the game. 213 | """ 214 | super().__init__(effects, pos, room, structureType, _id, hits, hitsMax, my, owner) 215 | self.cooldown = cooldown 216 | 217 | 218 | # noinspection PyPep8Naming 219 | class StructureFactory(OwnedStructure): 220 | """ 221 | :type effects: _Effect 222 | :type cooldown: int 223 | :type level: int 224 | :type store: Store 225 | """ 226 | 227 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Room, 228 | structureType: str, _id: str, hits: int, hitsMax: int, 229 | my: bool, owner: _Owner, level: int, cooldown: int, 230 | store: Store) -> None: 231 | """ 232 | WARNING: This constructor is purely for type completion, and does not exist in the game. 233 | """ 234 | super().__init__(effects, pos, room, structureType, _id, hits, hitsMax, my, owner) 235 | self.cooldown = cooldown 236 | self.level = level 237 | self.store = store 238 | 239 | def produce(self, resourceType: str) -> int: 240 | pass 241 | 242 | 243 | # noinspection PyPep8Naming 244 | class StructureInvaderCore(OwnedStructure): 245 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Room, 246 | structureType: str, _id: str, hits: int, hitsMax: int, 247 | my: bool, owner: _Owner, level: int, ticksToDeploy: int) -> None: 248 | super().__init__(effects, pos, room, structureType, _id, hits, hitsMax, my, owner) 249 | self.level = level 250 | self.ticksToDeploy = ticksToDeploy 251 | 252 | """ 253 | :type effects: _Effects 254 | :type level: int 255 | :type ticksToDeploy: int 256 | """ 257 | 258 | 259 | # noinspection PyPep8Naming 260 | class StructureKeeperLair(OwnedStructure): 261 | """ 262 | :type effects: _Effect 263 | :type ticksToSpawn: int 264 | """ 265 | 266 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Room, 267 | structureType: str, _id: str, hits: int, hitsMax: int, 268 | my: bool, owner: _Owner, ticksToSpawn: int) -> None: 269 | """ 270 | WARNING: This constructor is purely for type completion, and does not exist in the game. 271 | """ 272 | super().__init__(effects, pos, room, structureType, _id, hits, hitsMax, my, owner) 273 | self.ticksToSpawn = ticksToSpawn 274 | 275 | 276 | # noinspection PyPep8Naming 277 | class StructureLab(OwnedStructure): 278 | """ 279 | :type effects: _Effect 280 | :type cooldown: int 281 | :type mineralType: Optional[str] 282 | :type store: Store 283 | """ 284 | 285 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Room, 286 | structureType: str, _id: str, hits: int, hitsMax: int, 287 | my: bool, owner: _Owner, cooldown: int, 288 | mineralType: Optional[str], store: Store) -> None: 289 | """ 290 | WARNING: This constructor is purely for type completion, and does not exist in the game. 291 | """ 292 | super().__init__(effects, pos, room, structureType, _id, hits, hitsMax, my, owner) 293 | self.cooldown = cooldown 294 | self.mineralType = mineralType 295 | self.store = store 296 | 297 | def boostCreep(self, creep: Creep, bodyPartsCount: Optional[int] = None) -> int: 298 | pass 299 | 300 | def reverseReaction(self, lab1: 'StructureLab', lab2: 'StructureLab') -> int: 301 | pass 302 | 303 | def runReaction(self, lab1: 'StructureLab', lab2: 'StructureLab') -> int: 304 | pass 305 | 306 | def unboostCreep(self, creep: Creep) -> int: 307 | pass 308 | 309 | 310 | # noinspection PyPep8Naming 311 | class StructureLink(OwnedStructure): 312 | """ 313 | :type effects: _Effect 314 | :type cooldown: int 315 | :type store: Store 316 | """ 317 | 318 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Room, 319 | structureType: str, _id: str, hits: int, hitsMax: int, 320 | my: bool, owner: _Owner, cooldown: int, store: Store) -> None: 321 | """ 322 | WARNING: This constructor is purely for type completion, and does not exist in the game. 323 | """ 324 | super().__init__(effects, pos, room, structureType, _id, hits, hitsMax, my, owner) 325 | self.cooldown = cooldown 326 | self.store = store 327 | 328 | def transferEnergy(self, target: 'StructureLink', amount: int = 0) -> int: 329 | pass 330 | 331 | 332 | # noinspection PyPep8Naming 333 | class StructureNuker(OwnedStructure): 334 | """ 335 | :type effects: _Effect 336 | :type store: Store 337 | """ 338 | 339 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Room, 340 | structureType: str, _id: str, hits: int, hitsMax: int, 341 | my: bool, owner: _Owner, energy: int, cooldown: int, store: Store) -> None: 342 | """ 343 | WARNING: This constructor is purely for type completion, and does not exist in the game. 344 | """ 345 | super().__init__(effects, pos, room, structureType, _id, hits, hitsMax, my, owner) 346 | self.energy = energy 347 | self.cooldown = cooldown 348 | self.store = store 349 | 350 | def launchNuke(self, pos: RoomPosition) -> int: 351 | pass 352 | 353 | 354 | # noinspection PyPep8Naming 355 | class StructureObserver(OwnedStructure): 356 | """ 357 | :type effects: _Effect 358 | """ 359 | 360 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Room, 361 | structureType: str, _id: str, hits: int, hitsMax: int, 362 | my: bool, owner: _Owner) -> None: 363 | super().__init__(effects, pos, room, structureType, _id, hits, hitsMax, my, owner) 364 | 365 | def observeRoom(self, roomName: str) -> int: 366 | pass 367 | 368 | 369 | # noinspection PyPep8Naming 370 | class StructurePowerBank(Structure): 371 | """ 372 | :type effects: _Effect 373 | :type power: int 374 | :type ticksToDecay: int 375 | """ 376 | 377 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Room, 378 | structureType: str, _id: str, hits: int, hitsMax: int, 379 | power: int, ticksToDecay: int) -> None: 380 | """ 381 | WARNING: This constructor is purely for type completion, and does not exist in the game. 382 | """ 383 | super().__init__(effects, pos, room, structureType, _id, hits, hitsMax) 384 | self.power = power 385 | self.ticksToDecay = ticksToDecay 386 | 387 | 388 | # noinspection PyPep8Naming 389 | class StructurePowerSpawn(OwnedStructure): 390 | """ 391 | :type effects: _Effect 392 | :type energy: int 393 | :type energyCapacity: int 394 | :type power: int 395 | :type powerCapacity: int 396 | :type cooldown: int 397 | :type store: Store 398 | """ 399 | 400 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Room, 401 | structureType: str, _id: str, hits: int, hitsMax: int, 402 | my: bool, owner: _Owner, store: Store) -> None: 403 | """ 404 | WARNING: This constructor is purely for type completion, and does not exist in the game. 405 | """ 406 | super().__init__(effects, pos, room, structureType, _id, hits, hitsMax, my, owner) 407 | self.store = store 408 | 409 | # erased from docs? 410 | # def createPowerCreep(self, name: str) -> int: 411 | # pass 412 | 413 | def processPower(self) -> int: 414 | pass 415 | 416 | 417 | class _ShardPortalDestination: 418 | """ 419 | :type shard: str 420 | :type room: str 421 | """ 422 | 423 | def __init__(self, shard: str, room: str) -> None: 424 | """ 425 | WARNING: This constructor is purely for type completion, and does not exist in the game. 426 | """ 427 | self.shard = shard 428 | self.room = room 429 | 430 | 431 | # noinspection PyPep8Naming 432 | class StructurePortal(Structure): 433 | """ 434 | :type effects: _Effect 435 | :type destination: Union[RoomPosition, _ShardPortalDestination] 436 | :type ticksToDecay: Optional[int] 437 | """ 438 | 439 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Room, 440 | structureType: str, _id: str, hits: int, hitsMax: int, 441 | destination: Union[RoomPosition, _ShardPortalDestination], ticksToDecay: Optional[int]) -> None: 442 | """ 443 | WARNING: This constructor is purely for type completion, and does not exist in the game. 444 | """ 445 | super().__init__(effects, pos, room, structureType, _id, hits, hitsMax) 446 | 447 | self.destination = destination 448 | self.ticksToDecay = ticksToDecay 449 | 450 | 451 | # noinspection PyPep8Naming 452 | class StructureRampart(OwnedStructure): 453 | """ 454 | :type effects: _Effect 455 | :type isPublic: bool 456 | :type ticksToDecay: int 457 | """ 458 | 459 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Room, 460 | structureType: str, _id: str, hits: int, hitsMax: int, 461 | my: bool, owner: _Owner, isPublic: bool, ticksToDecay: int) -> None: 462 | """ 463 | WARNING: This constructor is purely for type completion, and does not exist in the game. 464 | """ 465 | super().__init__(effects, pos, room, structureType, _id, hits, hitsMax, my, owner) 466 | self.isPublic = isPublic 467 | self.ticksToDecay = ticksToDecay 468 | 469 | def setPublic(self, isPublic: bool) -> int: 470 | pass 471 | 472 | 473 | # noinspection PyPep8Naming 474 | class StructureRoad(Structure): 475 | """ 476 | :type effects: _Effect 477 | :type ticksToDecay: int 478 | """ 479 | 480 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Room, 481 | structureType: str, _id: str, hits: int, hitsMax: int, 482 | ticksToDecay: int) -> None: 483 | """ 484 | WARNING: This constructor is purely for type completion, and does not exist in the game. 485 | """ 486 | super().__init__(effects, pos, room, structureType, _id, hits, hitsMax) 487 | 488 | self.ticksToDecay = ticksToDecay 489 | 490 | 491 | # noinspection PyPep8Naming 492 | class _SpawnSpawningCreep: 493 | """ 494 | :type directions: List[int] 495 | :type name: str 496 | :type needTime: int 497 | :type remainingTime: int 498 | :type spawn: StructureSpawn 499 | """ 500 | 501 | def __init__(self, directions: List[int], name: str, needTime: int, remainingTime: int, spawn: str): 502 | self.directions = directions 503 | self.name = name 504 | self.needTime = needTime 505 | self.remainingTime = remainingTime 506 | self.spawn = spawn 507 | 508 | def cancel(self) -> int: 509 | pass 510 | 511 | def setDirections(self, directions: List[int]) -> int: 512 | pass 513 | 514 | 515 | # noinspection PyPep8Naming 516 | class StructureSpawn(OwnedStructure): 517 | """ 518 | :type effects: _Effect 519 | :type memory: _Memory 520 | :type name: str 521 | :type spawning: Optional[_SpawnSpawningCreep] 522 | :type store: Store 523 | """ 524 | 525 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Room, 526 | structureType: str, _id: str, hits: int, hitsMax: int, 527 | my: bool, owner: _Owner, # energy: int, energyCapacity: int, 528 | memory: _Memory, name: str, 529 | spawning: Optional[_SpawnSpawningCreep], 530 | store: Store) -> None: 531 | """ 532 | WARNING: This constructor is purely for type completion, and does not exist in the game. 533 | """ 534 | super().__init__(effects, pos, room, structureType, _id, hits, hitsMax, my, owner) 535 | self.memory = memory 536 | self.name = name 537 | self.spawning = spawning 538 | self.store = store 539 | 540 | @warnings.warn('This method is deprecated and will be removed soon.' 541 | ' Please use StructureSpawn.spawnCreep with dryRun flag instead.', DeprecationWarning) 542 | def canCreateCreep(self, body: List[str], name: Optional[str] = None) -> int: 543 | pass 544 | 545 | @warnings.warn('This method is deprecated and will be removed soon.' 546 | ' Please use StructureSpawn.spawnCreep instead.', DeprecationWarning) 547 | def createCreep(self, body: List[str], name: Optional[str] = None, memory: Optional[Dict[str, Any]] = None) \ 548 | -> Union[int, str]: 549 | pass 550 | 551 | def spawnCreep(self, body: List[str], name: str, opts: Optional[Dict[str, Any]] = None) -> int: 552 | pass 553 | 554 | def recycleCreep(self, target: Creep) -> int: 555 | pass 556 | 557 | def renewCreep(self, target: Creep) -> int: 558 | pass 559 | 560 | 561 | # noinspection PyPep8Naming 562 | class StructureStorage(OwnedStructure): 563 | """ 564 | :type effects: _Effect 565 | :type store: Store 566 | """ 567 | 568 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Room, 569 | structureType: str, _id: str, hits: int, hitsMax: int, 570 | my: bool, owner: _Owner, store: Store) -> None: 571 | """ 572 | WARNING: This constructor is purely for type completion, and does not exist in the game. 573 | """ 574 | super().__init__(effects, pos, room, structureType, _id, hits, hitsMax, my, owner) 575 | self.store = store 576 | 577 | 578 | # noinspection PyPep8Naming 579 | class StructureTerminal(OwnedStructure): 580 | """ 581 | :type effects: _Effect 582 | :type cooldown: int 583 | :type store: dict[str, int] 584 | """ 585 | 586 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Room, 587 | structureType: str, _id: str, hits: int, hitsMax: int, 588 | my: bool, owner: _Owner, cooldown: int, store: Store) -> None: 589 | """ 590 | WARNING: This constructor is purely for type completion, and does not exist in the game. 591 | """ 592 | super().__init__(effects, pos, room, structureType, _id, hits, hitsMax, my, owner) 593 | self.cooldown = cooldown 594 | self.store = store 595 | 596 | def send(self, resourceType: str, amount: Union[int, float], destination: str, description: str = None) -> int: 597 | pass 598 | 599 | 600 | # noinspection PyPep8Naming 601 | class StructureTower(OwnedStructure): 602 | """ 603 | :type effects: _Effect 604 | :type store: Store 605 | """ 606 | 607 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Room, 608 | structureType: str, _id: str, hits: int, hitsMax: int, 609 | my: bool, owner: _Owner, store: Store) -> None: 610 | """ 611 | WARNING: This constructor is purely for type completion, and does not exist in the game. 612 | """ 613 | super().__init__(effects, pos, room, structureType, _id, hits, hitsMax, my, owner) 614 | self.store = store 615 | 616 | def attack(self, target: Creep) -> int: 617 | pass 618 | 619 | def heal(self, target: Creep) -> int: 620 | pass 621 | 622 | def repair(self, target: Structure) -> int: 623 | pass 624 | 625 | 626 | # noinspection PyPep8Naming 627 | class StructureWall(Structure): 628 | """ 629 | :type effects: _Effect 630 | """ 631 | 632 | def __init__(self, effects: _Effect, pos: RoomPosition, room: Room, 633 | structureType: str, _id: str, hits: int, hitsMax: int) -> None: 634 | """ 635 | WARNING: This constructor is purely for type completion, and does not exist in the game. 636 | """ 637 | super().__init__(effects, pos, room, structureType, _id, hits, hitsMax) 638 | -------------------------------------------------------------------------------- /src/defs/classes/lodash.py: -------------------------------------------------------------------------------- 1 | from typing import Any, Callable, Dict, Generic, List, Optional, Tuple, Type, TypeVar, Union 2 | 3 | _L1 = TypeVar('_L1') 4 | _L2 = TypeVar('_L2') 5 | _L3 = TypeVar('_L3', int, float) 6 | _L4 = TypeVar('_L4') 7 | 8 | 9 | # noinspection PyPep8Naming 10 | class _LodashChain(Generic[_L1]): 11 | def __init__(self, value: Union[List[_L1], Dict[Any, _L1]]) -> None: 12 | self.__inner = value 13 | 14 | def concat(self, other: Union[List[_L1], Dict[Any, _L1]]) -> '_LodashChain[_L1]': 15 | pass 16 | 17 | def chunk(self, size: int = 1) -> '_LodashChain[List[_L1]]': 18 | pass 19 | 20 | def compact(self) -> '_LodashChain[_L1]': 21 | pass 22 | 23 | def difference(self, *other: List[_L1]) -> '_LodashChain[_L1]': 24 | pass 25 | 26 | def drop(self, n: int = 1) -> '_LodashChain[_L1]': 27 | pass 28 | 29 | def dropRight(self, n: int = 1) -> '_LodashChain[_L1]': 30 | pass 31 | 32 | def dropRightWhile(self, 33 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 34 | thisArg: Any = None) -> '_LodashChain[_L1]': 35 | pass 36 | 37 | def dropWhile(self, 38 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 39 | thisArg: Any = None) -> '_LodashChain[_L1]': 40 | pass 41 | 42 | def fill(self, value: _L1, start: int = 0, end: int = 0) -> '_LodashChain[_L1]': 43 | pass 44 | 45 | def first(self) -> Optional[_L1]: 46 | pass 47 | 48 | def flatten(self) -> '_LodashChain': 49 | pass 50 | 51 | def flattenDeep(self) -> '_LodashChain': 52 | pass 53 | 54 | def initial(self) -> List[_L1]: 55 | pass 56 | 57 | def intersection(self, arrays: List[List[_L1]]) -> '_LodashChain': 58 | pass 59 | 60 | def last(self) -> Optional[Any]: 61 | pass 62 | 63 | def lastIndexOf(self, value: _L1, fromIndex: Union[int, bool] = 0) -> int: 64 | pass 65 | 66 | def pull(self, values: List[_L1]) -> '_LodashChain': 67 | pass 68 | 69 | def pullAt(self, indices: List[int]) -> '_LodashChain': 70 | pass 71 | 72 | def remove(self, predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 73 | thisArg: Any = None) -> '_LodashChain': 74 | pass 75 | 76 | def rest(self) -> '_LodashChain': 77 | pass 78 | 79 | def slice(self, start: int = 0, end: int = 0) -> '_LodashChain': 80 | pass 81 | 82 | def sortedIndex(self, 83 | value: _L1, 84 | iteratee: Union[str, Callable[[_L1], _L2], None] = None, 85 | thisArg: Any = None) -> int: 86 | pass 87 | 88 | def sortedLastIndex(self, 89 | value: _L1, 90 | iteratee: Union[str, Callable[[_L1], _L2], None] = None, 91 | thisArg: Any = None) -> int: 92 | pass 93 | 94 | def take(self, n: int = 1) -> '_LodashChain': 95 | pass 96 | 97 | def takeRight(self, n: int = 1) -> '_LodashChain': 98 | pass 99 | 100 | def takeRightWhile(self, 101 | predicate: Union[str, Callable[[_L1], _L2], None] = None, 102 | thisArg: Any = None) -> '_LodashChain': 103 | pass 104 | 105 | def takeWhile(self, 106 | predicate: Union[str, Callable[[_L1], _L2], None] = None, 107 | thisArg: Any = None) -> '_LodashChain': 108 | pass 109 | 110 | def union(self, arrays: List[List[_L1]]) -> '_LodashChain': 111 | pass 112 | 113 | def unique(self, 114 | isSorted: bool = False, 115 | iteratee: Union[str, Callable[[_L1], _L2], None] = None, 116 | thisArg: Any = None) -> List[_L1]: 117 | pass 118 | 119 | def uniq(self, 120 | isSorted: bool = False, 121 | iteratee: Union[str, Callable[[_L1], _L2], None] = None, 122 | thisArg: Any = None) -> List[_L1]: 123 | pass 124 | 125 | def unzip(self) -> '_LodashChain': 126 | pass 127 | 128 | def unzipWith(self, 129 | iteratee: Optional[Callable[[Any, Any, Any, Any], Any]] = None, 130 | thisArg: Any = None) -> '_LodashChain': 131 | pass 132 | 133 | def without(self, values: List[_L1]) -> '_LodashChain': 134 | pass 135 | 136 | def xor(self, arrays: List[List[_L1]]) -> '_LodashChain': 137 | pass 138 | 139 | def zip(self) -> '_LodashChain': 140 | pass 141 | 142 | def zipObject(self, values: Optional[List[Any]] = None) -> '_LodashChain': 143 | pass 144 | 145 | def zipWith(self, 146 | iteratee: Optional[Callable[[Any, Any, Any, Any], None]] = None, 147 | thisArg: Any = None) -> '_LodashChain': 148 | pass 149 | 150 | def all(self, predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 151 | thisArg: Any = None) -> bool: 152 | pass 153 | 154 | def any(self, predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 155 | thisArg: Any = None) -> bool: 156 | pass 157 | 158 | def at(self, *props: Any) -> List[_L1]: 159 | pass 160 | 161 | def countBy(self, iteratee: Union[str, Callable[[_L1], _L2], None] = None, thisArg: Any = None) -> '_LodashChain': 162 | pass 163 | 164 | def every(self, 165 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 166 | thisArg: Any = None) -> bool: 167 | pass 168 | 169 | def filter(self, 170 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 171 | thisArg: Any = None) -> '_LodashChain[_L1]': 172 | pass 173 | 174 | def find(self, 175 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 176 | thisArg: Any = None) -> _L1: 177 | pass 178 | 179 | def findLast(self, 180 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 181 | thisArg: Any = None) -> _L1: 182 | pass 183 | 184 | def findWhere(self, 185 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 186 | thisArg: Any = None) -> _L1: 187 | pass 188 | 189 | def forEach(self, iteratee: Callable[[_L1], Optional[bool]] = None, thisArg: Any = None) -> '_LodashChain[_L1]': 190 | pass 191 | 192 | def forEachRight(self, 193 | iteratee: Callable[[_L1], Optional[bool]] = None, 194 | thisArg: Any = None) -> '_LodashChain[_L1]': 195 | pass 196 | 197 | def groupBy(self, iteratee: Union[str, Callable[[_L1], _L2], None] = None, thisArg: Any = None) -> '_LodashChain': 198 | pass 199 | 200 | def includes(self, value: _L1, fromIndex: int = 0) -> bool: 201 | pass 202 | 203 | def indexBy(self, iteratee: Union[str, Callable[[_L1], _L2], None] = None, thisArg: Any = None) -> Dict[str, _L1]: 204 | pass 205 | 206 | def invoke(self, path: str, *args: Any) -> '_LodashChain': 207 | pass 208 | 209 | def map(self, iteratee: Union[str, Callable[[_L1], _L2], None] = None, thisArg: Any = None) -> '_LodashChain': 210 | pass 211 | 212 | def partition(self, 213 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 214 | thisArg: Any = None) -> '_LodashChain': 215 | pass 216 | 217 | def pluck(self, path: Union[str, List[str]]) -> '_LodashChain': 218 | pass 219 | 220 | def reduce(self, 221 | iteratee: Callable[[_L2, _L1], _L2] = None, accumulator: _L2 = None, 222 | thisArg: Any = None) -> _L2: 223 | pass 224 | 225 | def reduceRight(self, 226 | iteratee: Callable[[_L2, _L1], _L2] = None, accumulator: _L2 = None, 227 | thisArg: Any = None) -> _L2: 228 | pass 229 | 230 | def reject(self, 231 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 232 | thisArg: Any = None) -> '_LodashChain': 233 | pass 234 | 235 | def sample(self) -> Any: 236 | pass 237 | 238 | def shuffle(self) -> '_LodashChain': 239 | pass 240 | 241 | def size(self) -> int: 242 | pass 243 | 244 | def some(self, 245 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 246 | thisArg: Any = None) -> bool: 247 | pass 248 | 249 | def sortBy(self, iteratee: Union[str, Callable[[_L1], _L2], None] = None, thisArg: Any = None) -> '_LodashChain': 250 | pass 251 | 252 | def sortByAll(self, *iteratee: Union[str, Callable[[_L1], _L2], None]) -> '_LodashChain': 253 | pass 254 | 255 | def sortByOrder(self, iteratees: List[Union[str, Callable[[_L1], _L2], None]], orders: List[str]) -> '_LodashChain': 256 | pass 257 | 258 | def where(self, source: Any) -> '_LodashChain': 259 | pass 260 | 261 | def toArray(self) -> '_LodashChain': 262 | pass 263 | 264 | def toPlainObject(self) -> '_LodashChain': 265 | pass 266 | 267 | def sum(self, iteratee: Union[str, Callable[[_L1], _L2], None] = None, thisArg: Any = None) -> _L2: 268 | pass 269 | 270 | def keys(self) -> '_LodashChain': 271 | pass 272 | 273 | def mapKeys(self, iteratee: Callable[[str], str] = None, thisArg: Any = None) -> '_LodashChain': 274 | pass 275 | 276 | def mapValues(self, iteratee: Callable[[Any], Any] = None, thisArg: Any = None) -> '_LodashChain': 277 | pass 278 | 279 | def omit(self, 280 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str], 281 | thisArg: Any = None) -> '_LodashChain': 282 | pass 283 | 284 | def pairs(self) -> '_LodashChain': 285 | pass 286 | 287 | def values(self) -> '_LodashChain': 288 | pass 289 | 290 | def value(self) -> Any: 291 | pass 292 | 293 | def max(self, iteratee: Callable[[_L1], _L3] = None, thisArg: Any = None) -> _L1: 294 | pass 295 | 296 | def min(self, iteratee: Callable[[_L1], _L3] = None, thisArg: Any = None) -> _L1: 297 | pass 298 | 299 | 300 | # noinspection PyPep8Naming 301 | class _: 302 | def __new__(cls, value: Union[List[_L1], Dict[Any, _L1]]) -> _LodashChain[_L1]: 303 | return _LodashChain(value) 304 | 305 | @staticmethod 306 | def chunk(array: List[_L1], size: int = 1) -> List[List[_L1]]: 307 | pass 308 | 309 | @staticmethod 310 | def compact(array: List[_L1]) -> List[_L1]: 311 | pass 312 | 313 | @staticmethod 314 | def difference(array: List[_L1], *other: List[_L1]) -> List[_L1]: 315 | pass 316 | 317 | @staticmethod 318 | def drop(array: List[_L1], n: int = 1) -> List[_L1]: 319 | pass 320 | 321 | @staticmethod 322 | def dropRight(array: List[_L1], n: int = 1) -> List[_L1]: 323 | pass 324 | 325 | @staticmethod 326 | def dropRightWhile(array: List[_L1], 327 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 328 | thisArg: Any = None) -> List[_L1]: 329 | pass 330 | 331 | @staticmethod 332 | def dropWhile(array: List[_L1], 333 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 334 | thisArg: Any = None) -> List[_L1]: 335 | pass 336 | 337 | @staticmethod 338 | def fill(array: List[_L1], value: _L1, start: int = 0, end: int = 0) -> List[_L1]: 339 | pass 340 | 341 | @staticmethod 342 | def findIndex(array: List[_L1], 343 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 344 | thisArg: Any = None) -> int: 345 | pass 346 | 347 | @staticmethod 348 | def findLastIndex(array: List[_L1], 349 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 350 | thisArg: Any = None) -> int: 351 | pass 352 | 353 | @staticmethod 354 | def first(array: List[_L1]) -> Optional[_L1]: 355 | pass 356 | 357 | @staticmethod 358 | def flatten(array: List[List[_L1]]) -> List[_L1]: 359 | pass 360 | 361 | @staticmethod 362 | def flattenDeep(array: List[Any]) -> List[Any]: 363 | pass 364 | 365 | @staticmethod 366 | def indexOf(array: List[_L1], value: _L1, fromIndex: Union[int, bool] = 0) -> int: 367 | pass 368 | 369 | @staticmethod 370 | def initial(array: List[_L1]) -> List[_L1]: 371 | pass 372 | 373 | @staticmethod 374 | def intersection(array: List[List[_L1]]) -> List[_L1]: 375 | pass 376 | 377 | @staticmethod 378 | def last(array: List[_L1]) -> Optional[_L1]: 379 | pass 380 | 381 | @staticmethod 382 | def lastIndexOf(array: List[_L1], value: _L1, fromIndex: Union[int, bool] = 0) -> int: 383 | pass 384 | 385 | @staticmethod 386 | def pull(array: List[_L1], *values: _L1) -> List[_L1]: 387 | pass 388 | 389 | @staticmethod 390 | def pullAt(array: List[_L1], indices: List[int]) -> List[_L1]: 391 | pass 392 | 393 | @staticmethod 394 | def remove(array: List[_L1], 395 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 396 | thisArg: Any = None) -> List[_L1]: 397 | pass 398 | 399 | @staticmethod 400 | def rest(array: List[_L1]) -> List[_L1]: 401 | pass 402 | 403 | @staticmethod 404 | def slice(array: List[_L1], start: int = 0, end: int = 0) -> List[_L1]: 405 | pass 406 | 407 | @staticmethod 408 | def sortedIndex(array: List[_L1], 409 | value: _L1, 410 | iteratee: Union[str, Callable[[_L1], _L2], None] = None, 411 | thisArg: Any = None) -> int: 412 | pass 413 | 414 | @staticmethod 415 | def sortedLastIndex(array: List[_L1], 416 | value: _L1, 417 | iteratee: Union[str, Callable[[_L1], _L2], None] = None, 418 | thisArg: Any = None) -> int: 419 | pass 420 | 421 | @staticmethod 422 | def take(array: List[_L1], n: int = 1) -> List[_L1]: 423 | pass 424 | 425 | @staticmethod 426 | def takeRight(array: List[_L1], n: int = 1) -> List[_L1]: 427 | pass 428 | 429 | @staticmethod 430 | def takeRightWhile(array: List[_L1], 431 | predicate: Union[str, Callable[[_L1], _L2], None] = None, 432 | thisArg: Any = None) -> List[_L1]: 433 | pass 434 | 435 | @staticmethod 436 | def takeWhile(array: List[_L1], 437 | predicate: Union[str, Callable[[_L1], _L2], None] = None, 438 | thisArg: Any = None) -> List[_L1]: 439 | pass 440 | 441 | @staticmethod 442 | def union(array: List[List[_L1]]) -> List[_L1]: 443 | pass 444 | 445 | @staticmethod 446 | def unique(array: List[_L1], 447 | isSorted: bool = False, 448 | iteratee: Union[str, Callable[[_L1], _L2], None] = None, 449 | thisArg: Any = None) -> List[_L1]: 450 | pass 451 | 452 | @staticmethod 453 | def uniq(array: List[_L1], 454 | isSorted: bool = False, 455 | iteratee: Union[str, Callable[[_L1], _L2], None] = None, 456 | thisArg: Any = None) -> List[_L1]: 457 | pass 458 | 459 | @staticmethod 460 | def unzip(array: List[Any]) -> List[Any]: 461 | pass 462 | 463 | @staticmethod 464 | def unzipWith(array: List[Any], 465 | iteratee: Optional[Callable[[Any, Any, Any, Any], Any]] = None, 466 | thisArg: Any = None) -> List[Any]: 467 | pass 468 | 469 | @staticmethod 470 | def without(array: List[_L1], values: List[_L1]) -> List[_L1]: 471 | pass 472 | 473 | @staticmethod 474 | def xor(array: List[List[_L1]]) -> List[_L1]: 475 | pass 476 | 477 | @staticmethod 478 | def zip(array: List[Any]) -> List[Any]: 479 | pass 480 | 481 | @staticmethod 482 | def zipObject(props: List[Any], values: Optional[List[Any]] = None) -> Any: 483 | pass 484 | 485 | @staticmethod 486 | def zipWith(array: List[Any], 487 | iteratee: Optional[Callable[[Any, Any, Any, Any], None]] = None, 488 | thisArg: Any = None) -> List[Any]: 489 | pass 490 | 491 | @staticmethod 492 | def all(collection: List[_L1], 493 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 494 | thisArg: Any = None) -> bool: 495 | pass 496 | 497 | @staticmethod 498 | def any(collection: Union[List[_L1], Dict[Any, _L1]], 499 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 500 | thisArg: Any = None) -> bool: 501 | pass 502 | 503 | @staticmethod 504 | def at(collection: Union[List[_L1], Dict[Any, _L1]], *props: Any) -> List[_L1]: 505 | pass 506 | 507 | @staticmethod 508 | def countBy(collection: Union[List[_L1], Dict[Any, _L1]], 509 | iteratee: Union[str, Callable[[_L1], _L2], None] = None, 510 | thisArg: Any = None) -> Dict[_L2, int]: 511 | pass 512 | 513 | @staticmethod 514 | def every(collection: Union[List[_L1], Dict[Any, _L1]], 515 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 516 | thisArg: Any = None) -> bool: 517 | pass 518 | 519 | @staticmethod 520 | def filter(collection: Union[List[_L1], Dict[Any, _L1]], 521 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 522 | thisArg: Any = None) -> List[_L1]: 523 | pass 524 | 525 | @staticmethod 526 | def find(collection: Union[List[_L1], Dict[Any, _L1]], 527 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 528 | thisArg: Any = None) -> _L1: 529 | pass 530 | 531 | @staticmethod 532 | def findLast(collection: Union[List[_L1], Dict[Any, _L1]], 533 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 534 | thisArg: Any = None) -> _L1: 535 | pass 536 | 537 | @staticmethod 538 | def findWhere(collection: Any, 539 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 540 | thisArg: Any = None) -> _L1: 541 | pass 542 | 543 | @staticmethod 544 | def groupBy(collection: Union[List[_L1], Dict[Any, _L1]], 545 | iteratee: Union[str, Callable[[_L1], _L2], None] = None, 546 | thisArg: Any = None) -> Dict[_L2, List[_L1]]: 547 | pass 548 | 549 | @staticmethod 550 | def includes(collection: Union[List[_L1], Dict[Any, _L1], str], value: _L1, fromIndex: int = 0) -> bool: 551 | pass 552 | 553 | @staticmethod 554 | def indexBy(collection: Union[List[_L1], Dict[Any, _L1]], 555 | iteratee: Union[str, Callable[[_L1], _L2], None] = None, 556 | thisArg: Any = None) -> Dict[str, _L1]: 557 | pass 558 | 559 | @staticmethod 560 | def invoke(collection: Union[List[_L1], Dict[Any, _L1]], path: str, *args: Any) -> Any: 561 | pass 562 | 563 | @staticmethod 564 | def map(collection: Union[List[_L1], Dict[Any, _L1]], 565 | iteratee: Union[str, Callable[[_L1], _L2], None] = None, 566 | thisArg: Any = None) -> List[_L2]: 567 | pass 568 | 569 | @staticmethod 570 | def partition(collection: Union[List[_L1], Dict[Any, _L1]], 571 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 572 | thisArg: Any = None) -> Tuple[List[_L1], List[_L1]]: 573 | pass 574 | 575 | @staticmethod 576 | def pluck(collection: Union[List[_L1], Dict[Any, _L1]], path: Union[str, List[str]]) -> List[Any]: 577 | pass 578 | 579 | @staticmethod 580 | def reduce(collection: Union[List[_L1], Dict[Any, _L1]], 581 | iteratee: Callable[[_L2, _L1], _L2] = None, 582 | accumulator: _L2 = None, 583 | thisArg: Any = None) -> _L2: 584 | pass 585 | 586 | @staticmethod 587 | def reduceRight(collection: Union[List[_L1], Dict[Any, _L1]], 588 | iteratee: Callable[[_L2, _L1], _L2] = None, 589 | accumulator: _L2 = None, 590 | thisArg: Any = None) -> _L2: 591 | pass 592 | 593 | @staticmethod 594 | def reject(collection: Union[List[_L1], Dict[Any, _L1]], 595 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 596 | thisArg: Any = None) -> List[ 597 | _L1]: 598 | pass 599 | 600 | @staticmethod 601 | def sample(collection: Union[List[_L1], Dict[Any, _L1]]) -> _L1: 602 | pass 603 | 604 | @staticmethod 605 | def shuffle(collection: Union[List[_L1], Dict[Any, _L1]]) -> List[_L1]: 606 | pass 607 | 608 | @staticmethod 609 | def size(collection: Optional[Union[List[_L1], Dict[Any, _L1]]]) -> int: 610 | pass 611 | 612 | @staticmethod 613 | def some(collection: Union[List[_L1], Dict[Any, _L1]], 614 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 615 | thisArg: Any = None) -> bool: 616 | pass 617 | 618 | @staticmethod 619 | def sortBy(collection: Union[List[_L1], Dict[Any, _L1]], 620 | iteratee: Union[str, Callable[[_L1], _L2], None] = None, 621 | thisArg: Any = None) -> List[_L1]: 622 | pass 623 | 624 | @staticmethod 625 | def sortByAll(collection: Union[List[_L1], Dict[Any, _L1]], 626 | *iteratee: Union[str, Callable[[_L1], _L2], None]) -> List[_L1]: 627 | pass 628 | 629 | @staticmethod 630 | def sortByOrder(collection: Union[List[_L1], Dict[Any, _L1]], 631 | iteratees: List[Union[str, Callable[[_L1], _L2], None]], 632 | orders: List[str]) -> List[_L1]: 633 | pass 634 | 635 | @staticmethod 636 | def where(collection: Union[List[_L1], Dict[Any, _L1]], source: Any) -> List[_L1]: 637 | pass 638 | 639 | @staticmethod 640 | def clone(value: _L1) -> _L1: 641 | pass 642 | 643 | @staticmethod 644 | def cloneDeep(value: _L1) -> _L1: 645 | pass 646 | 647 | @staticmethod 648 | def gt(value: Any, other: Any) -> bool: 649 | pass 650 | 651 | @staticmethod 652 | def gte(value: Any, other: Any) -> bool: 653 | pass 654 | 655 | @staticmethod 656 | def isArguments(value: Any) -> bool: 657 | pass 658 | 659 | @staticmethod 660 | def isArray(value: Any) -> bool: 661 | pass 662 | 663 | @staticmethod 664 | def isBoolean(value: Any) -> bool: 665 | pass 666 | 667 | @staticmethod 668 | def isDate(value: Any) -> bool: 669 | pass 670 | 671 | @staticmethod 672 | def isElement(value: Any) -> bool: 673 | pass 674 | 675 | @staticmethod 676 | def isEmpty(value: Any) -> bool: 677 | pass 678 | 679 | @staticmethod 680 | def isEqual(value: Any, other: Any) -> bool: 681 | pass 682 | 683 | @staticmethod 684 | def isError(value: Any) -> bool: 685 | pass 686 | 687 | @staticmethod 688 | def isFinite(value: Any) -> bool: 689 | pass 690 | 691 | @staticmethod 692 | def isFunction(value: Any) -> bool: 693 | pass 694 | 695 | @staticmethod 696 | def isMatch(value: Any) -> bool: 697 | pass 698 | 699 | @staticmethod 700 | def isNaN(value: Any) -> bool: 701 | pass 702 | 703 | @staticmethod 704 | def isNative(value: Any) -> bool: 705 | pass 706 | 707 | @staticmethod 708 | def isNull(value: Any) -> bool: 709 | pass 710 | 711 | @staticmethod 712 | def isNumber(value: Any) -> bool: 713 | pass 714 | 715 | @staticmethod 716 | def isObject(value: Any) -> bool: 717 | pass 718 | 719 | @staticmethod 720 | def isPlainObject(value: Any) -> bool: 721 | pass 722 | 723 | @staticmethod 724 | def isRegExp(value: Any) -> bool: 725 | pass 726 | 727 | @staticmethod 728 | def isString(value: Any) -> bool: 729 | pass 730 | 731 | @staticmethod 732 | def isTypedArray(value: Any) -> bool: 733 | pass 734 | 735 | @staticmethod 736 | def isUndefined(value: Any) -> bool: 737 | pass 738 | 739 | @staticmethod 740 | def lt(value: Any, other: Any) -> bool: 741 | pass 742 | 743 | @staticmethod 744 | def lte(value: Any, other: Any) -> bool: 745 | pass 746 | 747 | @staticmethod 748 | def toArray(value: Any) -> List[Any]: 749 | pass 750 | 751 | @staticmethod 752 | def toPlainObject(value: Any) -> Any: 753 | pass 754 | 755 | @staticmethod 756 | def add(augend: Union[int, float], addend: Union[int, float]) -> Union[int, float]: 757 | pass 758 | 759 | @staticmethod 760 | def ceil(n: Union[int, float], precision: int = 0) -> Union[int, float]: 761 | pass 762 | 763 | @staticmethod 764 | def floor(n: Union[int, float], precision: int = 0) -> Union[int, float]: 765 | pass 766 | 767 | @staticmethod 768 | def max(collection: Union[List[_L1], Dict[Any, _L1]], 769 | iteratee: Union[str, Callable[[_L1], Any], None] = lambda x: x, 770 | thisArg: Any = None) -> _L1: 771 | pass 772 | 773 | @staticmethod 774 | def min(collection: Union[List[_L1], Dict[Any, _L1]], 775 | iteratee: Union[str, Callable[[_L1], Any], None] = lambda x: x, 776 | thisArg: Any = None) -> _L1: 777 | pass 778 | 779 | @staticmethod 780 | def round(n: Union[int, float], precision: int = 0) -> Union[int, float]: 781 | pass 782 | 783 | @staticmethod 784 | def sum(collection: Union[List[_L1], Dict[Any, _L1]], 785 | iteratee: Union[str, Callable[[_L1], _L2], None] = None, 786 | thisArg: Any = None) -> _L2: 787 | pass 788 | 789 | @staticmethod 790 | def extend(_object: Any, *sources: Any) -> Any: 791 | pass 792 | 793 | @staticmethod 794 | def assign(_object: Any, *sources: Any) -> Any: 795 | pass 796 | 797 | @staticmethod 798 | def create(prototype: Type[_L1], properties: Any = None) -> _L1: 799 | pass 800 | 801 | @staticmethod 802 | def defaults(_object: Any, *sources: Any) -> Any: 803 | pass 804 | 805 | @staticmethod 806 | def defaultsDeep(_object: Any, *sources: Any) -> Any: 807 | pass 808 | 809 | @staticmethod 810 | def findKey(_object: Any, 811 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 812 | thisArg: Any = None) -> str: 813 | pass 814 | 815 | @staticmethod 816 | def findLastKey(_object: Any, 817 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str] = None, 818 | thisArg: Any = None) -> str: 819 | pass 820 | 821 | @staticmethod 822 | def forIn(_object: _L4, iteratee: Callable[[_L1], Optional[bool]] = None, thisArg: Any = None) -> _L4: 823 | pass 824 | 825 | @staticmethod 826 | def forInRight(_object: _L4, iteratee: Callable[[_L1], Optional[bool]] = None, thisArg: Any = None) -> _L4: 827 | pass 828 | 829 | @staticmethod 830 | def forOwn(_object: _L4, iteratee: Callable[[_L1], Optional[bool]] = None, thisArg: Any = None) -> _L4: 831 | pass 832 | 833 | @staticmethod 834 | def functions(_object: Any) -> List[str]: 835 | pass 836 | 837 | @staticmethod 838 | def get(_object: Any, path: Union[str, List[str]], defaultValue: _L1 = None) -> _L1: 839 | pass 840 | 841 | @staticmethod 842 | def has(_object: Any, path: str) -> bool: 843 | pass 844 | 845 | @staticmethod 846 | def invert(_object: Any) -> Dict[str, str]: 847 | pass 848 | 849 | @staticmethod 850 | def keys(_object: Any) -> List[str]: 851 | pass 852 | 853 | @staticmethod 854 | def keysIn(_object: Any) -> List[str]: 855 | pass 856 | 857 | @staticmethod 858 | def mapKeys(_object: Any, iteratee: Callable[[str], str] = None, thisArg: Any = None) -> Any: 859 | pass 860 | 861 | @staticmethod 862 | def mapValues(_object: Any, iteratee: Callable[[Any], Any] = None, thisArg: Any = None) -> Any: 863 | pass 864 | 865 | @staticmethod 866 | def merge(_object: Any, *sources: Any) -> Any: 867 | pass 868 | 869 | @staticmethod 870 | def omit(_object: Any, 871 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str], 872 | thisArg: Any = None) -> Any: 873 | pass 874 | 875 | @staticmethod 876 | def pairs(_object: Any) -> List[Tuple[str, Any]]: 877 | pass 878 | 879 | @staticmethod 880 | def pick(_object: Any, 881 | predicate: Union[Dict[str, Any], Callable[[_L1], bool], None, str], 882 | thisArg: Any = None) -> Any: 883 | pass 884 | 885 | @staticmethod 886 | def result(_object: Any, path: str, defaultValue: _L1 = None) -> _L1: 887 | pass 888 | 889 | @staticmethod 890 | def set(_object: _L4, path: str, value: Any) -> _L4: 891 | pass 892 | 893 | @staticmethod 894 | def transform(_object: Any, 895 | iteratee: Callable[[_L2, _L1], _L2] = None, 896 | accumulator: _L2 = None, 897 | thisArg: Any = None) -> _L2: 898 | pass 899 | 900 | @staticmethod 901 | def values(_object: Union[Dict[str, _L2], Any]) -> List[_L2]: 902 | pass 903 | 904 | @staticmethod 905 | def valuesIn(_object: Union[Dict[str, _L2], Any]) -> List[_L2]: 906 | pass 907 | 908 | @staticmethod 909 | def random(minimum: int, maximum: int) -> int: 910 | pass 911 | -------------------------------------------------------------------------------- /src/defs/constants.py: -------------------------------------------------------------------------------- 1 | # Error constants 2 | OK = 0 3 | ERR_NOT_OWNER = -1 4 | ERR_NO_PATH = -2 5 | ERR_NAME_EXISTS = -3 6 | ERR_BUSY = -4 7 | ERR_NOT_FOUND = -5 8 | ERR_NOT_ENOUGH_ENERGY = -6 9 | ERR_NOT_ENOUGH_RESOURCES = -6 10 | ERR_INVALID_TARGET = -7 11 | ERR_FULL = -8 12 | ERR_NOT_IN_RANGE = -9 13 | ERR_INVALID_ARGS = -10 14 | ERR_TIRED = -11 15 | ERR_NO_BODYPART = -12 16 | ERR_NOT_ENOUGH_EXTENSIONS = -6 17 | ERR_RCL_NOT_ENOUGH = -14 18 | ERR_GCL_NOT_ENOUGH = -15 19 | 20 | # Find constants 21 | FIND_EXIT_TOP = 1 22 | FIND_EXIT_RIGHT = 3 23 | FIND_EXIT_BOTTOM = 5 24 | FIND_EXIT_LEFT = 7 25 | FIND_EXIT = 10 26 | FIND_CREEPS = 101 27 | FIND_MY_CREEPS = 102 28 | FIND_HOSTILE_CREEPS = 103 29 | FIND_SOURCES_ACTIVE = 104 30 | FIND_SOURCES = 105 31 | FIND_DROPPED_RESOURCES = 106 32 | FIND_STRUCTURES = 107 33 | FIND_MY_STRUCTURES = 108 34 | FIND_HOSTILE_STRUCTURES = 109 35 | FIND_FLAGS = 110 36 | FIND_CONSTRUCTION_SITES = 111 37 | FIND_MY_SPAWNS = 112 38 | FIND_HOSTILE_SPAWNS = 113 39 | FIND_MY_CONSTRUCTION_SITES = 114 40 | FIND_HOSTILE_CONSTRUCTION_SITES = 115 41 | FIND_MINERALS = 116 42 | FIND_NUKES = 117 43 | FIND_TOMBSTONES = 118 44 | FIND_POWER_CREEPS = 119 45 | FIND_MY_POWER_CREEPS = 120 46 | FIND_HOSTILE_POWER_CREEPS = 121 47 | FIND_DEPOSITS = 122 48 | FIND_RUINS = 123 49 | 50 | # Direction constants 51 | TOP = 1 52 | TOP_RIGHT = 2 53 | RIGHT = 3 54 | BOTTOM_RIGHT = 4 55 | BOTTOM = 5 56 | BOTTOM_LEFT = 6 57 | LEFT = 7 58 | TOP_LEFT = 8 59 | 60 | # Color constants 61 | COLOR_RED = 1 62 | COLOR_PURPLE = 2 63 | COLOR_BLUE = 3 64 | COLOR_CYAN = 4 65 | COLOR_GREEN = 5 66 | COLOR_YELLOW = 6 67 | COLOR_ORANGE = 7 68 | COLOR_BROWN = 8 69 | COLOR_GREY = 9 70 | COLOR_WHITE = 10 71 | 72 | # Look constants 73 | LOOK_CREEPS = "creep" 74 | LOOK_ENERGY = "energy" 75 | LOOK_RESOURCES = "resource" 76 | LOOK_SOURCES = "source" 77 | LOOK_MINERALS = "mineral" 78 | LOOK_STRUCTURES = "structure" 79 | LOOK_FLAGS = "flag" 80 | LOOK_CONSTRUCTION_SITES = "constructionSite" 81 | LOOK_NUKES = "nuke" 82 | LOOK_TERRAIN = "terrain" 83 | LOOK_TOMBSTONES = "tombstone" 84 | LOOK_POWER_CREEPS = "powerCreep" 85 | LOOK_RUINS = "ruin" 86 | 87 | # Obstacle types 88 | OBSTACLE_OBJECT_TYPES = [ 89 | "spawn", 90 | "creep", 91 | "wall", 92 | "source", 93 | "constructedWall", 94 | "extension", 95 | "link", 96 | "storage", 97 | "tower", 98 | "observer", 99 | "powerSpawn", 100 | "powerBank", 101 | "lab", 102 | "terminal", 103 | "nuker", 104 | "factory", 105 | "invaderCore" 106 | ] 107 | 108 | # Part constants 109 | MOVE = "move" 110 | WORK = "work" 111 | CARRY = "carry" 112 | ATTACK = "attack" 113 | RANGED_ATTACK = "ranged_attack" 114 | TOUGH = "tough" 115 | HEAL = "heal" 116 | CLAIM = "claim" 117 | 118 | # Part costs 119 | BODYPART_COST = { 120 | MOVE: 50, 121 | WORK: 100, 122 | ATTACK: 80, 123 | CARRY: 50, 124 | HEAL: 250, 125 | RANGED_ATTACK: 150, 126 | TOUGH: 10, 127 | CLAIM: 600, 128 | } 129 | 130 | # World constants 131 | # WORLD_WIDTH and WORLD_HEIGHT constants are deprecated, please use Game.map.getWorldSize() instead 132 | WORLD_WIDTH = 202 133 | WORLD_HEIGHT = 202 134 | 135 | # Creep life constants 136 | CREEP_LIFE_TIME = 1500 137 | CREEP_CLAIM_LIFE_TIME = 500 138 | CREEP_CORPSE_RATE = 0.2 139 | CREEP_PART_MAX_ENERGY = 125 140 | 141 | # Power constants 142 | CARRY_CAPACITY = 50 143 | HARVEST_POWER = 2 144 | HARVEST_MINERAL_POWER = 1 145 | REPAIR_POWER = 100 146 | DISMANTLE_POWER = 50 147 | BUILD_POWER = 5 148 | ATTACK_POWER = 30 149 | UPGRADE_CONTROLLER_POWER = 1 150 | RANGED_ATTACK_POWER = 10 151 | HEAL_POWER = 12 152 | RANGED_HEAL_POWER = 4 153 | REPAIR_COST = 0.01 154 | DISMANTLE_COST = 0.005 155 | 156 | # Rampart constants 157 | RAMPART_DECAY_AMOUNT = 300 158 | RAMPART_DECAY_TIME = 100 159 | RAMPART_HITS = 1 160 | RAMPART_HITS_MAX = { 161 | 2: 300000, 162 | 3: 1000000, 163 | 4: 3000000, 164 | 5: 10000000, 165 | 6: 30000000, 166 | 7: 100000000, 167 | 8: 300000000 168 | } 169 | 170 | # Room energy constants 171 | ENERGY_REGEN_TIME = 300 172 | ENERGY_DECAY = 1000 173 | 174 | # Spawn constants 175 | SPAWN_HITS = 5000 176 | SPAWN_ENERGY_START = 300 177 | SPAWN_ENERGY_CAPACITY = 300 178 | CREEP_SPAWN_TIME = 3 179 | SPAWN_RENEW_RATIO = 1.2 180 | 181 | # Source constants 182 | SOURCE_ENERGY_CAPACITY = 3000 183 | SOURCE_ENERGY_NEUTRAL_CAPACITY = 1500 184 | SOURCE_ENERGY_KEEPER_CAPACITY = 4000 185 | 186 | # Wall constants 187 | WALL_HITS = 1 188 | WALL_HITS_MAX = 300000000 189 | 190 | # Extension constants 191 | EXTENSION_HITS = 1000 192 | EXTENSION_ENERGY_CAPACITY = { 193 | 0: 50, 194 | 1: 50, 195 | 2: 50, 196 | 3: 50, 197 | 4: 50, 198 | 5: 50, 199 | 6: 50, 200 | 7: 100, 201 | 8: 200 202 | } 203 | 204 | # Road constants 205 | ROAD_HITS = 5000 206 | ROAD_WEAROUT = 1 207 | ROAD_DECAY_AMOUNT = 100 208 | ROAD_DECAY_TIME = 1000 209 | 210 | # Link constants 211 | LINK_HITS = 1000 212 | LINK_HITS_MAX = 1000 213 | LINK_CAPACITY = 800 214 | LINK_COOLDOWN = 1 215 | LINK_LOSS_RATIO = 0.03 216 | 217 | # Storage constants 218 | STORAGE_CAPACITY = 1000000 219 | STORAGE_HITS = 10000 220 | 221 | # Structure constants 222 | STRUCTURE_SPAWN = "spawn" 223 | STRUCTURE_EXTENSION = "extension" 224 | STRUCTURE_ROAD = "road" 225 | STRUCTURE_WALL = "constructedWall" 226 | STRUCTURE_RAMPART = "rampart" 227 | STRUCTURE_KEEPER_LAIR = "keeperLair" 228 | STRUCTURE_PORTAL = "portal" 229 | STRUCTURE_CONTROLLER = "controller" 230 | STRUCTURE_LINK = "link" 231 | STRUCTURE_STORAGE = "storage" 232 | STRUCTURE_TOWER = "tower" 233 | STRUCTURE_OBSERVER = "observer" 234 | STRUCTURE_POWER_BANK = "powerBank" 235 | STRUCTURE_POWER_SPAWN = "powerSpawn" 236 | STRUCTURE_EXTRACTOR = "extractor" 237 | STRUCTURE_LAB = "lab" 238 | STRUCTURE_TERMINAL = "terminal" 239 | STRUCTURE_CONTAINER = "container" 240 | STRUCTURE_NUKER = "nuker" 241 | STRUCTURE_FACTORY = "factory" 242 | STRUCTURE_INVADER_CORE = "invaderCore" 243 | 244 | # Construction cost constants 245 | CONSTRUCTION_COST = { 246 | "spawn": 15000, 247 | "extension": 3000, 248 | "road": 300, 249 | "constructedWall": 1, 250 | "rampart": 1, 251 | "link": 5000, 252 | "storage": 30000, 253 | "tower": 5000, 254 | "observer": 8000, 255 | "powerSpawn": 100000, 256 | "extractor": 5000, 257 | "lab": 50000, 258 | "terminal": 100000, 259 | "container": 5000, 260 | "nuker": 100000, 261 | "factory": 100000 262 | } 263 | CONSTRUCTION_COST_ROAD_SWAMP_RATIO = 5 264 | CONSTRUCTION_COST_ROAD_WALL_RATIO = 150 265 | 266 | # Controller level structure constants 267 | CONTROLLER_LEVELS = { 268 | 1: 200, 269 | 2: 45000, 270 | 3: 135000, 271 | 4: 405000, 272 | 5: 1215000, 273 | 6: 3645000, 274 | 7: 10935000 275 | } 276 | CONTROLLER_STRUCTURES = { 277 | "spawn": { 278 | 0: 0, 279 | 1: 1, 280 | 2: 1, 281 | 3: 1, 282 | 4: 1, 283 | 5: 1, 284 | 6: 1, 285 | 7: 2, 286 | 8: 3 287 | }, 288 | "extension": { 289 | 0: 0, 290 | 1: 0, 291 | 2: 5, 292 | 3: 10, 293 | 4: 20, 294 | 5: 30, 295 | 6: 40, 296 | 7: 50, 297 | 8: 60 298 | }, 299 | "link": { 300 | 1: 0, 301 | 2: 0, 302 | 3: 0, 303 | 4: 0, 304 | 5: 2, 305 | 6: 3, 306 | 7: 4, 307 | 8: 6 308 | }, 309 | "road": { 310 | 0: 2500, 311 | 1: 2500, 312 | 2: 2500, 313 | 3: 2500, 314 | 4: 2500, 315 | 5: 2500, 316 | 6: 2500, 317 | 7: 2500, 318 | 8: 2500 319 | }, 320 | "constructedWall": { 321 | 1: 0, 322 | 2: 2500, 323 | 3: 2500, 324 | 4: 2500, 325 | 5: 2500, 326 | 6: 2500, 327 | 7: 2500, 328 | 8: 2500 329 | }, 330 | "rampart": { 331 | 1: 0, 332 | 2: 2500, 333 | 3: 2500, 334 | 4: 2500, 335 | 5: 2500, 336 | 6: 2500, 337 | 7: 2500, 338 | 8: 2500 339 | }, 340 | "storage": { 341 | 1: 0, 342 | 2: 0, 343 | 3: 0, 344 | 4: 1, 345 | 5: 1, 346 | 6: 1, 347 | 7: 1, 348 | 8: 1 349 | }, 350 | "tower": { 351 | 1: 0, 352 | 2: 0, 353 | 3: 1, 354 | 4: 1, 355 | 5: 2, 356 | 6: 2, 357 | 7: 3, 358 | 8: 6 359 | }, 360 | "observer": { 361 | 1: 0, 362 | 2: 0, 363 | 3: 0, 364 | 4: 0, 365 | 5: 0, 366 | 6: 0, 367 | 7: 0, 368 | 8: 1 369 | }, 370 | "powerSpawn": { 371 | 1: 0, 372 | 2: 0, 373 | 3: 0, 374 | 4: 0, 375 | 5: 0, 376 | 6: 0, 377 | 7: 0, 378 | 8: 1 379 | }, 380 | "extractor": { 381 | 1: 0, 382 | 2: 0, 383 | 3: 0, 384 | 4: 0, 385 | 5: 0, 386 | 6: 1, 387 | 7: 1, 388 | 8: 1 389 | }, 390 | "terminal": { 391 | 1: 0, 392 | 2: 0, 393 | 3: 0, 394 | 4: 0, 395 | 5: 0, 396 | 6: 1, 397 | 7: 1, 398 | 8: 1 399 | }, 400 | "lab": { 401 | 1: 0, 402 | 2: 0, 403 | 3: 0, 404 | 4: 0, 405 | 5: 0, 406 | 6: 3, 407 | 7: 6, 408 | 8: 10 409 | }, 410 | "container": { 411 | 0: 5, 412 | 1: 5, 413 | 2: 5, 414 | 3: 5, 415 | 4: 5, 416 | 5: 5, 417 | 6: 5, 418 | 7: 5, 419 | 8: 5 420 | }, 421 | "nuker": { 422 | 1: 0, 423 | 2: 0, 424 | 3: 0, 425 | 4: 0, 426 | 5: 0, 427 | 6: 0, 428 | 7: 0, 429 | 8: 1 430 | }, 431 | "factory": { 432 | 1: 0, 433 | 2: 0, 434 | 3: 0, 435 | 4: 0, 436 | 5: 0, 437 | 6: 0, 438 | 7: 1, 439 | 8: 1 440 | } 441 | } 442 | CONTROLLER_DOWNGRADE = { 443 | 1: 20000, 444 | 2: 10000, 445 | 3: 20000, 446 | 4: 40000, 447 | 5: 80000, 448 | 6: 120000, 449 | 7: 150000, 450 | 8: 200000, 451 | } 452 | CONTROLLER_DOWNGRADE_RESTORE = 100 453 | CONTROLLER_DOWNGRADE_SAFEMODE_THRESHOLD = 5000 454 | 455 | CONTROLLER_CLAIM_DOWNGRADE = 300 456 | # Noting especially here: CONTROLLER_RESERVE seemingly is the RESERVE_POWER constant, meaning it is how much reservation 457 | # a creep can do per CLAIM part per tick. 458 | CONTROLLER_RESERVE = 1 459 | CONTROLLER_RESERVE_MAX = 5000 460 | CONTROLLER_MAX_UPGRADE_PER_TICK = 15 461 | CONTROLLER_ATTACK_BLOCKED_UPGRADE = 1000 462 | CONTROLLER_NUKE_BLOCKED_UPGRADE = 200 463 | 464 | # Safe mode constants 465 | SAFE_MODE_DURATION = 20000 466 | SAFE_MODE_COOLDOWN = 50000 467 | SAFE_MODE_COST = 1000 468 | 469 | # Tower constants 470 | TOWER_HITS = 3000 471 | TOWER_CAPACITY = 1000 472 | TOWER_ENERGY_COST = 10 473 | TOWER_POWER_ATTACK = 600 474 | TOWER_POWER_HEAL = 400 475 | TOWER_POWER_REPAIR = 800 476 | TOWER_OPTIMAL_RANGE = 5 477 | TOWER_FALLOFF_RANGE = 20 478 | TOWER_FALLOFF = 0.75 479 | 480 | # Observer constants 481 | OBSERVER_HITS = 500 482 | OBSERVER_RANGE = 10 483 | 484 | # Power bank constants 485 | POWER_BANK_HITS = 2000000 486 | POWER_BANK_CAPACITY_MAX = 5000 487 | POWER_BANK_CAPACITY_MIN = 500 488 | POWER_BANK_CAPACITY_CRIT = 0.3 489 | POWER_BANK_DECAY = 5000 490 | POWER_BANK_HIT_BACK = 0.5 491 | POWER_SPAWN_HITS = 5000 492 | POWER_SPAWN_ENERGY_CAPACITY = 5000 493 | POWER_SPAWN_POWER_CAPACITY = 100 494 | POWER_SPAWN_ENERGY_RATIO = 50 495 | 496 | # Extractor constants 497 | EXTRACTOR_HITS = 500 498 | EXTRACTOR_COOLDOWN = 5 499 | 500 | # Lab constants 501 | LAB_HITS = 500 502 | LAB_MINERAL_CAPACITY = 3000 503 | LAB_ENERGY_CAPACITY = 2000 504 | LAB_BOOST_ENERGY = 20 505 | LAB_BOOST_MINERAL = 30 506 | LAB_COOLDOWN = 10 # not used 507 | LAB_REACTION_AMOUNT = 5 508 | LAB_UNBOOST_ENERGY = 0 509 | LAB_UNBOOST_MINERAL = 15 510 | 511 | # GCL constants 512 | GCL_POW = 2.4 513 | GCL_MULTIPLY = 1000000 514 | GCL_NOVICE = 3 515 | 516 | # Mode constants 517 | MODE_SIMULATION = None 518 | MODE_WORLD = None 519 | 520 | # Terrain constants 521 | TERRAIN_MASK_WALL = 1 522 | TERRAIN_MASK_SWAMP = 2 523 | TERRAIN_MASK_LAVA = 4 524 | 525 | # Maximum constants 526 | MAX_CONSTRUCTION_SITES = 100 527 | MAX_CREEP_SIZE = 50 528 | 529 | # Mineral constants 530 | MINERAL_REGEN_TIME = 50000 531 | MINERAL_MIN_AMOUNT = { 532 | "H": 35000, 533 | "O": 35000, 534 | "L": 35000, 535 | "K": 35000, 536 | "Z": 35000, 537 | "U": 35000, 538 | "X": 35000 539 | } 540 | MINERAL_RANDOM_FACTOR = 2 541 | 542 | MINERAL_DENSITY = { 543 | 1: 15000, 544 | 2: 35000, 545 | 3: 70000, 546 | 4: 100000 547 | } 548 | MINERAL_DENSITY_PROBABILITY = { 549 | 1: 0.1, 550 | 2: 0.5, 551 | 3: 0.9, 552 | 4: 1.0 553 | } 554 | MINERAL_DENSITY_CHANGE = 0.05 555 | 556 | # Density constants 557 | DENSITY_LOW = 1 558 | DENSITY_MODERATE = 2 559 | DENSITY_HIGH = 3 560 | DENSITY_ULTRA = 4 561 | 562 | DEPOSIT_EXHAUST_MULTIPLY = 0.001 563 | DEPOSIT_EXHAUST_POW = 1.2 564 | DEPOSIT_DECAY_TIME = 50000 565 | 566 | # Terminal constants 567 | TERMINAL_CAPACITY = 300000 568 | TERMINAL_HITS = 3000 569 | TERMINAL_SEND_COST = 0.1 570 | TERMINAL_MIN_SEND = 100 571 | TERMINAL_COOLDOWN = 10 572 | 573 | # Container constants 574 | CONTAINER_HITS = 250000 575 | CONTAINER_CAPACITY = 2000 576 | CONTAINER_DECAY = 5000 577 | CONTAINER_DECAY_TIME = 100 578 | CONTAINER_DECAY_TIME_OWNED = 500 579 | 580 | # Nuke constants 581 | NUKER_HITS = 1000 582 | NUKER_COOLDOWN = 100000 583 | NUKER_ENERGY_CAPACITY = 300000 584 | NUKER_GHODIUM_CAPACITY = 5000 585 | NUKE_LAND_TIME = 50000 586 | NUKE_RANGE = 10 587 | NUKE_DAMAGE = { 588 | 0: 10000000, 589 | 2: 5000000 590 | } 591 | 592 | FACTORY_HITS = 1000 593 | FACTORY_CAPACITY = 50000 594 | 595 | TOMBSTONE_DECAY_PER_PART = 5 596 | TOMBSTONE_DECAY_POWER_CREEP = 500 597 | 598 | RUIN_DECAY = 500 599 | RUIN_DECAY_STRUCTURES = { 600 | 'powerBank': 10 601 | } 602 | 603 | # Portal constants 604 | PORTAL_DECAY = 30000 605 | 606 | # Market constants 607 | ORDER_SELL = "sell" 608 | ORDER_BUY = "buy" 609 | 610 | MARKET_FEE = 0.05 611 | 612 | MARKET_MAX_ORDERS = 300 613 | MARKET_ORDER_LIFE_TIME = 1000 * 60 * 60 * 24 * 30 614 | 615 | # Flag limit 616 | FLAGS_LIMIT = 10000 617 | 618 | # Resource constants 619 | SUBSCRIPTION_TOKEN = "token" 620 | 621 | RESOURCE_ENERGY = "energy" 622 | RESOURCE_POWER = "power" 623 | 624 | RESOURCE_HYDROGEN = "H" 625 | RESOURCE_OXYGEN = "O" 626 | RESOURCE_UTRIUM = "U" 627 | RESOURCE_LEMERGIUM = "L" 628 | RESOURCE_KEANIUM = "K" 629 | RESOURCE_ZYNTHIUM = "Z" 630 | RESOURCE_CATALYST = "X" 631 | RESOURCE_GHODIUM = "G" 632 | 633 | RESOURCE_SILICON = 'silicon' 634 | RESOURCE_METAL = 'metal' 635 | RESOURCE_BIOMASS = 'biomass' 636 | RESOURCE_MIST = 'mist' 637 | 638 | RESOURCE_HYDROXIDE = "OH" 639 | RESOURCE_ZYNTHIUM_KEANITE = "ZK" 640 | RESOURCE_UTRIUM_LEMERGITE = "UL" 641 | 642 | RESOURCE_UTRIUM_HYDRIDE = "UH" 643 | RESOURCE_UTRIUM_OXIDE = "UO" 644 | RESOURCE_KEANIUM_HYDRIDE = "KH" 645 | RESOURCE_KEANIUM_OXIDE = "KO" 646 | RESOURCE_LEMERGIUM_HYDRIDE = "LH" 647 | RESOURCE_LEMERGIUM_OXIDE = "LO" 648 | RESOURCE_ZYNTHIUM_HYDRIDE = "ZH" 649 | RESOURCE_ZYNTHIUM_OXIDE = "ZO" 650 | RESOURCE_GHODIUM_HYDRIDE = "GH" 651 | RESOURCE_GHODIUM_OXIDE = "GO" 652 | 653 | RESOURCE_UTRIUM_ACID = "UH2O" 654 | RESOURCE_UTRIUM_ALKALIDE = "UHO2" 655 | RESOURCE_KEANIUM_ACID = "KH2O" 656 | RESOURCE_KEANIUM_ALKALIDE = "KHO2" 657 | RESOURCE_LEMERGIUM_ACID = "LH2O" 658 | RESOURCE_LEMERGIUM_ALKALIDE = "LHO2" 659 | RESOURCE_ZYNTHIUM_ACID = "ZH2O" 660 | RESOURCE_ZYNTHIUM_ALKALIDE = "ZHO2" 661 | RESOURCE_GHODIUM_ACID = "GH2O" 662 | RESOURCE_GHODIUM_ALKALIDE = "GHO2" 663 | 664 | RESOURCE_CATALYZED_UTRIUM_ACID = "XUH2O" 665 | RESOURCE_CATALYZED_UTRIUM_ALKALIDE = "XUHO2" 666 | RESOURCE_CATALYZED_KEANIUM_ACID = "XKH2O" 667 | RESOURCE_CATALYZED_KEANIUM_ALKALIDE = "XKHO2" 668 | RESOURCE_CATALYZED_LEMERGIUM_ACID = "XLH2O" 669 | RESOURCE_CATALYZED_LEMERGIUM_ALKALIDE = "XLHO2" 670 | RESOURCE_CATALYZED_ZYNTHIUM_ACID = "XZH2O" 671 | RESOURCE_CATALYZED_ZYNTHIUM_ALKALIDE = "XZHO2" 672 | RESOURCE_CATALYZED_GHODIUM_ACID = "XGH2O" 673 | RESOURCE_CATALYZED_GHODIUM_ALKALIDE = "XGHO2" 674 | 675 | RESOURCE_OPS = "ops" 676 | 677 | RESOURCE_UTRIUM_BAR = 'utrium_bar' 678 | RESOURCE_LEMERGIUM_BAR = 'lemergium_bar' 679 | RESOURCE_ZYNTHIUM_BAR = 'zynthium_bar' 680 | RESOURCE_KEANIUM_BAR = 'keanium_bar' 681 | RESOURCE_GHODIUM_MELT = 'ghodium_melt' 682 | RESOURCE_OXIDANT = 'oxidant' 683 | RESOURCE_REDUCTANT = 'reductant' 684 | RESOURCE_PURIFIER = 'purifier' 685 | RESOURCE_BATTERY = 'battery' 686 | 687 | RESOURCE_COMPOSITE = 'composite' 688 | RESOURCE_CRYSTAL = 'crystal' 689 | RESOURCE_LIQUID = 'liquid' 690 | 691 | RESOURCE_WIRE = 'wire' 692 | RESOURCE_SWITCH = 'switch' 693 | RESOURCE_TRANSISTOR = 'transistor' 694 | RESOURCE_MICROCHIP = 'microchip' 695 | RESOURCE_CIRCUIT = 'circuit' 696 | RESOURCE_DEVICE = 'device' 697 | 698 | RESOURCE_CELL = 'cell' 699 | RESOURCE_PHLEGM = 'phlegm' 700 | RESOURCE_TISSUE = 'tissue' 701 | RESOURCE_MUSCLE = 'muscle' 702 | RESOURCE_ORGANOID = 'organoid' 703 | RESOURCE_ORGANISM = 'organism' 704 | 705 | RESOURCE_ALLOY = 'alloy' 706 | RESOURCE_TUBE = 'tube' 707 | RESOURCE_FIXTURES = 'fixtures' 708 | RESOURCE_FRAME = 'frame' 709 | RESOURCE_HYDRAULICS = 'hydraulics' 710 | RESOURCE_MACHINE = 'machine' 711 | 712 | RESOURCE_CONDENSATE = 'condensate' 713 | RESOURCE_CONCENTRATE = 'concentrate' 714 | RESOURCE_EXTRACT = 'extract' 715 | RESOURCE_SPIRIT = 'spirit' 716 | RESOURCE_EMANATION = 'emanation' 717 | RESOURCE_ESSENCE = 'essence' 718 | 719 | REACTIONS = { 720 | "H": { 721 | "O": "OH", 722 | "L": "LH", 723 | "K": "KH", 724 | "U": "UH", 725 | "Z": "ZH", 726 | "G": "GH" 727 | }, 728 | "O": { 729 | "H": "OH", 730 | "L": "LO", 731 | "K": "KO", 732 | "U": "UO", 733 | "Z": "ZO", 734 | "G": "GO" 735 | }, 736 | "Z": { 737 | "K": "ZK", 738 | "H": "ZH", 739 | "O": "ZO" 740 | }, 741 | "L": { 742 | "U": "UL", 743 | "H": "LH", 744 | "O": "LO" 745 | }, 746 | "K": { 747 | "Z": "ZK", 748 | "H": "KH", 749 | "O": "KO" 750 | }, 751 | "G": { 752 | "H": "GH", 753 | "O": "GO" 754 | }, 755 | "U": { 756 | "L": "UL", 757 | "H": "UH", 758 | "O": "UO" 759 | }, 760 | "OH": { 761 | "UH": "UH2O", 762 | "UO": "UHO2", 763 | "ZH": "ZH2O", 764 | "ZO": "ZHO2", 765 | "KH": "KH2O", 766 | "KO": "KHO2", 767 | "LH": "LH2O", 768 | "LO": "LHO2", 769 | "GH": "GH2O", 770 | "GO": "GHO2" 771 | }, 772 | "X": { 773 | "UH2O": "XUH2O", 774 | "UHO2": "XUHO2", 775 | "LH2O": "XLH2O", 776 | "LHO2": "XLHO2", 777 | "KH2O": "XKH2O", 778 | "KHO2": "XKHO2", 779 | "ZH2O": "XZH2O", 780 | "ZHO2": "XZHO2", 781 | "GH2O": "XGH2O", 782 | "GHO2": "XGHO2" 783 | }, 784 | "ZK": { 785 | "UL": "G" 786 | }, 787 | "UL": { 788 | "ZK": "G" 789 | }, 790 | "LH": { 791 | "OH": "LH2O" 792 | }, 793 | "ZH": { 794 | "OH": "ZH2O" 795 | }, 796 | "GH": { 797 | "OH": "GH2O" 798 | }, 799 | "KH": { 800 | "OH": "KH2O" 801 | }, 802 | "UH": { 803 | "OH": "UH2O" 804 | }, 805 | "LO": { 806 | "OH": "LHO2" 807 | }, 808 | "ZO": { 809 | "OH": "ZHO2" 810 | }, 811 | "KO": { 812 | "OH": "KHO2" 813 | }, 814 | "UO": { 815 | "OH": "UHO2" 816 | }, 817 | "GO": { 818 | "OH": "GHO2" 819 | }, 820 | "LH2O": { 821 | "X": "XLH2O" 822 | }, 823 | "KH2O": { 824 | "X": "XKH2O" 825 | }, 826 | "ZH2O": { 827 | "X": "XZH2O" 828 | }, 829 | "UH2O": { 830 | "X": "XUH2O" 831 | }, 832 | "GH2O": { 833 | "X": "XGH2O" 834 | }, 835 | "LHO2": { 836 | "X": "XLHO2" 837 | }, 838 | "UHO2": { 839 | "X": "XUHO2" 840 | }, 841 | "KHO2": { 842 | "X": "XKHO2" 843 | }, 844 | "ZHO2": { 845 | "X": "XZHO2" 846 | }, 847 | "GHO2": { 848 | "X": "XGHO2" 849 | } 850 | } 851 | 852 | BOOSTS = { 853 | "work": { 854 | "UO": { 855 | "harvest": 3 856 | }, 857 | "UHO2": { 858 | "harvest": 5 859 | }, 860 | "XUHO2": { 861 | "harvest": 7 862 | }, 863 | "LH": { 864 | "build": 1.5, 865 | "repair": 1.5 866 | }, 867 | "LH2O": { 868 | "build": 1.8, 869 | "repair": 1.8 870 | }, 871 | "XLH2O": { 872 | "build": 2, 873 | "repair": 2 874 | }, 875 | "ZH": { 876 | "dismantle": 2 877 | }, 878 | "ZH2O": { 879 | "dismantle": 3 880 | }, 881 | "XZH2O": { 882 | "dismantle": 4 883 | }, 884 | "GH": { 885 | "upgradeController": 1.5 886 | }, 887 | "GH2O": { 888 | "upgradeController": 1.8 889 | }, 890 | "XGH2O": { 891 | "upgradeController": 2 892 | } 893 | }, 894 | "attack": { 895 | "UH": { 896 | "attack": 2 897 | }, 898 | "UH2O": { 899 | "attack": 3 900 | }, 901 | "XUH2O": { 902 | "attack": 4 903 | } 904 | }, 905 | "ranged_attack": { 906 | "KO": { 907 | "rangedAttack": 2, 908 | "rangedMassAttack": 2 909 | }, 910 | "KHO2": { 911 | "rangedAttack": 3, 912 | "rangedMassAttack": 3 913 | }, 914 | "XKHO2": { 915 | "rangedAttack": 4, 916 | "rangedMassAttack": 4 917 | } 918 | }, 919 | "heal": { 920 | "LO": { 921 | "heal": 2, 922 | "rangedHeal": 2 923 | }, 924 | "LHO2": { 925 | "heal": 3, 926 | "rangedHeal": 3 927 | }, 928 | "XLHO2": { 929 | "heal": 4, 930 | "rangedHeal": 4 931 | } 932 | }, 933 | "carry": { 934 | "KH": { 935 | "capacity": 2 936 | }, 937 | "KH2O": { 938 | "capacity": 3 939 | }, 940 | "XKH2O": { 941 | "capacity": 4 942 | } 943 | }, 944 | "move": { 945 | "ZO": { 946 | "fatigue": 2 947 | }, 948 | "ZHO2": { 949 | "fatigue": 3 950 | }, 951 | "XZHO2": { 952 | "fatigue": 4 953 | } 954 | }, 955 | "tough": { 956 | "GO": { 957 | "damage": .7 958 | }, 959 | "GHO2": { 960 | "damage": .5 961 | }, 962 | "XGHO2": { 963 | "damage": .3 964 | } 965 | } 966 | } 967 | 968 | REACTION_TIME = { 969 | 'OH': 20, 970 | 'ZK': 5, 971 | 'UL': 5, 972 | 'G': 5, 973 | 'UH': 10, 974 | 'UH2O': 5, 975 | 'XUH2O': 60, 976 | 'UO': 10, 977 | 'UHO2': 5, 978 | 'XUHO2': 60, 979 | 'KH': 10, 980 | 'KH2O': 5, 981 | 'XKH2O': 60, 982 | 'KO': 10, 983 | 'KHO2': 5, 984 | 'XKHO2': 60, 985 | 'LH': 15, 986 | 'LH2O': 10, 987 | 'XLH2O': 65, 988 | 'LO': 10, 989 | 'LHO2': 5, 990 | 'XLHO2': 60, 991 | 'ZH': 20, 992 | 'ZH2O': 40, 993 | 'XZH2O': 160, 994 | 'ZO': 10, 995 | 'ZHO2': 5, 996 | 'XZHO2': 60, 997 | 'GH': 10, 998 | 'GH2O': 15, 999 | 'XGH2O': 80, 1000 | 'GO': 10, 1001 | 'GHO2': 30, 1002 | 'XGHO2': 150, 1003 | } 1004 | 1005 | # Portal constants 1006 | PORTAL_UNSTABLE = 10 * 24 * 3600 * 1000 1007 | PORTAL_MIN_TIMEOUT = 12 * 24 * 3600 * 1000 1008 | PORTAL_MAX_TIMEOUT = 22 * 24 * 3600 * 1000 1009 | 1010 | POWER_BANK_RESPAWN_TIME = 50000 1011 | 1012 | # Invader energy goal 1013 | INVADERS_ENERGY_GOAL = 100000 1014 | 1015 | # Sign constants 1016 | SYSTEM_USERNAME = 'Screeps' 1017 | 1018 | SIGN_NOVICE_AREA = 'A new Novice or Respawn Area is being planned somewhere in this sector. Please make sure all important rooms are reserved.' 1019 | SIGN_RESPAWN_AREA = 'A new Novice or Respawn Area is being planned somewhere in this sector. Please make sure all important rooms are reserved.' 1020 | SIGN_PLANNED_AREA = 'A new Novice or Respawn Area is being planned somewhere in this sector. Please make sure all important rooms are reserved.' 1021 | 1022 | # Room Event constants 1023 | EVENT_ATTACK = 1 1024 | EVENT_OBJECT_DESTROYED = 2 1025 | EVENT_ATTACK_CONTROLLER = 3 1026 | EVENT_BUILD = 4 1027 | EVENT_HARVEST = 5 1028 | EVENT_HEAL = 6 1029 | EVENT_REPAIR = 7 1030 | EVENT_RESERVE_CONTROLLER = 8 1031 | EVENT_UPGRADE_CONTROLLER = 9 1032 | EVENT_EXIT = 10 1033 | EVENT_POWER = 11 1034 | EVENT_TRANSFER = 12 1035 | 1036 | EVENT_ATTACK_TYPE_MELEE = 1 1037 | EVENT_ATTACK_TYPE_RANGED = 2 1038 | EVENT_ATTACK_TYPE_RANGED_MASS = 3 1039 | EVENT_ATTACK_TYPE_DISMANTLE = 4 1040 | EVENT_ATTACK_TYPE_HIT_BACK = 5 1041 | EVENT_ATTACK_TYPE_NUKE = 6 1042 | 1043 | EVENT_HEAL_TYPE_MELEE = 1 1044 | EVENT_HEAL_TYPE_RANGED = 2 1045 | 1046 | POWER_LEVEL_MULTIPLY = 1000 1047 | POWER_LEVEL_POW = 2 1048 | POWER_CREEP_SPAWN_COOLDOWN = 8 * 3600 * 1000 1049 | POWER_CREEP_DELETE_COOLDOWN = 24 * 3600 * 1000 1050 | POWER_CREEP_MAX_LEVEL = 25 1051 | POWER_CREEP_LIFE_TIME = 5000 1052 | 1053 | POWER_CLASS = { 1054 | "OPERATOR": 'operator' 1055 | } 1056 | 1057 | PWR_GENERATE_OPS = 1 1058 | PWR_OPERATE_SPAWN = 2 1059 | PWR_OPERATE_TOWER = 3 1060 | PWR_OPERATE_STORAGE = 4 1061 | PWR_OPERATE_LAB = 5 1062 | PWR_OPERATE_EXTENSION = 6 1063 | PWR_OPERATE_OBSERVER = 7 1064 | PWR_OPERATE_TERMINAL = 8 1065 | PWR_DISRUPT_SPAWN = 9 1066 | PWR_DISRUPT_TOWER = 10 1067 | PWR_DISRUPT_SOURCE = 11 1068 | PWR_SHIELD = 12 1069 | PWR_REGEN_SOURCE = 13 1070 | PWR_REGEN_MINERAL = 14 1071 | PWR_DISRUPT_TERMINAL = 15 1072 | PWR_OPERATE_POWER = 16 1073 | PWR_FORTIFY = 17 1074 | PWR_OPERATE_CONTROLLER = 18 1075 | PWR_OPERATE_FACTORY = 19 1076 | 1077 | EFFECT_INVULNERABILITY = 1001 1078 | EFFECT_COLLAPSE_TIMER = 1002 1079 | 1080 | INVADER_CORE_HITS = 100000 1081 | INVADER_CORE_CREEP_SPAWN_TIME = { 1082 | 0: 0, 1083 | 1: 0, 1084 | 2: 6, 1085 | 3: 3, 1086 | 4: 2, 1087 | 5: 1 1088 | } 1089 | INVADER_CORE_EXPAND_TIME = { 1090 | 1: 4000, 1091 | 2: 3500, 1092 | 3: 3000, 1093 | 4: 2500, 1094 | 5: 2000 1095 | } 1096 | INVADER_CORE_CONTROLLER_POWER = 2 1097 | INVADER_CORE_CONTROLLER_DOWNGRADE = 5000 1098 | 1099 | STRONGHOLD_RAMPART_HITS = { 1100 | 0: 0, 1101 | 1: 50000, 1102 | 2: 200000, 1103 | 3: 500000, 1104 | 4: 1000000, 1105 | 5: 2000000 1106 | } 1107 | STRONGHOLD_DECAY_TICKS = 75000 1108 | 1109 | POWER_INFO: { 1110 | PWR_GENERATE_OPS: { 1111 | "className": POWER_CLASS["OPERATOR"], 1112 | "level": [0, 2, 7, 14, 22], 1113 | "cooldown": 50, 1114 | "effect": [1, 2, 4, 6, 8] 1115 | }, 1116 | PWR_OPERATE_SPAWN: { 1117 | "className": POWER_CLASS["OPERATOR"], 1118 | "level": [0, 2, 7, 14, 22], 1119 | "cooldown": 300, 1120 | "duration": 1000, 1121 | "range": 3, 1122 | "ops": 100, 1123 | "effect": [0.9, 0.7, 0.5, 0.35, 0.2] 1124 | }, 1125 | PWR_OPERATE_TOWER: { 1126 | "className": POWER_CLASS["OPERATOR"], 1127 | "level": [0, 2, 7, 14, 22], 1128 | "cooldown": 10, 1129 | "duration": 100, 1130 | "range": 3, 1131 | "ops": 10, 1132 | "effect": [1.1, 1.2, 1.3, 1.4, 1.5] 1133 | }, 1134 | PWR_OPERATE_STORAGE: { 1135 | "className": POWER_CLASS["OPERATOR"], 1136 | "level": [0, 2, 7, 14, 22], 1137 | "cooldown": 800, 1138 | "duration": 1000, 1139 | "range": 3, 1140 | "ops": 100, 1141 | "effect": [500000, 1000000, 2000000, 4000000, 7000000] 1142 | }, 1143 | PWR_OPERATE_LAB: { 1144 | "className": POWER_CLASS["OPERATOR"], 1145 | "level": [0, 2, 7, 14, 22], 1146 | "cooldown": 50, 1147 | "duration": 1000, 1148 | "range": 3, 1149 | "ops": 10, 1150 | "effect": [2, 4, 6, 8, 10] 1151 | }, 1152 | PWR_OPERATE_EXTENSION: { 1153 | "className": POWER_CLASS["OPERATOR"], 1154 | "level": [0, 2, 7, 14, 22], 1155 | "cooldown": 50, 1156 | "range": 3, 1157 | "ops": 2, 1158 | "effect": [0.2, 0.4, 0.6, 0.8, 1.0] 1159 | }, 1160 | PWR_OPERATE_OBSERVER: { 1161 | "className": POWER_CLASS["OPERATOR"], 1162 | "level": [0, 2, 7, 14, 22], 1163 | "cooldown": 400, 1164 | "duration": [200, 400, 600, 800, 1000], 1165 | "range": 3, 1166 | "ops": 10, 1167 | }, 1168 | PWR_OPERATE_TERMINAL: { 1169 | "className": POWER_CLASS["OPERATOR"], 1170 | "level": [0, 2, 7, 14, 22], 1171 | "cooldown": 500, 1172 | "duration": 1000, 1173 | "range": 3, 1174 | "ops": 100, 1175 | "effect": [0.9, 0.8, 0.7, 0.6, 0.5] 1176 | }, 1177 | PWR_DISRUPT_SPAWN: { 1178 | "className": POWER_CLASS["OPERATOR"], 1179 | "level": [0, 2, 7, 14, 22], 1180 | "cooldown": 5, 1181 | "range": 20, 1182 | "ops": 10, 1183 | "duration": [1, 2, 3, 4, 5] 1184 | }, 1185 | PWR_DISRUPT_TOWER: { 1186 | "className": POWER_CLASS["OPERATOR"], 1187 | "level": [0, 2, 7, 14, 22], 1188 | "cooldown": 0, 1189 | "duration": 5, 1190 | "range": 50, 1191 | "ops": 10, 1192 | "effect": [0.9, 0.8, 0.7, 0.6, 0.5], 1193 | }, 1194 | PWR_DISRUPT_SOURCE: { 1195 | "className": POWER_CLASS["OPERATOR"], 1196 | "level": [0, 2, 7, 14, 22], 1197 | "cooldown": 100, 1198 | "range": 3, 1199 | "ops": 100, 1200 | "duration": [100, 200, 300, 400, 500] 1201 | }, 1202 | PWR_SHIELD: { 1203 | "className": POWER_CLASS["OPERATOR"], 1204 | "level": [0, 2, 7, 14, 22], 1205 | "effect": [5000, 10000, 15000, 20000, 25000], 1206 | "duration": 50, 1207 | "cooldown": 20, 1208 | "energy": 100, 1209 | }, 1210 | PWR_REGEN_SOURCE: { 1211 | "className": POWER_CLASS["OPERATOR"], 1212 | "level": [10, 11, 12, 14, 22], 1213 | "cooldown": 100, 1214 | "duration": 300, 1215 | "range": 3, 1216 | "effect": [50, 100, 150, 200, 250], 1217 | "period": 15 1218 | }, 1219 | PWR_REGEN_MINERAL: { 1220 | "className": POWER_CLASS["OPERATOR"], 1221 | "level": [10, 11, 12, 14, 22], 1222 | "cooldown": 100, 1223 | "duration": 100, 1224 | "range": 3, 1225 | "effect": [2, 4, 6, 8, 10], 1226 | "period": 10 1227 | }, 1228 | PWR_DISRUPT_TERMINAL: { 1229 | "className": POWER_CLASS["OPERATOR"], 1230 | "level": [20, 21, 22, 23, 24], 1231 | "cooldown": 8, 1232 | "duration": 10, 1233 | "range": 50, 1234 | "ops": [50, 40, 30, 20, 10] 1235 | 1236 | }, 1237 | PWR_FORTIFY: { 1238 | "className": POWER_CLASS["OPERATOR"], 1239 | "level": [0, 2, 7, 14, 22], 1240 | "cooldown": 5, 1241 | "range": 3, 1242 | "ops": 5, 1243 | "duration": [1, 2, 3, 4, 5] 1244 | }, 1245 | PWR_OPERATE_POWER: { 1246 | "className": POWER_CLASS["OPERATOR"], 1247 | "level": [10, 11, 12, 14, 22], 1248 | "cooldown": 800, 1249 | "range": 3, 1250 | "duration": 1000, 1251 | "ops": 200, 1252 | "effect": [1, 2, 3, 4, 5] 1253 | }, 1254 | PWR_OPERATE_CONTROLLER: { 1255 | "className": POWER_CLASS["OPERATOR"], 1256 | "level": [20, 21, 22, 23, 24], 1257 | "cooldown": 800, 1258 | "range": 3, 1259 | "duration": 1000, 1260 | "ops": 200, 1261 | "effect": [10, 20, 30, 40, 50] 1262 | }, 1263 | PWR_OPERATE_FACTORY: { 1264 | "className": POWER_CLASS["OPERATOR"], 1265 | "level": [0, 2, 7, 14, 22], 1266 | "cooldown": 800, 1267 | "range": 3, 1268 | "duration": 1000, 1269 | "ops": 100 1270 | }, 1271 | } 1272 | 1273 | # Sum constants 1274 | BODYPARTS_ALL = [ 1275 | MOVE, 1276 | WORK, 1277 | CARRY, 1278 | ATTACK, 1279 | RANGED_ATTACK, 1280 | TOUGH, 1281 | HEAL, 1282 | CLAIM, 1283 | ] 1284 | 1285 | RESOURCES_ALL = [ 1286 | RESOURCE_ENERGY, 1287 | RESOURCE_POWER, 1288 | 1289 | RESOURCE_HYDROGEN, 1290 | RESOURCE_OXYGEN, 1291 | RESOURCE_UTRIUM, 1292 | RESOURCE_KEANIUM, 1293 | RESOURCE_LEMERGIUM, 1294 | RESOURCE_ZYNTHIUM, 1295 | RESOURCE_CATALYST, 1296 | RESOURCE_GHODIUM, 1297 | 1298 | RESOURCE_HYDROXIDE, 1299 | RESOURCE_ZYNTHIUM_KEANITE, 1300 | RESOURCE_UTRIUM_LEMERGITE, 1301 | 1302 | RESOURCE_UTRIUM_HYDRIDE, 1303 | RESOURCE_UTRIUM_OXIDE, 1304 | RESOURCE_KEANIUM_HYDRIDE, 1305 | RESOURCE_KEANIUM_OXIDE, 1306 | RESOURCE_LEMERGIUM_HYDRIDE, 1307 | RESOURCE_LEMERGIUM_OXIDE, 1308 | RESOURCE_ZYNTHIUM_HYDRIDE, 1309 | RESOURCE_ZYNTHIUM_OXIDE, 1310 | RESOURCE_GHODIUM_HYDRIDE, 1311 | RESOURCE_GHODIUM_OXIDE, 1312 | 1313 | RESOURCE_UTRIUM_ACID, 1314 | RESOURCE_UTRIUM_ALKALIDE, 1315 | RESOURCE_KEANIUM_ACID, 1316 | RESOURCE_KEANIUM_ALKALIDE, 1317 | RESOURCE_LEMERGIUM_ACID, 1318 | RESOURCE_LEMERGIUM_ALKALIDE, 1319 | RESOURCE_ZYNTHIUM_ACID, 1320 | RESOURCE_ZYNTHIUM_ALKALIDE, 1321 | RESOURCE_GHODIUM_ACID, 1322 | RESOURCE_GHODIUM_ALKALIDE, 1323 | 1324 | RESOURCE_CATALYZED_UTRIUM_ACID, 1325 | RESOURCE_CATALYZED_UTRIUM_ALKALIDE, 1326 | RESOURCE_CATALYZED_KEANIUM_ACID, 1327 | RESOURCE_CATALYZED_KEANIUM_ALKALIDE, 1328 | RESOURCE_CATALYZED_LEMERGIUM_ACID, 1329 | RESOURCE_CATALYZED_LEMERGIUM_ALKALIDE, 1330 | RESOURCE_CATALYZED_ZYNTHIUM_ACID, 1331 | RESOURCE_CATALYZED_ZYNTHIUM_ALKALIDE, 1332 | RESOURCE_CATALYZED_GHODIUM_ACID, 1333 | RESOURCE_CATALYZED_GHODIUM_ALKALIDE, 1334 | 1335 | RESOURCE_OPS, 1336 | 1337 | RESOURCE_SILICON, 1338 | RESOURCE_METAL, 1339 | RESOURCE_BIOMASS, 1340 | RESOURCE_MIST, 1341 | 1342 | RESOURCE_UTRIUM_BAR, 1343 | RESOURCE_LEMERGIUM_BAR, 1344 | RESOURCE_ZYNTHIUM_BAR, 1345 | RESOURCE_KEANIUM_BAR, 1346 | RESOURCE_GHODIUM_MELT, 1347 | RESOURCE_OXIDANT, 1348 | RESOURCE_REDUCTANT, 1349 | RESOURCE_PURIFIER, 1350 | RESOURCE_BATTERY, 1351 | RESOURCE_COMPOSITE, 1352 | RESOURCE_CRYSTAL, 1353 | RESOURCE_LIQUID, 1354 | 1355 | RESOURCE_WIRE, 1356 | RESOURCE_SWITCH, 1357 | RESOURCE_TRANSISTOR, 1358 | RESOURCE_MICROCHIP, 1359 | RESOURCE_CIRCUIT, 1360 | RESOURCE_DEVICE, 1361 | 1362 | RESOURCE_CELL, 1363 | RESOURCE_PHLEGM, 1364 | RESOURCE_TISSUE, 1365 | RESOURCE_MUSCLE, 1366 | RESOURCE_ORGANOID, 1367 | RESOURCE_ORGANISM, 1368 | 1369 | RESOURCE_ALLOY, 1370 | RESOURCE_TUBE, 1371 | RESOURCE_FIXTURES, 1372 | RESOURCE_FRAME, 1373 | RESOURCE_HYDRAULICS, 1374 | RESOURCE_MACHINE, 1375 | 1376 | RESOURCE_CONDENSATE, 1377 | RESOURCE_CONCENTRATE, 1378 | RESOURCE_EXTRACT, 1379 | RESOURCE_SPIRIT, 1380 | RESOURCE_EMANATION, 1381 | RESOURCE_ESSENCE 1382 | ] 1383 | 1384 | COLORS_ALL = [ 1385 | COLOR_RED, 1386 | COLOR_PURPLE, 1387 | COLOR_BLUE, 1388 | COLOR_CYAN, 1389 | COLOR_GREEN, 1390 | COLOR_YELLOW, 1391 | COLOR_ORANGE, 1392 | COLOR_BROWN, 1393 | COLOR_GREY, 1394 | COLOR_WHITE, 1395 | ] 1396 | 1397 | INTERSHARD_RESOURCES = [ 1398 | SUBSCRIPTION_TOKEN 1399 | ] 1400 | 1401 | COMMODITIES = { 1402 | RESOURCE_UTRIUM_BAR: { 1403 | "amount": 100, 1404 | "cooldown": 20, 1405 | "components": { 1406 | RESOURCE_UTRIUM: 500, 1407 | RESOURCE_ENERGY: 200 1408 | } 1409 | }, 1410 | RESOURCE_UTRIUM: { 1411 | "amount": 500, 1412 | "cooldown": 20, 1413 | "components": { 1414 | RESOURCE_UTRIUM_BAR: 100, 1415 | RESOURCE_ENERGY: 200 1416 | } 1417 | }, 1418 | RESOURCE_LEMERGIUM_BAR: { 1419 | "amount": 100, 1420 | "cooldown": 20, 1421 | "components": { 1422 | RESOURCE_LEMERGIUM: 500, 1423 | RESOURCE_ENERGY: 200 1424 | } 1425 | }, 1426 | RESOURCE_LEMERGIUM: { 1427 | "amount": 500, 1428 | "cooldown": 20, 1429 | "components": { 1430 | RESOURCE_LEMERGIUM_BAR: 100, 1431 | RESOURCE_ENERGY: 200 1432 | } 1433 | }, 1434 | RESOURCE_ZYNTHIUM_BAR: { 1435 | "amount": 100, 1436 | "cooldown": 20, 1437 | "components": { 1438 | RESOURCE_ZYNTHIUM: 500, 1439 | RESOURCE_ENERGY: 200 1440 | } 1441 | }, 1442 | RESOURCE_ZYNTHIUM: { 1443 | "amount": 500, 1444 | "cooldown": 20, 1445 | "components": { 1446 | RESOURCE_ZYNTHIUM_BAR: 100, 1447 | RESOURCE_ENERGY: 200 1448 | } 1449 | }, 1450 | RESOURCE_KEANIUM_BAR: { 1451 | "amount": 100, 1452 | "cooldown": 20, 1453 | "components": { 1454 | RESOURCE_KEANIUM: 500, 1455 | RESOURCE_ENERGY: 200 1456 | } 1457 | }, 1458 | RESOURCE_KEANIUM: { 1459 | "amount": 500, 1460 | "cooldown": 20, 1461 | "components": { 1462 | RESOURCE_KEANIUM_BAR: 100, 1463 | RESOURCE_ENERGY: 200 1464 | } 1465 | }, 1466 | RESOURCE_GHODIUM_MELT: { 1467 | "amount": 100, 1468 | "cooldown": 20, 1469 | "components": { 1470 | RESOURCE_GHODIUM: 500, 1471 | RESOURCE_ENERGY: 200 1472 | } 1473 | }, 1474 | RESOURCE_GHODIUM: { 1475 | "amount": 500, 1476 | "cooldown": 20, 1477 | "components": { 1478 | RESOURCE_GHODIUM_MELT: 100, 1479 | RESOURCE_ENERGY: 200 1480 | } 1481 | }, 1482 | RESOURCE_OXIDANT: { 1483 | "amount": 100, 1484 | "cooldown": 20, 1485 | "components": { 1486 | RESOURCE_OXYGEN: 500, 1487 | RESOURCE_ENERGY: 200 1488 | } 1489 | }, 1490 | RESOURCE_OXYGEN: { 1491 | "amount": 500, 1492 | "cooldown": 20, 1493 | "components": { 1494 | RESOURCE_OXIDANT: 100, 1495 | RESOURCE_ENERGY: 200 1496 | } 1497 | }, 1498 | RESOURCE_REDUCTANT: { 1499 | "amount": 100, 1500 | "cooldown": 20, 1501 | "components": { 1502 | RESOURCE_HYDROGEN: 500, 1503 | RESOURCE_ENERGY: 200 1504 | } 1505 | }, 1506 | RESOURCE_HYDROGEN: { 1507 | "amount": 500, 1508 | "cooldown": 20, 1509 | "components": { 1510 | RESOURCE_REDUCTANT: 100, 1511 | RESOURCE_ENERGY: 200 1512 | } 1513 | }, 1514 | RESOURCE_PURIFIER: { 1515 | "amount": 100, 1516 | "cooldown": 20, 1517 | "components": { 1518 | RESOURCE_CATALYST: 500, 1519 | RESOURCE_ENERGY: 200 1520 | } 1521 | }, 1522 | RESOURCE_CATALYST: { 1523 | "amount": 500, 1524 | "cooldown": 20, 1525 | "components": { 1526 | RESOURCE_PURIFIER: 100, 1527 | RESOURCE_ENERGY: 200 1528 | } 1529 | }, 1530 | RESOURCE_BATTERY: { 1531 | "amount": 50, 1532 | "cooldown": 10, 1533 | "components": { 1534 | RESOURCE_ENERGY: 600 1535 | } 1536 | }, 1537 | RESOURCE_ENERGY: { 1538 | "amount": 500, 1539 | "cooldown": 10, 1540 | "components": { 1541 | RESOURCE_BATTERY: 50 1542 | } 1543 | }, 1544 | RESOURCE_COMPOSITE: { 1545 | "level": 1, 1546 | "amount": 20, 1547 | "cooldown": 50, 1548 | "components": { 1549 | RESOURCE_UTRIUM_BAR: 20, 1550 | RESOURCE_ZYNTHIUM_BAR: 20, 1551 | RESOURCE_ENERGY: 20 1552 | } 1553 | }, 1554 | RESOURCE_CRYSTAL: { 1555 | "level": 2, 1556 | "amount": 6, 1557 | "cooldown": 21, 1558 | "components": { 1559 | RESOURCE_LEMERGIUM_BAR: 6, 1560 | RESOURCE_KEANIUM_BAR: 6, 1561 | RESOURCE_PURIFIER: 6, 1562 | RESOURCE_ENERGY: 45 1563 | } 1564 | }, 1565 | RESOURCE_LIQUID: { 1566 | "level": 3, 1567 | "amount": 12, 1568 | "cooldown": 60, 1569 | "components": { 1570 | RESOURCE_OXIDANT: 12, 1571 | RESOURCE_REDUCTANT: 12, 1572 | RESOURCE_GHODIUM_MELT: 12, 1573 | RESOURCE_ENERGY: 90 1574 | } 1575 | }, 1576 | 1577 | RESOURCE_WIRE: { 1578 | "amount": 20, 1579 | "cooldown": 8, 1580 | "components": { 1581 | RESOURCE_UTRIUM_BAR: 20, 1582 | RESOURCE_SILICON: 100, 1583 | RESOURCE_ENERGY: 40 1584 | } 1585 | }, 1586 | RESOURCE_SWITCH: { 1587 | "level": 1, 1588 | "amount": 5, 1589 | "cooldown": 70, 1590 | "components": { 1591 | RESOURCE_WIRE: 40, 1592 | RESOURCE_OXIDANT: 95, 1593 | RESOURCE_UTRIUM_BAR: 35, 1594 | RESOURCE_ENERGY: 20 1595 | } 1596 | }, 1597 | RESOURCE_TRANSISTOR: { 1598 | "level": 2, 1599 | "amount": 1, 1600 | "cooldown": 59, 1601 | "components": { 1602 | RESOURCE_SWITCH: 4, 1603 | RESOURCE_WIRE: 15, 1604 | RESOURCE_REDUCTANT: 85, 1605 | RESOURCE_ENERGY: 8 1606 | } 1607 | }, 1608 | RESOURCE_MICROCHIP: { 1609 | "level": 3, 1610 | "amount": 1, 1611 | "cooldown": 250, 1612 | "components": { 1613 | RESOURCE_TRANSISTOR: 2, 1614 | RESOURCE_COMPOSITE: 50, 1615 | RESOURCE_WIRE: 117, 1616 | RESOURCE_PURIFIER: 25, 1617 | RESOURCE_ENERGY: 16 1618 | } 1619 | }, 1620 | RESOURCE_CIRCUIT: { 1621 | "level": 4, 1622 | "amount": 1, 1623 | "cooldown": 800, 1624 | "components": { 1625 | RESOURCE_MICROCHIP: 1, 1626 | RESOURCE_TRANSISTOR: 5, 1627 | RESOURCE_SWITCH: 4, 1628 | RESOURCE_OXIDANT: 115, 1629 | RESOURCE_ENERGY: 32 1630 | } 1631 | }, 1632 | RESOURCE_DEVICE: { 1633 | "level": 5, 1634 | "amount": 1, 1635 | "cooldown": 600, 1636 | "components": { 1637 | RESOURCE_CIRCUIT: 1, 1638 | RESOURCE_MICROCHIP: 3, 1639 | RESOURCE_CRYSTAL: 110, 1640 | RESOURCE_GHODIUM_MELT: 150, 1641 | RESOURCE_ENERGY: 64 1642 | } 1643 | }, 1644 | 1645 | RESOURCE_CELL: { 1646 | "amount": 20, 1647 | "cooldown": 8, 1648 | "components": { 1649 | RESOURCE_LEMERGIUM_BAR: 20, 1650 | RESOURCE_BIOMASS: 100, 1651 | RESOURCE_ENERGY: 40 1652 | } 1653 | }, 1654 | RESOURCE_PHLEGM: { 1655 | "level": 1, 1656 | "amount": 2, 1657 | "cooldown": 35, 1658 | "components": { 1659 | RESOURCE_CELL: 20, 1660 | RESOURCE_OXIDANT: 36, 1661 | RESOURCE_LEMERGIUM_BAR: 16, 1662 | RESOURCE_ENERGY: 8 1663 | } 1664 | }, 1665 | RESOURCE_TISSUE: { 1666 | "level": 2, 1667 | "amount": 2, 1668 | "cooldown": 164, 1669 | "components": { 1670 | RESOURCE_PHLEGM: 10, 1671 | RESOURCE_CELL: 10, 1672 | RESOURCE_REDUCTANT: 110, 1673 | RESOURCE_ENERGY: 16 1674 | } 1675 | }, 1676 | RESOURCE_MUSCLE: { 1677 | "level": 3, 1678 | "amount": 1, 1679 | "cooldown": 250, 1680 | "components": { 1681 | RESOURCE_TISSUE: 3, 1682 | RESOURCE_PHLEGM: 3, 1683 | RESOURCE_ZYNTHIUM_BAR: 50, 1684 | RESOURCE_REDUCTANT: 50, 1685 | RESOURCE_ENERGY: 16 1686 | } 1687 | }, 1688 | RESOURCE_ORGANOID: { 1689 | "level": 4, 1690 | "amount": 1, 1691 | "cooldown": 800, 1692 | "components": { 1693 | RESOURCE_MUSCLE: 1, 1694 | RESOURCE_TISSUE: 5, 1695 | RESOURCE_PURIFIER: 208, 1696 | RESOURCE_OXIDANT: 256, 1697 | RESOURCE_ENERGY: 32 1698 | } 1699 | }, 1700 | RESOURCE_ORGANISM: { 1701 | "level": 5, 1702 | "amount": 1, 1703 | "cooldown": 600, 1704 | "components": { 1705 | RESOURCE_ORGANOID: 1, 1706 | RESOURCE_LIQUID: 150, 1707 | RESOURCE_TISSUE: 6, 1708 | RESOURCE_CELL: 310, 1709 | RESOURCE_ENERGY: 64 1710 | } 1711 | }, 1712 | 1713 | RESOURCE_ALLOY: { 1714 | "amount": 20, 1715 | "cooldown": 8, 1716 | "components": { 1717 | RESOURCE_ZYNTHIUM_BAR: 20, 1718 | RESOURCE_METAL: 100, 1719 | RESOURCE_ENERGY: 40 1720 | } 1721 | }, 1722 | RESOURCE_TUBE: { 1723 | "level": 1, 1724 | "amount": 2, 1725 | "cooldown": 45, 1726 | "components": { 1727 | RESOURCE_ALLOY: 40, 1728 | RESOURCE_ZYNTHIUM_BAR: 16, 1729 | RESOURCE_ENERGY: 8 1730 | } 1731 | }, 1732 | RESOURCE_FIXTURES: { 1733 | "level": 2, 1734 | "amount": 1, 1735 | "cooldown": 115, 1736 | "components": { 1737 | RESOURCE_COMPOSITE: 20, 1738 | RESOURCE_ALLOY: 41, 1739 | RESOURCE_OXIDANT: 161, 1740 | RESOURCE_ENERGY: 8 1741 | } 1742 | }, 1743 | RESOURCE_FRAME: { 1744 | "level": 3, 1745 | "amount": 1, 1746 | "cooldown": 125, 1747 | "components": { 1748 | RESOURCE_FIXTURES: 2, 1749 | RESOURCE_TUBE: 4, 1750 | RESOURCE_REDUCTANT: 330, 1751 | RESOURCE_ZYNTHIUM_BAR: 31, 1752 | RESOURCE_ENERGY: 16 1753 | } 1754 | }, 1755 | RESOURCE_HYDRAULICS: { 1756 | "level": 4, 1757 | "amount": 1, 1758 | "cooldown": 800, 1759 | "components": { 1760 | RESOURCE_LIQUID: 150, 1761 | RESOURCE_FIXTURES: 3, 1762 | RESOURCE_TUBE: 15, 1763 | RESOURCE_PURIFIER: 208, 1764 | RESOURCE_ENERGY: 32 1765 | } 1766 | }, 1767 | RESOURCE_MACHINE: { 1768 | "level": 5, 1769 | "amount": 1, 1770 | "cooldown": 600, 1771 | "components": { 1772 | RESOURCE_HYDRAULICS: 1, 1773 | RESOURCE_FRAME: 2, 1774 | RESOURCE_FIXTURES: 3, 1775 | RESOURCE_TUBE: 12, 1776 | RESOURCE_ENERGY: 64 1777 | } 1778 | }, 1779 | 1780 | RESOURCE_CONDENSATE: { 1781 | "amount": 20, 1782 | "cooldown": 8, 1783 | "components": { 1784 | RESOURCE_KEANIUM_BAR: 20, 1785 | RESOURCE_MIST: 100, 1786 | RESOURCE_ENERGY: 40 1787 | } 1788 | }, 1789 | RESOURCE_CONCENTRATE: { 1790 | "level": 1, 1791 | "amount": 3, 1792 | "cooldown": 41, 1793 | "components": { 1794 | RESOURCE_CONDENSATE: 30, 1795 | RESOURCE_KEANIUM_BAR: 15, 1796 | RESOURCE_REDUCTANT: 54, 1797 | RESOURCE_ENERGY: 12 1798 | } 1799 | }, 1800 | RESOURCE_EXTRACT: { 1801 | "level": 2, 1802 | "amount": 2, 1803 | "cooldown": 128, 1804 | "components": { 1805 | RESOURCE_CONCENTRATE: 10, 1806 | RESOURCE_CONDENSATE: 30, 1807 | RESOURCE_OXIDANT: 60, 1808 | RESOURCE_ENERGY: 16 1809 | } 1810 | }, 1811 | RESOURCE_SPIRIT: { 1812 | "level": 3, 1813 | "amount": 1, 1814 | "cooldown": 200, 1815 | "components": { 1816 | RESOURCE_EXTRACT: 2, 1817 | RESOURCE_CONCENTRATE: 6, 1818 | RESOURCE_REDUCTANT: 90, 1819 | RESOURCE_PURIFIER: 20, 1820 | RESOURCE_ENERGY: 16 1821 | } 1822 | }, 1823 | RESOURCE_EMANATION: { 1824 | "level": 4, 1825 | "amount": 1, 1826 | "cooldown": 800, 1827 | "components": { 1828 | RESOURCE_SPIRIT: 2, 1829 | RESOURCE_EXTRACT: 2, 1830 | RESOURCE_CONCENTRATE: 3, 1831 | RESOURCE_KEANIUM_BAR: 112, 1832 | RESOURCE_ENERGY: 32 1833 | } 1834 | }, 1835 | RESOURCE_ESSENCE: { 1836 | "level": 5, 1837 | "amount": 1, 1838 | "cooldown": 600, 1839 | "components": { 1840 | RESOURCE_EMANATION: 1, 1841 | RESOURCE_SPIRIT: 3, 1842 | RESOURCE_CRYSTAL: 110, 1843 | RESOURCE_GHODIUM_MELT: 150, 1844 | RESOURCE_ENERGY: 64 1845 | } 1846 | }, 1847 | } 1848 | --------------------------------------------------------------------------------