diff --git a/types/screeps/index.d.ts b/types/screeps/index.d.ts index 06c2d76c6a..42b7d8a696 100644 --- a/types/screeps/index.d.ts +++ b/types/screeps/index.d.ts @@ -82,21 +82,21 @@ declare const CREEP_CLAIM_LIFE_TIME: 600; declare const CREEP_CORPSE_RATE: 0.2; declare const OBSTACLE_OBJECT_TYPES: [ - "spawn", - "creep", - "wall", - "source", - "constructedWall", - "extension", - "link", - "storage", - "tower", - "observer", - "powerSpawn", - "powerBank", - "lab", - "terminal", - "nuker" + "spawn", + "creep", + "wall", + "source", + "constructedWall", + "extension", + "link", + "storage", + "tower", + "observer", + "powerSpawn", + "powerBank", + "lab", + "terminal", + "nuker" ]; declare const ENERGY_REGEN_TIME: 300; @@ -108,14 +108,14 @@ declare const RAMPART_DECAY_AMOUNT: 300; declare const RAMPART_DECAY_TIME: 100; declare const RAMPART_HITS: 1; declare const RAMPART_HITS_MAX: { - [rcl: number]: number - 2: 300000, - 3: 1000000, - 4: 3000000, - 5: 10000000, - 6: 30000000, - 7: 100000000, - 8: 300000000 + [rcl: number]: number; + 2: 300000; + 3: 1000000; + 4: 3000000; + 5: 10000000; + 6: 30000000; + 7: 100000000; + 8: 300000000; }; declare const SPAWN_HITS: 5000; @@ -131,16 +131,16 @@ declare const WALL_HITS_MAX: 300000000; declare const EXTENSION_HITS: 1000; declare const EXTENSION_ENERGY_CAPACITY: { - [rcl: number]: number - 0: 50, - 1: 50, - 2: 50, - 3: 50, - 4: 50, - 5: 50, - 6: 50, - 7: 100, - 8: 200 + [rcl: number]: number; + 0: 50; + 1: 50; + 2: 50; + 3: 50; + 4: 50; + 5: 50; + 6: 50; + 7: 100; + 8: 200; }; declare const ROAD_HITS: 5000; @@ -254,10 +254,10 @@ declare const RESOURCES_ALL: ResourceConstant[]; declare const SUBSCRIPTION_TOKEN: "token"; -declare const CONTROLLER_LEVELS: {[level: number]: number}; -declare const CONTROLLER_STRUCTURES: Record; +declare const CONTROLLER_LEVELS: { [level: number]: number }; +declare const CONTROLLER_STRUCTURES: Record; -declare const CONTROLLER_DOWNGRADE: {[level: number]: number}; +declare const CONTROLLER_DOWNGRADE: { [level: number]: number }; declare const CONTROLLER_DOWNGRADE_RESTORE: number; declare const CONTROLLER_DOWNGRADE_SAFEMODE_THRESHOLD: number; declare const CONTROLLER_CLAIM_DOWNGRADE: number; @@ -328,19 +328,19 @@ declare const MINERAL_MIN_AMOUNT: Record; declare const MINERAL_RANDOM_FACTOR: number; declare const MINERAL_DENSITY: { - [level: number]: number - 1: number, - 2: number, - 3: number, - 4: number + [level: number]: number; + 1: number; + 2: number; + 3: number; + 4: number; }; declare const MINERAL_DENSITY_PROBABILITY: { - [level: number]: number - 1: number, - 2: number, - 3: number, - 4: number + [level: number]: number; + 1: number; + 2: number; + 3: number; + 4: number; }; declare const MINERAL_DENSITY_CHANGE: number; @@ -369,261 +369,261 @@ declare const NUKER_GHODIUM_CAPACITY: number; declare const NUKE_LAND_TIME: number; declare const NUKE_RANGE: number; declare const NUKE_DAMAGE: { - [range: number]: number - 0: number, - 1: number, - 4: number + [range: number]: number; + 0: number; + 1: number; + 4: number; }; declare const REACTIONS: { - [resource: string]: {[resource: string]: string} - H: { - O: "OH", - L: "LH", - K: "KH", - U: "UH", - Z: "ZH", - G: "GH" - }, - O: { - H: "OH", - L: "LO", - K: "KO", - U: "UO", - Z: "ZO", - G: "GO" - }, - Z: { - K: "ZK", - H: "ZH", - O: "ZO" - }, - L: { - U: "UL", - H: "LH", - O: "LO" - }, - K: { - Z: "ZK", - H: "KH", - O: "KO" - }, - G: { - H: "GH", - O: "GO" - }, - U: { - L: "UL", - H: "UH", - O: "UO" - }, - OH: { - UH: "UH2O", - UO: "UHO2", - ZH: "ZH2O", - ZO: "ZHO2", - KH: "KH2O", - KO: "KHO2", - LH: "LH2O", - LO: "LHO2", - GH: "GH2O", - GO: "GHO2" - }, - X: { - UH2O: "XUH2O", - UHO2: "XUHO2", - LH2O: "XLH2O", - LHO2: "XLHO2", - KH2O: "XKH2O", - KHO2: "XKHO2", - ZH2O: "XZH2O", - ZHO2: "XZHO2", - GH2O: "XGH2O", - GHO2: "XGHO2" - }, - ZK: { - UL: "G" - }, - UL: { - ZK: "G" - }, - LH: { - OH: "LH2O" - }, - ZH: { - OH: "ZH2O" - }, - GH: { - OH: "GH2O" - }, - KH: { - OH: "KH2O" - }, - UH: { - OH: "UH2O" - }, - LO: { - OH: "LHO2" - }, - ZO: { - OH: "ZHO2" - }, - KO: { - OH: "KHO2" - }, - UO: { - OH: "UHO2" - }, - GO: { - OH: "GHO2" - }, - LH2O: { - X: "XLH2O" - }, - KH2O: { - X: "XKH2O" - }, - ZH2O: { - X: "XZH2O" - }, - UH2O: { - X: "XUH2O" - }, - GH2O: { - X: "XGH2O" - }, - LHO2: { - X: "XLHO2" - }, - UHO2: { - X: "XUHO2" - }, - KHO2: { - X: "XKHO2" - }, - ZHO2: { - X: "XZHO2" - }, - GHO2: { - X: "XGHO2" - } + [resource: string]: { [resource: string]: string }; + H: { + O: "OH"; + L: "LH"; + K: "KH"; + U: "UH"; + Z: "ZH"; + G: "GH"; + }; + O: { + H: "OH"; + L: "LO"; + K: "KO"; + U: "UO"; + Z: "ZO"; + G: "GO"; + }; + Z: { + K: "ZK"; + H: "ZH"; + O: "ZO"; + }; + L: { + U: "UL"; + H: "LH"; + O: "LO"; + }; + K: { + Z: "ZK"; + H: "KH"; + O: "KO"; + }; + G: { + H: "GH"; + O: "GO"; + }; + U: { + L: "UL"; + H: "UH"; + O: "UO"; + }; + OH: { + UH: "UH2O"; + UO: "UHO2"; + ZH: "ZH2O"; + ZO: "ZHO2"; + KH: "KH2O"; + KO: "KHO2"; + LH: "LH2O"; + LO: "LHO2"; + GH: "GH2O"; + GO: "GHO2"; + }; + X: { + UH2O: "XUH2O"; + UHO2: "XUHO2"; + LH2O: "XLH2O"; + LHO2: "XLHO2"; + KH2O: "XKH2O"; + KHO2: "XKHO2"; + ZH2O: "XZH2O"; + ZHO2: "XZHO2"; + GH2O: "XGH2O"; + GHO2: "XGHO2"; + }; + ZK: { + UL: "G"; + }; + UL: { + ZK: "G"; + }; + LH: { + OH: "LH2O"; + }; + ZH: { + OH: "ZH2O"; + }; + GH: { + OH: "GH2O"; + }; + KH: { + OH: "KH2O"; + }; + UH: { + OH: "UH2O"; + }; + LO: { + OH: "LHO2"; + }; + ZO: { + OH: "ZHO2"; + }; + KO: { + OH: "KHO2"; + }; + UO: { + OH: "UHO2"; + }; + GO: { + OH: "GHO2"; + }; + LH2O: { + X: "XLH2O"; + }; + KH2O: { + X: "XKH2O"; + }; + ZH2O: { + X: "XZH2O"; + }; + UH2O: { + X: "XUH2O"; + }; + GH2O: { + X: "XGH2O"; + }; + LHO2: { + X: "XLHO2"; + }; + UHO2: { + X: "XUHO2"; + }; + KHO2: { + X: "XKHO2"; + }; + ZHO2: { + X: "XZHO2"; + }; + GHO2: { + X: "XGHO2"; + }; }; declare const BOOSTS: { - [part: string]: {[boost: string]: {[action: string]: number}} - work: { - UO: { - harvest: 3 - }, - UHO2: { - harvest: 5 - }, - XUHO2: { - harvest: 7 - }, - LH: { - build: 1.5, - repair: 1.5 - }, - LH2O: { - build: 1.8, - repair: 1.8 - }, - XLH2O: { - build: 2, - repair: 2 - }, - ZH: { - dismantle: 2 - }, - ZH2O: { - dismantle: 3 - }, - XZH2O: { - dismantle: 4 - }, - GH: { - upgradeController: 1.5 - }, - GH2O: { - upgradeController: 1.8 - }, - XGH2O: { - upgradeController: 2 - } - }, - attack: { - UH: { - attack: 2 - }, - UH2O: { - attack: 3 - }, - XUH2O: { - attack: 4 - } - }, - ranged_attack: { - KO: { - rangedAttack: 2, - rangedMassAttack: 2 - }, - KHO2: { - rangedAttack: 3, - rangedMassAttack: 3 - }, - XKHO2: { - rangedAttack: 4, - rangedMassAttack: 4 - } - }, - heal: { - LO: { - heal: 2, - rangedHeal: 2 - }, - LHO2: { - heal: 3, - rangedHeal: 3 - }, - XLHO2: { - heal: 4, - rangedHeal: 4 - } - }, - carry: { - KH: { - capacity: 2 - }, - KH2O: { - capacity: 3 - }, - XKH2O: { - capacity: 4 - } - }, - move: { - ZO: { - fatigue: 2 - }, - ZHO2: { - fatigue: 3 - }, - XZHO2: { - fatigue: 4 - } - }, - tough: { - GO: { - damage: .7 - }, - GHO2: { - damage: .5 - }, - XGHO2: { - damage: .3 - } - } + [part: string]: { [boost: string]: { [action: string]: number } }; + work: { + UO: { + harvest: 3; + }; + UHO2: { + harvest: 5; + }; + XUHO2: { + harvest: 7; + }; + LH: { + build: 1.5; + repair: 1.5; + }; + LH2O: { + build: 1.8; + repair: 1.8; + }; + XLH2O: { + build: 2; + repair: 2; + }; + ZH: { + dismantle: 2; + }; + ZH2O: { + dismantle: 3; + }; + XZH2O: { + dismantle: 4; + }; + GH: { + upgradeController: 1.5; + }; + GH2O: { + upgradeController: 1.8; + }; + XGH2O: { + upgradeController: 2; + }; + }; + attack: { + UH: { + attack: 2; + }; + UH2O: { + attack: 3; + }; + XUH2O: { + attack: 4; + }; + }; + ranged_attack: { + KO: { + rangedAttack: 2; + rangedMassAttack: 2; + }; + KHO2: { + rangedAttack: 3; + rangedMassAttack: 3; + }; + XKHO2: { + rangedAttack: 4; + rangedMassAttack: 4; + }; + }; + heal: { + LO: { + heal: 2; + rangedHeal: 2; + }; + LHO2: { + heal: 3; + rangedHeal: 3; + }; + XLHO2: { + heal: 4; + rangedHeal: 4; + }; + }; + carry: { + KH: { + capacity: 2; + }; + KH2O: { + capacity: 3; + }; + XKH2O: { + capacity: 4; + }; + }; + move: { + ZO: { + fatigue: 2; + }; + ZHO2: { + fatigue: 3; + }; + XZHO2: { + fatigue: 4; + }; + }; + tough: { + GO: { + damage: 0.7; + }; + GHO2: { + damage: 0.5; + }; + XGHO2: { + damage: 0.3; + }; + }; }; declare const LOOK_CREEPS: "creep"; @@ -636,7 +636,7 @@ declare const LOOK_FLAGS: "flag"; declare const LOOK_CONSTRUCTION_SITES: "constructionSite"; declare const LOOK_NUKES: "nuke"; declare const LOOK_TERRAIN: "terrain"; -declare const LOOK_TOMBSTONES: 'tombstone'; +declare const LOOK_TOMBSTONES: "tombstone"; declare const ORDER_SELL: "sell"; declare const ORDER_BUY: "buy"; @@ -648,10 +648,25 @@ declare const SYSTEM_USERNAME: string; declare const TOMBSTONE_DECAY_PER_PART: 5; declare const EVENT_ATTACK: 1; -declare const EVENT_HEAL: 6; +declare const EVENT_OBJECT_DESTROYED: 2; +declare const EVENT_ATTACK_CONTROLLER: 3; +declare const EVENT_BUILD: 4; declare const EVENT_HARVEST: 5; +declare const EVENT_HEAL: 6; declare const EVENT_REPAIR: 7; +declare const EVENT_RESERVE_CONTROLLER: 8; declare const EVENT_UPGRADE_CONTROLLER: 9; +declare const EVENT_EXIT: 10; + +declare const EVENT_ATTACK_TYPE_MELEE: 1; +declare const EVENT_ATTACK_TYPE_RANGED: 2; +declare const EVENT_ATTACK_TYPE_RANGED_MASS: 3; +declare const EVENT_ATTACK_TYPE_DISMANTLE: 4; +declare const EVENT_ATTACK_TYPE_HIT_BACK: 5; +declare const EVENT_ATTACK_TYPE_NUKE: 6; + +declare const EVENT_HEAL_TYPE_MELEE: 1; +declare const EVENT_HEAL_TYPE_RANGED: 2; /** * A site of a structure which is currently under construction. */ @@ -688,8 +703,7 @@ interface ConstructionSite, _ConstructorById { -} +interface ConstructionSiteConstructor extends _Constructor, _ConstructorById {} declare const ConstructionSite: ConstructionSiteConstructor; /** @@ -773,7 +787,7 @@ interface Creep extends RoomObject { * * @returns Result Code: OK, ERR_NOT_OWNER, ERR_BUSY, ERR_INVALID_TARGET, ERR_NOT_IN_RANGE, ERR_NO_BODYPART */ - attack(target: Creep|Structure): CreepActionReturnCode; + attack(target: Creep | Structure): CreepActionReturnCode; /** * Decreases the controller's downgrade or reservation timer for 1 tick per * every 5 `CLAIM` body parts (so the creep must have at least 5x`CLAIM`). @@ -887,7 +901,10 @@ interface Creep extends RoomObject { * @param target Can be a RoomPosition object or any object containing RoomPosition. * @param opts An object containing pathfinding options flags (see Room.findPath for more info) or one of the following: reusePath, serializeMemory, noPathFinding */ - moveTo(target: RoomPosition|{pos: RoomPosition}, opts?: MoveToOpts): CreepMoveReturnCode | ERR_NO_PATH | ERR_INVALID_TARGET | ERR_NOT_FOUND; + moveTo( + target: RoomPosition | { pos: RoomPosition }, + opts?: MoveToOpts, + ): CreepMoveReturnCode | ERR_NO_PATH | ERR_INVALID_TARGET | ERR_NOT_FOUND; /** * Toggle auto notification when the creep is under attack. The notification will be sent to your account email. Turned on by default. * @param enabled Whether to enable notification or disable. @@ -906,7 +923,7 @@ interface Creep extends RoomObject { * The target has to be within 3 squares range of the creep. * @param target The target object to be attacked. */ - rangedAttack(target: Creep|Structure): CreepActionReturnCode; + rangedAttack(target: Creep | Structure): CreepActionReturnCode; /** * Heal another creep at a distance. * @@ -969,7 +986,7 @@ interface Creep extends RoomObject { * @param resourceType One of the RESOURCE_* constants * @param amount The amount of resources to be transferred. If omitted, all the available carried amount is used. */ - transfer(target: Creep|Structure, resourceType: ResourceConstant, amount?: number): ScreepsReturnCode; + transfer(target: Creep | Structure, resourceType: ResourceConstant, amount?: number): ScreepsReturnCode; /** * Upgrade your controller to the next level using carried energy. * @@ -1000,8 +1017,7 @@ interface Creep extends RoomObject { withdraw(target: Structure | Tombstone, resourceType: ResourceConstant, amount?: number): ScreepsReturnCode; } -interface CreepConstructor extends _Constructor, _ConstructorById { -} +interface CreepConstructor extends _Constructor, _ConstructorById {} declare const Creep: CreepConstructor; /** @@ -1054,7 +1070,7 @@ interface Flag extends RoomObject { * @param pos Can be a RoomPosition object or any object containing RoomPosition. * @returns Result Code: OK, ERR_INVALID_TARGET */ - setPosition(pos: RoomPosition|{pos: RoomPosition}): OK | ERR_INVALID_ARGS; + setPosition(pos: RoomPosition | { pos: RoomPosition }): OK | ERR_INVALID_ARGS; } interface FlagConstructor extends _Constructor { @@ -1074,11 +1090,11 @@ interface Game { /** * A hash containing all your creeps with creep names as hash keys. */ - creeps: {[creepName: string]: Creep}; + creeps: { [creepName: string]: Creep }; /** * A hash containing all your flags with flag names as hash keys. */ - flags: {[flagName: string]: Flag}; + flags: { [flagName: string]: Flag }; /** * Your Global Control Level. */ @@ -1094,25 +1110,25 @@ interface Game { /** * An object with your global resources that are bound to the account, like subscription tokens. Each object key is a resource constant, values are resources amounts. */ - resources: {[key: string]: any}; + resources: { [key: string]: any }; /** * A hash containing all the rooms available to you with room names as hash keys. * A room is visible if you have a creep or an owned structure in it. */ - rooms: {[roomName: string]: Room}; + rooms: { [roomName: string]: Room }; /** * A hash containing all your spawns with spawn names as hash keys. */ - spawns: {[spawnName: string]: StructureSpawn}; + spawns: { [spawnName: string]: StructureSpawn }; /** * A hash containing all your structures with structure id as hash keys. */ - structures: {[structureId: string]: Structure}; + structures: { [structureId: string]: Structure }; /** * A hash containing all your construction sites with their id as hash keys. */ - constructionSites: {[constructionSiteId: string]: ConstructionSite}; + constructionSites: { [constructionSiteId: string]: ConstructionSite }; /** * An object describing the world shard where your script is currently being executed in. @@ -1225,16 +1241,16 @@ interface CPU { } interface HeapStatistics { - total_heap_size: number; - total_heap_size_executable: number; - total_physical_size: number; - total_available_size: number; - used_heap_size: number; - heap_size_limit: number; - malloced_memory: number; - peak_malloced_memory: number; - does_zap_garbage: 0 | 1; - externally_allocated_size: number; + total_heap_size: number; + total_heap_size_executable: number; + total_physical_size: number; + total_available_size: number; + used_heap_size: number; + heap_size_limit: number; + malloced_memory: number; + peak_malloced_memory: number; + does_zap_garbage: 0 | 1; + externally_allocated_size: number; } /** @@ -1289,7 +1305,7 @@ interface AllLookAtTypes { constructionSite: ConstructionSite; creep: Creep; energy: Resource; - exit: any; // TODO what type is this? + exit: any; // TODO what type is this? flag: Flag; mineral: Mineral; nuke: Nuke; @@ -1305,8 +1321,8 @@ type LookAtTypes = Partial; type LookAtResult = Pick & { type: K }; type LookAtResultWithPos = LookAtResult & { - x: number, - y: number, + x: number; + y: number; }; interface LookAtResultMatrix { @@ -1321,39 +1337,37 @@ interface LookForAtAreaResultMatrix = {type: K} & { - [P in K]: T; -}; +type LookForAtAreaResult = { type: K } & { [P in K]: T }; -type LookForAtAreaResultWithPos = LookForAtAreaResult & {x: number, y: number}; +type LookForAtAreaResultWithPos = LookForAtAreaResult & { x: number; y: number }; type LookForAtAreaResultArray = Array>; interface FindTypes { - [key: number]: RoomPosition | Creep | Source | Resource | Structure | Flag | ConstructionSite | Mineral | Nuke | Tombstone; - 1: RoomPosition; // FIND_EXIT_TOP - 3: RoomPosition; // FIND_EXIT_RIGHT - 5: RoomPosition; // FIND_EXIT_BOTTOM - 7: RoomPosition; // FIND_EXIT_LEFT - 10: RoomPosition; // FIND_EXIT - 101: Creep; // FIND_CREEPS - 102: Creep; // FIND_MY_CREEPS - 103: Creep; // FIND_HOSTILE_CREEPS - 104: Source; // FIND_SOURCES_ACTIVE - 105: Source; // FIND_SOURCES - 106: Resource; // FIND_DROPPED_RESOURCES - 107: AnyStructure; // FIND_STRUCTURES - 108: AnyOwnedStructure; // FIND_MY_STRUCTURES - 109: AnyOwnedStructure; // FIND_HOSTILE_STRUCTURES - 110: Flag; // FIND_FLAGS - 111: ConstructionSite; // FIND_CONSTRUCTION_SITES - 112: StructureSpawn; // FIND_MY_SPAWNS - 113: StructureSpawn; // FIND_HOSTILE_SPAWNS - 114: ConstructionSite; // FIND_MY_CONSTRUCTION_SITES - 115: ConstructionSite; // FIND_HOSTILE_CONSTRUCTION_SITES - 116: Mineral; // FIND_MINERALS - 117: Nuke; // FIND_NUKES - 118: Tombstone; // FIND_TOMBSTONES + [key: number]: RoomPosition | Creep | Source | Resource | Structure | Flag | ConstructionSite | Mineral | Nuke | Tombstone; + 1: RoomPosition; // FIND_EXIT_TOP + 3: RoomPosition; // FIND_EXIT_RIGHT + 5: RoomPosition; // FIND_EXIT_BOTTOM + 7: RoomPosition; // FIND_EXIT_LEFT + 10: RoomPosition; // FIND_EXIT + 101: Creep; // FIND_CREEPS + 102: Creep; // FIND_MY_CREEPS + 103: Creep; // FIND_HOSTILE_CREEPS + 104: Source; // FIND_SOURCES_ACTIVE + 105: Source; // FIND_SOURCES + 106: Resource; // FIND_DROPPED_RESOURCES + 107: AnyStructure; // FIND_STRUCTURES + 108: AnyOwnedStructure; // FIND_MY_STRUCTURES + 109: AnyOwnedStructure; // FIND_HOSTILE_STRUCTURES + 110: Flag; // FIND_FLAGS + 111: ConstructionSite; // FIND_CONSTRUCTION_SITES + 112: StructureSpawn; // FIND_MY_SPAWNS + 113: StructureSpawn; // FIND_HOSTILE_SPAWNS + 114: ConstructionSite; // FIND_MY_CONSTRUCTION_SITES + 115: ConstructionSite; // FIND_HOSTILE_CONSTRUCTION_SITES + 116: Mineral; // FIND_MINERALS + 117: Nuke; // FIND_NUKES + 118: Tombstone; // FIND_TOMBSTONES } interface FindPathOpts { @@ -1502,23 +1516,23 @@ type ExitKey = "1" | "3" | "5" | "7"; // Return Codes type ScreepsReturnCode = - OK | - ERR_NOT_OWNER | - ERR_NO_PATH | - ERR_BUSY | - ERR_NAME_EXISTS | - ERR_NOT_FOUND | - ERR_NOT_ENOUGH_RESOURCES | - ERR_NOT_ENOUGH_ENERGY | - ERR_INVALID_TARGET | - ERR_FULL | - ERR_NOT_IN_RANGE | - ERR_INVALID_ARGS | - ERR_TIRED | - ERR_NO_BODYPART | - ERR_NOT_ENOUGH_EXTENSIONS | - ERR_RCL_NOT_ENOUGH | - ERR_GCL_NOT_ENOUGH; + | OK + | ERR_NOT_OWNER + | ERR_NO_PATH + | ERR_BUSY + | ERR_NAME_EXISTS + | ERR_NOT_FOUND + | ERR_NOT_ENOUGH_RESOURCES + | ERR_NOT_ENOUGH_ENERGY + | ERR_INVALID_TARGET + | ERR_FULL + | ERR_NOT_IN_RANGE + | ERR_INVALID_ARGS + | ERR_TIRED + | ERR_NO_BODYPART + | ERR_NOT_ENOUGH_EXTENSIONS + | ERR_RCL_NOT_ENOUGH + | ERR_GCL_NOT_ENOUGH; type OK = 0; type ERR_NOT_OWNER = -1; @@ -1538,54 +1552,38 @@ type ERR_NOT_ENOUGH_EXTENSIONS = -6; type ERR_RCL_NOT_ENOUGH = -14; type ERR_GCL_NOT_ENOUGH = -15; -type CreepActionReturnCode = - OK | - ERR_NOT_OWNER | - ERR_BUSY | - ERR_INVALID_TARGET | - ERR_NOT_IN_RANGE | - ERR_NO_BODYPART | - ERR_TIRED; +type CreepActionReturnCode = OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_NO_BODYPART | ERR_TIRED; -type CreepMoveReturnCode = - OK | - ERR_NOT_OWNER | - ERR_BUSY | - ERR_TIRED | - ERR_NO_BODYPART; +type CreepMoveReturnCode = OK | ERR_NOT_OWNER | ERR_BUSY | ERR_TIRED | ERR_NO_BODYPART; // Find Constants -type ExitConstant = - FIND_EXIT_TOP | - FIND_EXIT_RIGHT | - FIND_EXIT_BOTTOM | - FIND_EXIT_LEFT; +type ExitConstant = FIND_EXIT_TOP | FIND_EXIT_RIGHT | FIND_EXIT_BOTTOM | FIND_EXIT_LEFT; type FindConstant = - FIND_EXIT_TOP | - FIND_EXIT_RIGHT | - FIND_EXIT_BOTTOM | - FIND_EXIT_LEFT | - FIND_EXIT | - FIND_CREEPS | - FIND_MY_CREEPS | - FIND_HOSTILE_CREEPS | - FIND_SOURCES_ACTIVE | - FIND_SOURCES | - FIND_DROPPED_RESOURCES | - FIND_STRUCTURES | - FIND_MY_STRUCTURES | - FIND_HOSTILE_STRUCTURES | - FIND_FLAGS | - FIND_CONSTRUCTION_SITES | - FIND_MY_SPAWNS | - FIND_HOSTILE_SPAWNS | - FIND_MY_CONSTRUCTION_SITES | - FIND_HOSTILE_CONSTRUCTION_SITES | - FIND_MINERALS | - FIND_NUKES | - FIND_TOMBSTONES; + | FIND_EXIT_TOP + | FIND_EXIT_RIGHT + | FIND_EXIT_BOTTOM + | FIND_EXIT_LEFT + | FIND_EXIT + | FIND_CREEPS + | FIND_MY_CREEPS + | FIND_HOSTILE_CREEPS + | FIND_SOURCES_ACTIVE + | FIND_SOURCES + | FIND_DROPPED_RESOURCES + | FIND_STRUCTURES + | FIND_MY_STRUCTURES + | FIND_HOSTILE_STRUCTURES + | FIND_FLAGS + | FIND_CONSTRUCTION_SITES + | FIND_MY_SPAWNS + | FIND_HOSTILE_SPAWNS + | FIND_MY_CONSTRUCTION_SITES + | FIND_HOSTILE_CONSTRUCTION_SITES + | FIND_MINERALS + | FIND_NUKES + | FIND_TOMBSTONES; type FIND_EXIT_TOP = 1; type FIND_EXIT_RIGHT = 3; @@ -1614,21 +1612,17 @@ type FIND_TOMBSTONES = 118; // Filter Options -interface FilterOptions { filter: FilterFunction | FilterObject | string; } +interface FilterOptions { + filter: FilterFunction | FilterObject | string; +} type FilterFunction = (object: FindTypes[T]) => boolean; -interface FilterObject { [key: string]: any; } +interface FilterObject { + [key: string]: any; +} // Body Part Constants -type BodyPartConstant = - MOVE | - WORK | - CARRY | - ATTACK | - RANGED_ATTACK | - TOUGH | - HEAL | - CLAIM; +type BodyPartConstant = MOVE | WORK | CARRY | ATTACK | RANGED_ATTACK | TOUGH | HEAL | CLAIM; type MOVE = "move"; type WORK = "work"; @@ -1642,17 +1636,17 @@ type CLAIM = "claim"; // Look Constants type LookConstant = - LOOK_CREEPS | - LOOK_ENERGY | - LOOK_RESOURCES | - LOOK_SOURCES | - LOOK_MINERALS | - LOOK_STRUCTURES | - LOOK_FLAGS | - LOOK_CONSTRUCTION_SITES | - LOOK_NUKES | - LOOK_TERRAIN | - LOOK_TOMBSTONES; + | LOOK_CREEPS + | LOOK_ENERGY + | LOOK_RESOURCES + | LOOK_SOURCES + | LOOK_MINERALS + | LOOK_STRUCTURES + | LOOK_FLAGS + | LOOK_CONSTRUCTION_SITES + | LOOK_NUKES + | LOOK_TERRAIN + | LOOK_TOMBSTONES; type LOOK_CONSTRUCTION_SITES = "constructionSite"; type LOOK_CREEPS = "creep"; @@ -1668,15 +1662,7 @@ type LOOK_TOMBSTONES = "tombstone"; // Direction Constants -type DirectionConstant = - TOP | - TOP_RIGHT | - RIGHT | - BOTTOM_RIGHT | - BOTTOM | - BOTTOM_LEFT | - LEFT | - TOP_LEFT; +type DirectionConstant = TOP | TOP_RIGHT | RIGHT | BOTTOM_RIGHT | BOTTOM | BOTTOM_LEFT | LEFT | TOP_LEFT; type TOP = 1; type TOP_RIGHT = 2; @@ -1690,16 +1676,16 @@ type TOP_LEFT = 8; // Color Constants type ColorConstant = - COLOR_RED | - COLOR_PURPLE | - COLOR_BLUE | - COLOR_CYAN | - COLOR_GREEN | - COLOR_YELLOW | - COLOR_ORANGE | - COLOR_BROWN | - COLOR_GREY | - COLOR_WHITE; + | COLOR_RED + | COLOR_PURPLE + | COLOR_BLUE + | COLOR_CYAN + | COLOR_GREEN + | COLOR_YELLOW + | COLOR_ORANGE + | COLOR_BROWN + | COLOR_GREY + | COLOR_WHITE; type COLOR_RED = 1; type COLOR_PURPLE = 2; @@ -1715,28 +1701,28 @@ type COLOR_WHITE = 10; // Structure Constants type BuildableStructureConstant = - STRUCTURE_EXTENSION | - STRUCTURE_RAMPART | - STRUCTURE_ROAD | - STRUCTURE_SPAWN | - STRUCTURE_LINK | - STRUCTURE_WALL | - STRUCTURE_STORAGE | - STRUCTURE_TOWER | - STRUCTURE_OBSERVER | - STRUCTURE_POWER_SPAWN | - STRUCTURE_EXTRACTOR | - STRUCTURE_LAB | - STRUCTURE_TERMINAL | - STRUCTURE_CONTAINER | - STRUCTURE_NUKER; + | STRUCTURE_EXTENSION + | STRUCTURE_RAMPART + | STRUCTURE_ROAD + | STRUCTURE_SPAWN + | STRUCTURE_LINK + | STRUCTURE_WALL + | STRUCTURE_STORAGE + | STRUCTURE_TOWER + | STRUCTURE_OBSERVER + | STRUCTURE_POWER_SPAWN + | STRUCTURE_EXTRACTOR + | STRUCTURE_LAB + | STRUCTURE_TERMINAL + | STRUCTURE_CONTAINER + | STRUCTURE_NUKER; type StructureConstant = - BuildableStructureConstant | - STRUCTURE_KEEPER_LAIR | - STRUCTURE_CONTROLLER | - STRUCTURE_POWER_BANK | - STRUCTURE_PORTAL; + | BuildableStructureConstant + | STRUCTURE_KEEPER_LAIR + | STRUCTURE_CONTROLLER + | STRUCTURE_POWER_BANK + | STRUCTURE_PORTAL; type STRUCTURE_EXTENSION = "extension"; type STRUCTURE_RAMPART = "rampart"; @@ -1761,107 +1747,105 @@ type STRUCTURE_PORTAL = "portal"; // Resource Constants type ResourceConstant = - RESOURCE_ENERGY | - RESOURCE_POWER | - RESOURCE_UTRIUM | - RESOURCE_LEMERGIUM | - RESOURCE_KEANIUM | - RESOURCE_GHODIUM | - RESOURCE_ZYNTHIUM | - RESOURCE_OXYGEN | - RESOURCE_HYDROGEN | - RESOURCE_CATALYST | - RESOURCE_HYDROXIDE | - RESOURCE_ZYNTHIUM_KEANITE | - RESOURCE_UTRIUM_LEMERGITE | - RESOURCE_UTRIUM_HYDRIDE | - RESOURCE_UTRIUM_OXIDE | - RESOURCE_KEANIUM_HYDRIDE | - RESOURCE_KEANIUM_OXIDE | - RESOURCE_LEMERGIUM_HYDRIDE | - RESOURCE_LEMERGIUM_OXIDE | - RESOURCE_ZYNTHIUM_HYDRIDE | - RESOURCE_ZYNTHIUM_OXIDE | - RESOURCE_GHODIUM_HYDRIDE | - RESOURCE_GHODIUM_OXIDE | - RESOURCE_UTRIUM_ACID | - RESOURCE_UTRIUM_ALKALIDE | - RESOURCE_KEANIUM_ACID | - RESOURCE_KEANIUM_ALKALIDE | - RESOURCE_LEMERGIUM_ACID | - RESOURCE_LEMERGIUM_ALKALIDE | - RESOURCE_ZYNTHIUM_ACID | - RESOURCE_ZYNTHIUM_ALKALIDE | - RESOURCE_GHODIUM_ACID | - RESOURCE_GHODIUM_ALKALIDE | - RESOURCE_CATALYZED_UTRIUM_ACID | - RESOURCE_CATALYZED_UTRIUM_ALKALIDE | - RESOURCE_CATALYZED_KEANIUM_ACID | - RESOURCE_CATALYZED_KEANIUM_ALKALIDE | - RESOURCE_CATALYZED_LEMERGIUM_ACID | - RESOURCE_CATALYZED_LEMERGIUM_ALKALIDE | - RESOURCE_CATALYZED_ZYNTHIUM_ACID | - RESOURCE_CATALYZED_ZYNTHIUM_ALKALIDE | - RESOURCE_CATALYZED_GHODIUM_ACID | - RESOURCE_CATALYZED_GHODIUM_ALKALIDE; + | RESOURCE_ENERGY + | RESOURCE_POWER + | RESOURCE_UTRIUM + | RESOURCE_LEMERGIUM + | RESOURCE_KEANIUM + | RESOURCE_GHODIUM + | RESOURCE_ZYNTHIUM + | RESOURCE_OXYGEN + | RESOURCE_HYDROGEN + | RESOURCE_CATALYST + | RESOURCE_HYDROXIDE + | RESOURCE_ZYNTHIUM_KEANITE + | RESOURCE_UTRIUM_LEMERGITE + | RESOURCE_UTRIUM_HYDRIDE + | RESOURCE_UTRIUM_OXIDE + | RESOURCE_KEANIUM_HYDRIDE + | RESOURCE_KEANIUM_OXIDE + | RESOURCE_LEMERGIUM_HYDRIDE + | RESOURCE_LEMERGIUM_OXIDE + | RESOURCE_ZYNTHIUM_HYDRIDE + | RESOURCE_ZYNTHIUM_OXIDE + | RESOURCE_GHODIUM_HYDRIDE + | RESOURCE_GHODIUM_OXIDE + | RESOURCE_UTRIUM_ACID + | RESOURCE_UTRIUM_ALKALIDE + | RESOURCE_KEANIUM_ACID + | RESOURCE_KEANIUM_ALKALIDE + | RESOURCE_LEMERGIUM_ACID + | RESOURCE_LEMERGIUM_ALKALIDE + | RESOURCE_ZYNTHIUM_ACID + | RESOURCE_ZYNTHIUM_ALKALIDE + | RESOURCE_GHODIUM_ACID + | RESOURCE_GHODIUM_ALKALIDE + | RESOURCE_CATALYZED_UTRIUM_ACID + | RESOURCE_CATALYZED_UTRIUM_ALKALIDE + | RESOURCE_CATALYZED_KEANIUM_ACID + | RESOURCE_CATALYZED_KEANIUM_ALKALIDE + | RESOURCE_CATALYZED_LEMERGIUM_ACID + | RESOURCE_CATALYZED_LEMERGIUM_ALKALIDE + | RESOURCE_CATALYZED_ZYNTHIUM_ACID + | RESOURCE_CATALYZED_ZYNTHIUM_ALKALIDE + | RESOURCE_CATALYZED_GHODIUM_ACID + | RESOURCE_CATALYZED_GHODIUM_ALKALIDE; type _ResourceConstantSansEnergy = - RESOURCE_POWER | - RESOURCE_UTRIUM | - RESOURCE_LEMERGIUM | - RESOURCE_KEANIUM | - RESOURCE_GHODIUM | - RESOURCE_ZYNTHIUM | - RESOURCE_OXYGEN | - RESOURCE_HYDROGEN | - RESOURCE_CATALYST | - RESOURCE_HYDROXIDE | - RESOURCE_ZYNTHIUM_KEANITE | - RESOURCE_UTRIUM_LEMERGITE | - RESOURCE_UTRIUM_HYDRIDE | - RESOURCE_UTRIUM_OXIDE | - RESOURCE_KEANIUM_HYDRIDE | - RESOURCE_KEANIUM_OXIDE | - RESOURCE_LEMERGIUM_HYDRIDE | - RESOURCE_LEMERGIUM_OXIDE | - RESOURCE_ZYNTHIUM_HYDRIDE | - RESOURCE_ZYNTHIUM_OXIDE | - RESOURCE_GHODIUM_HYDRIDE | - RESOURCE_GHODIUM_OXIDE | - RESOURCE_UTRIUM_ACID | - RESOURCE_UTRIUM_ALKALIDE | - RESOURCE_KEANIUM_ACID | - RESOURCE_KEANIUM_ALKALIDE | - RESOURCE_LEMERGIUM_ACID | - RESOURCE_LEMERGIUM_ALKALIDE | - RESOURCE_ZYNTHIUM_ACID | - RESOURCE_ZYNTHIUM_ALKALIDE | - RESOURCE_GHODIUM_ACID | - RESOURCE_GHODIUM_ALKALIDE | - RESOURCE_CATALYZED_UTRIUM_ACID | - RESOURCE_CATALYZED_UTRIUM_ALKALIDE | - RESOURCE_CATALYZED_KEANIUM_ACID | - RESOURCE_CATALYZED_KEANIUM_ALKALIDE | - RESOURCE_CATALYZED_LEMERGIUM_ACID | - RESOURCE_CATALYZED_LEMERGIUM_ALKALIDE | - RESOURCE_CATALYZED_ZYNTHIUM_ACID | - RESOURCE_CATALYZED_ZYNTHIUM_ALKALIDE | - RESOURCE_CATALYZED_GHODIUM_ACID | - RESOURCE_CATALYZED_GHODIUM_ALKALIDE; + | RESOURCE_POWER + | RESOURCE_UTRIUM + | RESOURCE_LEMERGIUM + | RESOURCE_KEANIUM + | RESOURCE_GHODIUM + | RESOURCE_ZYNTHIUM + | RESOURCE_OXYGEN + | RESOURCE_HYDROGEN + | RESOURCE_CATALYST + | RESOURCE_HYDROXIDE + | RESOURCE_ZYNTHIUM_KEANITE + | RESOURCE_UTRIUM_LEMERGITE + | RESOURCE_UTRIUM_HYDRIDE + | RESOURCE_UTRIUM_OXIDE + | RESOURCE_KEANIUM_HYDRIDE + | RESOURCE_KEANIUM_OXIDE + | RESOURCE_LEMERGIUM_HYDRIDE + | RESOURCE_LEMERGIUM_OXIDE + | RESOURCE_ZYNTHIUM_HYDRIDE + | RESOURCE_ZYNTHIUM_OXIDE + | RESOURCE_GHODIUM_HYDRIDE + | RESOURCE_GHODIUM_OXIDE + | RESOURCE_UTRIUM_ACID + | RESOURCE_UTRIUM_ALKALIDE + | RESOURCE_KEANIUM_ACID + | RESOURCE_KEANIUM_ALKALIDE + | RESOURCE_LEMERGIUM_ACID + | RESOURCE_LEMERGIUM_ALKALIDE + | RESOURCE_ZYNTHIUM_ACID + | RESOURCE_ZYNTHIUM_ALKALIDE + | RESOURCE_GHODIUM_ACID + | RESOURCE_GHODIUM_ALKALIDE + | RESOURCE_CATALYZED_UTRIUM_ACID + | RESOURCE_CATALYZED_UTRIUM_ALKALIDE + | RESOURCE_CATALYZED_KEANIUM_ACID + | RESOURCE_CATALYZED_KEANIUM_ALKALIDE + | RESOURCE_CATALYZED_LEMERGIUM_ACID + | RESOURCE_CATALYZED_LEMERGIUM_ALKALIDE + | RESOURCE_CATALYZED_ZYNTHIUM_ACID + | RESOURCE_CATALYZED_ZYNTHIUM_ALKALIDE + | RESOURCE_CATALYZED_GHODIUM_ACID + | RESOURCE_CATALYZED_GHODIUM_ALKALIDE; type MineralConstant = - RESOURCE_UTRIUM | - RESOURCE_LEMERGIUM | - RESOURCE_KEANIUM | - RESOURCE_GHODIUM | - RESOURCE_ZYNTHIUM | - RESOURCE_OXYGEN | - RESOURCE_HYDROGEN | - RESOURCE_CATALYST; + | RESOURCE_UTRIUM + | RESOURCE_LEMERGIUM + | RESOURCE_KEANIUM + | RESOURCE_GHODIUM + | RESOURCE_ZYNTHIUM + | RESOURCE_OXYGEN + | RESOURCE_HYDROGEN + | RESOURCE_CATALYST; -type MarketResourceConstant = - ResourceConstant | - SUBSCRIPTION_TOKEN; +type MarketResourceConstant = ResourceConstant | SUBSCRIPTION_TOKEN; type RESOURCE_ENERGY = "energy"; type RESOURCE_POWER = "power"; @@ -1916,63 +1900,131 @@ type SUBSCRIPTION_TOKEN = "token"; type TOMBSTONE_DECAY_PER_PART = 5; type EventConstant = - EVENT_ATTACK | - EVENT_HEAL | - EVENT_HARVEST | - EVENT_REPAIR | - EVENT_UPGRADE_CONTROLLER; + | EVENT_ATTACK + | EVENT_OBJECT_DESTROYED + | EVENT_ATTACK_CONTROLLER + | EVENT_BUILD + | EVENT_HARVEST + | EVENT_HEAL + | EVENT_REPAIR + | EVENT_RESERVE_CONTROLLER + | EVENT_UPGRADE_CONTROLLER + | EVENT_EXIT; type EVENT_ATTACK = 1; -type EVENT_HEAL = 6; +type EVENT_OBJECT_DESTROYED = 2; +type EVENT_ATTACK_CONTROLLER = 3; +type EVENT_BUILD = 4; type EVENT_HARVEST = 5; +type EVENT_HEAL = 6; type EVENT_REPAIR = 7; +type EVENT_RESERVE_CONTROLLER = 8; type EVENT_UPGRADE_CONTROLLER = 9; +type EVENT_EXIT = 10; type EventAttackType = - "attack" | - "rangedAttack" | - "rangedMassAttack" | - "dismantle" | - "nuke"; + | EVENT_ATTACK_TYPE_MELEE + | EVENT_ATTACK_TYPE_RANGED + | EVENT_ATTACK_TYPE_RANGED_MASS + | EVENT_ATTACK_TYPE_DISMANTLE + | EVENT_ATTACK_TYPE_HIT_BACK + | EVENT_ATTACK_TYPE_NUKE; -type EventItem = { - type: EVENT_ATTACK; - objectId: string; - data: { - targetId: string; - attackType: EventAttackType; - } -} | { - type: EVENT_HEAL; - objectId: string; - data: { - targetId: string; - healed: number; - } -} | { - type: EVENT_HARVEST; - objectId: string; - data: { - targetId: string; - harvested: number; - } -} | { - type: EVENT_REPAIR; - objectId: string; - data: { - targetId: string; - repaired: number; - energySpent: number; - } -} | { - type: EVENT_UPGRADE_CONTROLLER; - objectId: string; - data: { - targetId: string; - upgraded: number; - energySpent: number; - } -}; +type EVENT_ATTACK_TYPE_MELEE = 1; +type EVENT_ATTACK_TYPE_RANGED = 2; +type EVENT_ATTACK_TYPE_RANGED_MASS = 3; +type EVENT_ATTACK_TYPE_DISMANTLE = 4; +type EVENT_ATTACK_TYPE_HIT_BACK = 5; +type EVENT_ATTACK_TYPE_NUKE = 6; + +type EventHealType = EVENT_HEAL_TYPE_MELEE | EVENT_HEAL_TYPE_RANGED; + +type EVENT_HEAL_TYPE_MELEE = 1; +type EVENT_HEAL_TYPE_RANGED = 2; + +type EventDestroyType = "creep" | StructureConstant; + +type EventItem = + | { + type: EVENT_ATTACK; + objectId: string; + data: { + targetId: string; + damage: number; + attackType: EventAttackType; + }; + } + | { + type: EVENT_OBJECT_DESTROYED; + objectId: string; + data: { + type: EventDestroyType; + }; + } + | { + type: EVENT_ATTACK_CONTROLLER; + objectId: string; + } + | { + type: EVENT_BUILD; + objectId: string; + data: { + targetId: string; + amount: number; + energySpent: number; + }; + } + | { + type: EVENT_HARVEST; + objectId: string; + data: { + targetId: string; + amount: number; + }; + } + | { + type: EVENT_HEAL; + objectId: string; + data: { + targetId: string; + amount: number; + healType: EventHealType; + }; + } + | { + type: EVENT_REPAIR; + objectId: string; + data: { + targetId: string; + amount: number; + energySpent: number; + }; + } + | { + type: EVENT_RESERVE_CONTROLLER; + objectId: string; + data: { + amount: number; + }; + } + | { + type: EVENT_UPGRADE_CONTROLLER; + objectId: string; + data: + | { + amount: number; + energySpent: number; + } + | { + type: EVENT_EXIT; + objectId: string; + data: { + room: string; + x: number; + y: number; + }; + }; + }; /** * The options that can be accepted by `findRoute()` and friends. */ @@ -2000,7 +2052,7 @@ interface GameMap { * Or one of the following Result codes: * ERR_NO_PATH, ERR_INVALID_ARGS */ - findExit(fromRoom: string|Room, toRoom: string|Room, opts?: RouteOptions): ExitConstant | ERR_NO_PATH | ERR_INVALID_ARGS; + findExit(fromRoom: string | Room, toRoom: string | Room, opts?: RouteOptions): ExitConstant | ERR_NO_PATH | ERR_INVALID_ARGS; /** * Find route from the given room to another room. * @param fromRoom Start room name or room object. @@ -2008,10 +2060,16 @@ interface GameMap { * @param opts (optional) An object with the pathfinding options. * @returns the route array or ERR_NO_PATH code */ - findRoute(fromRoom: string | Room, toRoom: string | Room, opts?: RouteOptions): Array<{ - exit: ExitConstant; - room: string; - }> | ERR_NO_PATH; + findRoute( + fromRoom: string | Room, + toRoom: string | Room, + opts?: RouteOptions, + ): + | Array<{ + exit: ExitConstant; + room: string; + }> + | ERR_NO_PATH; /** * Get the linear distance (in rooms) between two rooms. You can use this function to estimate the energy cost of * sending resources through terminals, or using observers and nukes. @@ -2105,7 +2163,13 @@ interface Market { * The maximum orders count is 50 per player. You can create an order at any time with any amount, * it will be automatically activated and deactivated depending on the resource/credits availability. */ - createOrder(type: string, resourceType: MarketResourceConstant, price: number, totalAmount: number, roomName?: string): ScreepsReturnCode; + createOrder( + type: string, + resourceType: MarketResourceConstant, + price: number, + totalAmount: number, + roomName?: string, + ): ScreepsReturnCode; /** * Execute a trade deal from your Terminal to another player's Terminal using the specified buy/sell order. * @@ -2182,10 +2246,10 @@ interface OrderFilter { } interface Memory { [name: string]: any; - creeps: {[name: string]: CreepMemory}; - flags: {[name: string]: FlagMemory}; - rooms: {[name: string]: RoomMemory}; - spawns: {[name: string]: SpawnMemory}; + creeps: { [name: string]: CreepMemory }; + flags: { [name: string]: FlagMemory }; + rooms: { [name: string]: RoomMemory }; + spawns: { [name: string]: SpawnMemory }; } interface CreepMemory {} @@ -2225,8 +2289,7 @@ interface Mineral extends RoomObjec ticksToRegeneration: number; } -interface MineralConstructor extends _Constructor, _ConstructorById { -} +interface MineralConstructor extends _Constructor, _ConstructorById {} declare const Mineral: MineralConstructor; /** @@ -2271,7 +2334,11 @@ interface PathFinder { * @param goal goal A RoomPosition, an object containing a RoomPosition and range or an array of either. * @param opts An object containing additional pathfinding flags. */ - search(origin: RoomPosition, goal: RoomPosition | { pos: RoomPosition, range: number } | Array, opts?: PathFinderOpts): PathFinderPath; + search( + origin: RoomPosition, + goal: RoomPosition | { pos: RoomPosition; range: number } | Array, + opts?: PathFinderOpts, + ): PathFinderPath; /** * Specify whether to use this new experimental pathfinder in game objects methods. * This method should be invoked every tick. It affects the following methods behavior: @@ -2370,7 +2437,7 @@ interface CostMatrix { * Creates a new CostMatrix containing 0's for all positions. * @constructor */ - new(): CostMatrix; + new (): CostMatrix; /** * Set the cost of a position in this CostMatrix. * @param x X position in the room. @@ -2404,70 +2471,70 @@ declare const PathFinder: PathFinder; * RawMemory object allows to implement your own memory stringifier instead of built-in serializer based on JSON.stringify. */ interface RawMemory { - /** - * An object with asynchronous memory segments available on this tick. Each object key is the segment ID with data in string values. - * Use RawMemory.setActiveSegments to fetch segments on the next tick. Segments data is saved automatically in the end of the tick. - */ - segments: string[]; + /** + * An object with asynchronous memory segments available on this tick. Each object key is the segment ID with data in string values. + * Use RawMemory.setActiveSegments to fetch segments on the next tick. Segments data is saved automatically in the end of the tick. + */ + segments: { [segmentId: number]: string }; - /** - * An object with a memory segment of another player available on this tick. Use `setActiveForeignSegment` to fetch segments on the next tick. - */ - foreignSegment: { - username: string, - id: number, - data: string, - }; + /** + * An object with a memory segment of another player available on this tick. Use `setActiveForeignSegment` to fetch segments on the next tick. + */ + foreignSegment: { + username: string; + id: number; + data: string; + }; - /** - * A string with a shared memory segment available on every world shard. Maximum string length is 100 KB. - * - * **Warning:** this segment is not safe for concurrent usage! All shards have shared access to the same instance of - * data. When the segment contents is changed by two shards simultaneously, you may lose some data, since the segment - * string value is written all at once atomically. You must implement your own system to determine when each shard is - * allowed to rewrite the inter-shard memory, e.g. based on mutual exclusions. - */ - interShardSegment: string; + /** + * A string with a shared memory segment available on every world shard. Maximum string length is 100 KB. + * + * **Warning:** this segment is not safe for concurrent usage! All shards have shared access to the same instance of + * data. When the segment contents is changed by two shards simultaneously, you may lose some data, since the segment + * string value is written all at once atomically. You must implement your own system to determine when each shard is + * allowed to rewrite the inter-shard memory, e.g. based on mutual exclusions. + */ + interShardSegment: string; - /** - * Get a raw string representation of the Memory object. - */ - get(): string; - /** - * Set new memory value. - * @param value New memory value as a string. - */ - set(value: string): undefined; - /** - * Request memory segments using the list of their IDs. Memory segments will become available on the next tick in RawMemory.segments object. - * @param ids An array of segment IDs. Each ID should be a number from 0 to 99. Maximum 10 segments can be active at the same time. Subsequent calls of setActiveSegments override previous ones. - */ - setActiveSegments(ids: number[]): undefined; - /** - * Request a memory segment of another user. - * - * The segment should be marked by its owner as public using `setPublicSegments`. - * - * The segment data will become available on the next tick in `foreignSegment` object. - * - * You can only have access to one foreign segment at the same time. - * - * @param username The name of another user. Pass `null` to clear the foreign segment. - * @param id The ID of the requested segment from 0 to 99. If undefined, the user's default public segment is requested as set by `setDefaultPublicSegment`. - */ - setActiveForeignSegment(username: string | null, id?: number): undefined; - /** - * Set the specified segment as your default public segment. It will be returned if no id parameter is passed to `setActiveForeignSegment` by another user. - * - * @param id The ID of the requested segment from 0 to 99. Pass `null` to clear the foreign segment. - */ - setDefaultPublicSegment(id: number | null): undefined; - /** - * Set specified segments as public. Other users will be able to request access to them using `setActiveForeignSegment`. - * - * @param ids An array of segment IDs. Each ID should be a number from 0 to 99. Subsequent calls of `setPublicSegments` override previous ones. - */ - setPublicSegments(ids: number[]): undefined; + /** + * Get a raw string representation of the Memory object. + */ + get(): string; + /** + * Set new memory value. + * @param value New memory value as a string. + */ + set(value: string): undefined; + /** + * Request memory segments using the list of their IDs. Memory segments will become available on the next tick in RawMemory.segments object. + * @param ids An array of segment IDs. Each ID should be a number from 0 to 99. Maximum 10 segments can be active at the same time. Subsequent calls of setActiveSegments override previous ones. + */ + setActiveSegments(ids: number[]): undefined; + /** + * Request a memory segment of another user. + * + * The segment should be marked by its owner as public using `setPublicSegments`. + * + * The segment data will become available on the next tick in `foreignSegment` object. + * + * You can only have access to one foreign segment at the same time. + * + * @param username The name of another user. Pass `null` to clear the foreign segment. + * @param id The ID of the requested segment from 0 to 99. If undefined, the user's default public segment is requested as set by `setDefaultPublicSegment`. + */ + setActiveForeignSegment(username: string | null, id?: number): undefined; + /** + * Set the specified segment as your default public segment. It will be returned if no id parameter is passed to `setActiveForeignSegment` by another user. + * + * @param id The ID of the requested segment from 0 to 99. Pass `null` to clear the foreign segment. + */ + setDefaultPublicSegment(id: number | null): undefined; + /** + * Set specified segments as public. Other users will be able to request access to them using `setActiveForeignSegment`. + * + * @param ids An array of segment IDs. Each ID should be a number from 0 to 99. Subsequent calls of `setPublicSegments` override previous ones. + */ + setPublicSegments(ids: number[]): undefined; } declare const RawMemory: RawMemory; @@ -2582,10 +2649,13 @@ interface RoomPosition { * @param opts An object containing pathfinding options (see Room.findPath), or one of the following: filter, algorithm * @returns An instance of a RoomObject. */ - findClosestByPath(type: K, opts?: FindPathOpts & FilterOptions & { algorithm?: string }): FindTypes[K] | null; + findClosestByPath( + type: K, + opts?: FindPathOpts & FilterOptions & { algorithm?: string }, + ): FindTypes[K] | null; findClosestByPath( type: FIND_STRUCTURES | FIND_MY_STRUCTURES | FIND_HOSTILE_STRUCTURES, - opts?: FindPathOpts & FilterOptions & { algorithm?: string } + opts?: FindPathOpts & FilterOptions & { algorithm?: string }, ): T | null; /** * Find the object with the shortest path from the given position. Uses A* search algorithm and Dijkstra's algorithm. @@ -2593,7 +2663,10 @@ interface RoomPosition { * @param opts An object containing pathfinding options (see Room.findPath), or one of the following: filter, algorithm * @returns One of the supplied objects */ - findClosestByPath(objects: T[], opts?: FindPathOpts & {filter?: any | string, algorithm?: string}): T | null; + findClosestByPath( + objects: T[], + opts?: FindPathOpts & { filter?: any | string; algorithm?: string }, + ): T | null; /** * Find the object with the shortest linear distance from the given position. * @param type Any of the FIND_* constants. @@ -2602,14 +2675,14 @@ interface RoomPosition { findClosestByRange(type: K, opts?: FilterOptions): FindTypes[K] | null; findClosestByRange( type: FIND_STRUCTURES | FIND_MY_STRUCTURES | FIND_HOSTILE_STRUCTURES, - opts?: FilterOptions + opts?: FilterOptions, ): T | null; /** * Find the object with the shortest linear distance from the given position. * @param objects An array of RoomPositions or objects with a RoomPosition. * @param opts An object containing pathfinding options (see Room.findPath), or one of the following: filter, algorithm */ - findClosestByRange(objects: T[], opts?: {filter: any | string}): T | null; + findClosestByRange(objects: T[], opts?: { filter: any | string }): T | null; /** * Find all objects in the specified linear range. * @param type Any of the FIND_* constants. @@ -2620,7 +2693,7 @@ interface RoomPosition { findInRange( type: FIND_STRUCTURES | FIND_MY_STRUCTURES | FIND_HOSTILE_STRUCTURES, range: number, - opts?: FilterOptions + opts?: FilterOptions, ): T[]; /** * Find all objects in the specified linear range. @@ -2680,7 +2753,7 @@ interface RoomPosition { * @param toPos The target position. * @param range The range distance. */ - inRangeTo(target: RoomPosition|{pos: RoomPosition}, range: number): boolean; + inRangeTo(target: RoomPosition | { pos: RoomPosition }, range: number): boolean; /** * Check whether this position is the same as the specified position. * @param x X position in the room. @@ -2955,8 +3028,10 @@ interface Room { * Total amount of energyCapacity of all spawns and extensions in the room. */ energyCapacityAvailable: number; - - eventLog: EventItem[]; + /** + * Returns an array of events happened on the previous tick in this room. + */ + getEventLog(raw?: boolean): EventItem[]; /** * A shorthand to `Memory.rooms[room.name]`. You can use it for quick access the room’s specific memory data object. */ @@ -3004,12 +3079,7 @@ interface Room { * @param name The name of the structure, for structures that support it (currently only spawns). * @returns Result Code: OK, ERR_INVALID_TARGET, ERR_INVALID_ARGS, ERR_RCL_NOT_ENOUGH */ - createConstructionSite( - x: number, - y: number, - structureType: STRUCTURE_SPAWN, - name?: string - ): ScreepsReturnCode; + createConstructionSite(x: number, y: number, structureType: STRUCTURE_SPAWN, name?: string): ScreepsReturnCode; /** * Create new ConstructionSite at the specified location. * @param pos Can be a RoomPosition object or any object containing RoomPosition. @@ -3033,7 +3103,13 @@ interface Room { * @param secondaryColor The secondary color of a new flag. Should be one of the COLOR_* constants. The default value is equal to color. * @returns The name of a new flag, or one of the following error codes: ERR_NAME_EXISTS, ERR_INVALID_ARGS */ - createFlag(x: number, y: number, name?: string, color?: ColorConstant, secondaryColor?: ColorConstant): ERR_NAME_EXISTS | ERR_INVALID_ARGS | string; + createFlag( + x: number, + y: number, + name?: string, + color?: ColorConstant, + secondaryColor?: ColorConstant, + ): ERR_NAME_EXISTS | ERR_INVALID_ARGS | string; /** * Create new Flag at the specified location. * @param pos Can be a RoomPosition object or any object containing RoomPosition. @@ -3048,7 +3124,12 @@ interface Room { * @param secondaryColor The secondary color of a new flag. Should be one of the COLOR_* constants. The default value is equal to color. * @returns The name of a new flag, or one of the following error codes: ERR_NAME_EXISTS, ERR_INVALID_ARGS */ - createFlag(pos: RoomPosition | { pos: RoomPosition }, name?: string, color?: ColorConstant, secondaryColor?: ColorConstant): ERR_NAME_EXISTS | ERR_INVALID_ARGS | string; + createFlag( + pos: RoomPosition | { pos: RoomPosition }, + name?: string, + color?: ColorConstant, + secondaryColor?: ColorConstant, + ): ERR_NAME_EXISTS | ERR_INVALID_ARGS | string; /** * Find all objects of the specified type in the room. * @param type One of the following constants: @@ -3075,7 +3156,10 @@ interface Room { * @returns An array with the objects found. */ find(type: K, opts?: FilterOptions): Array; - find(type: FIND_STRUCTURES | FIND_MY_STRUCTURES | FIND_HOSTILE_STRUCTURES, opts?: FilterOptions): T[]; + find( + type: FIND_STRUCTURES | FIND_MY_STRUCTURES | FIND_HOSTILE_STRUCTURES, + opts?: FilterOptions, + ): T[]; /** * Find the exit direction en route to another room. * @param room Another room name or room object. @@ -3162,7 +3246,7 @@ interface Room { left: number, bottom: number, right: number, - asArray?: false + asArray?: false, ): LookForAtAreaResultMatrix; /** * Get the given objets in the supplied area. @@ -3180,7 +3264,7 @@ interface Room { left: number, bottom: number, right: number, - asArray: true + asArray: true, ): LookForAtAreaResultArray; /** @@ -3244,8 +3328,7 @@ interface Source extends RoomObject { ticksToRegeneration: number; } -interface SourceConstructor extends _Constructor, _ConstructorById { -} +interface SourceConstructor extends _Constructor, _ConstructorById {} declare const Source: SourceConstructor; /** @@ -3450,8 +3533,7 @@ interface SpawnOptions { directions?: DirectionConstant[]; } -interface SpawningConstructor extends _Constructor, _ConstructorById { -} +interface SpawningConstructor extends _Constructor, _ConstructorById {} /** * Parent object for structure classes */ @@ -3494,8 +3576,7 @@ interface Structure extends Roo notifyWhenAttacked(enabled: boolean): ScreepsReturnCode; } -interface StructureConstructor extends _Constructor, _ConstructorById { -} +interface StructureConstructor extends _Constructor, _ConstructorById {} declare const Structure: StructureConstructor; @@ -3520,8 +3601,7 @@ interface OwnedStructure extend room: Room; } -interface OwnedStructureConstructor extends _Constructor, _ConstructorById { -} +interface OwnedStructureConstructor extends _Constructor, _ConstructorById {} declare const OwnedStructure: OwnedStructureConstructor; @@ -3584,8 +3664,7 @@ interface StructureController extends OwnedStructure { unclaim(): ScreepsReturnCode; } -interface StructureControllerConstructor extends _Constructor, _ConstructorById { -} +interface StructureControllerConstructor extends _Constructor, _ConstructorById {} declare const StructureController: StructureControllerConstructor; @@ -3607,8 +3686,7 @@ interface StructureExtension extends OwnedStructure { energyCapacity: number; } -interface StructureExtensionConstructor extends _Constructor, _ConstructorById { -} +interface StructureExtensionConstructor extends _Constructor, _ConstructorById {} declare const StructureExtension: StructureExtensionConstructor; @@ -3644,8 +3722,7 @@ interface StructureLink extends OwnedStructure { transferEnergy(target: Creep | StructureLink, amount?: number): ScreepsReturnCode; } -interface StructureLinkConstructor extends _Constructor, _ConstructorById { -} +interface StructureLinkConstructor extends _Constructor, _ConstructorById {} declare const StructureLink: StructureLinkConstructor; @@ -3662,8 +3739,7 @@ interface StructureKeeperLair extends OwnedStructure { ticksToSpawn?: number; } -interface StructureKeeperLairConstructor extends _Constructor, _ConstructorById { -} +interface StructureKeeperLairConstructor extends _Constructor, _ConstructorById {} declare const StructureKeeperLair: StructureKeeperLairConstructor; @@ -3680,8 +3756,7 @@ interface StructureObserver extends OwnedStructure { observeRoom(roomName: string): ScreepsReturnCode; } -interface StructureObserverConstructor extends _Constructor, _ConstructorById { -} +interface StructureObserverConstructor extends _Constructor, _ConstructorById {} declare const StructureObserver: StructureObserverConstructor; @@ -3701,8 +3776,7 @@ interface StructurePowerBank extends OwnedStructure { ticksToDecay: number; } -interface StructurePowerBankConstructor extends _Constructor, _ConstructorById { -} +interface StructurePowerBankConstructor extends _Constructor, _ConstructorById {} declare const StructurePowerBank: StructurePowerBankConstructor; @@ -3740,8 +3814,7 @@ interface StructurePowerSpawn extends OwnedStructure { processPower(): ScreepsReturnCode; } -interface StructurePowerSpawnConstructor extends _Constructor, _ConstructorById { -} +interface StructurePowerSpawnConstructor extends _Constructor, _ConstructorById {} declare const StructurePowerSpawn: StructurePowerSpawnConstructor; @@ -3769,8 +3842,7 @@ interface StructureRampart extends OwnedStructure { setPublic(isPublic: boolean): undefined; } -interface StructureRampartConstructor extends _Constructor, _ConstructorById { -} +interface StructureRampartConstructor extends _Constructor, _ConstructorById {} declare const StructureRampart: StructureRampartConstructor; @@ -3787,8 +3859,7 @@ interface StructureRoad extends Structure { ticksToDecay: number; } -interface StructureRoadConstructor extends _Constructor, _ConstructorById { -} +interface StructureRoadConstructor extends _Constructor, _ConstructorById {} declare const StructureRoad: StructureRoadConstructor; @@ -3809,8 +3880,7 @@ interface StructureStorage extends OwnedStructure { storeCapacity: number; } -interface StructureStorageConstructor extends _Constructor, _ConstructorById { -} +interface StructureStorageConstructor extends _Constructor, _ConstructorById {} declare const StructureStorage: StructureStorageConstructor; @@ -3848,8 +3918,7 @@ interface StructureTower extends OwnedStructure { repair(target: Structure): ScreepsReturnCode; } -interface StructureTowerConstructor extends _Constructor, _ConstructorById { -} +interface StructureTowerConstructor extends _Constructor, _ConstructorById {} declare const StructureTower: StructureTowerConstructor; @@ -3864,8 +3933,7 @@ interface StructureWall extends Structure { ticksToLive: number; } -interface StructureWallConstructor extends _Constructor, _ConstructorById { -} +interface StructureWallConstructor extends _Constructor, _ConstructorById {} declare const StructureWall: StructureWallConstructor; @@ -3880,8 +3948,7 @@ interface StructureExtractor extends OwnedStructure { cooldown: number; } -interface StructureExtractorConstructor extends _Constructor, _ConstructorById { -} +interface StructureExtractorConstructor extends _Constructor, _ConstructorById {} declare const StructureExtractor: StructureExtractorConstructor; @@ -3933,8 +4000,7 @@ interface StructureLab extends OwnedStructure { runReaction(lab1: StructureLab, lab2: StructureLab): ScreepsReturnCode; } -interface StructureLabConstructor extends _Constructor, _ConstructorById { -} +interface StructureLabConstructor extends _Constructor, _ConstructorById {} declare const StructureLab: StructureLabConstructor; @@ -3965,8 +4031,7 @@ interface StructureTerminal extends OwnedStructure { send(resourceType: ResourceConstant, amount: number, destination: string, description?: string): ScreepsReturnCode; } -interface StructureTerminalConstructor extends _Constructor, _ConstructorById { -} +interface StructureTerminalConstructor extends _Constructor, _ConstructorById {} declare const StructureTerminal: StructureTerminalConstructor; @@ -3990,8 +4055,7 @@ interface StructureContainer extends Structure { ticksToDecay: number; } -interface StructureContainerConstructor extends _Constructor, _ConstructorById { -} +interface StructureContainerConstructor extends _Constructor, _ConstructorById {} declare const StructureContainer: StructureContainerConstructor; @@ -4031,8 +4095,7 @@ interface StructureNuker extends OwnedStructure { launchNuke(pos: RoomPosition): ScreepsReturnCode; } -interface StructureNukerConstructor extends _Constructor, _ConstructorById { -} +interface StructureNukerConstructor extends _Constructor, _ConstructorById {} declare const StructureNuker: StructureNukerConstructor; @@ -4048,15 +4111,14 @@ interface StructurePortal extends Structure { * If this is an inter-shard portal, then this property contains an object with shard and room string properties. * Exact coordinates are undetermined, the creep will appear at any free spot in the destination room. */ - destination: RoomPosition | { shard: string, room: string }; + destination: RoomPosition | { shard: string; room: string }; /** * The amount of game ticks when the portal disappears, or undefined when the portal is stable. */ ticksToDecay: number | undefined; } -interface StructurePortalConstructor extends _Constructor, _ConstructorById { -} +interface StructurePortalConstructor extends _Constructor, _ConstructorById {} declare const StructurePortal: StructurePortalConstructor; @@ -4064,31 +4126,26 @@ declare const StructurePortal: StructurePortalConstructor; * A discriminated union on Structure.type of all owned structure types */ type AnyOwnedStructure = - StructureController | - StructureExtension | - StructureExtractor | - StructureKeeperLair | - StructureLab | - StructureLink | - StructureNuker | - StructureObserver | - StructurePowerBank | - StructurePowerSpawn | - StructureRampart | - StructureSpawn | - StructureStorage | - StructureTerminal | - StructureTower; + | StructureController + | StructureExtension + | StructureExtractor + | StructureKeeperLair + | StructureLab + | StructureLink + | StructureNuker + | StructureObserver + | StructurePowerBank + | StructurePowerSpawn + | StructureRampart + | StructureSpawn + | StructureStorage + | StructureTerminal + | StructureTower; /** * A discriminated union on Structure.type of all structure types */ -type AnyStructure = - AnyOwnedStructure | - StructureContainer | - StructurePortal | - StructureRoad | - StructureWall; +type AnyStructure = AnyOwnedStructure | StructureContainer | StructurePortal | StructureRoad | StructureWall; /** * A remnant of dead creeps. This is a walkable structure. *
    @@ -4123,7 +4180,6 @@ interface Tombstone extends RoomObject { creep: Creep; } -interface TombstoneConstructor extends _Constructor, _ConstructorById { -} +interface TombstoneConstructor extends _Constructor, _ConstructorById {} declare const Tombstone: TombstoneConstructor; diff --git a/types/screeps/screeps-tests.ts b/types/screeps/screeps-tests.ts index f0f8710fc6..4b7a3722a4 100644 --- a/types/screeps/screeps-tests.ts +++ b/types/screeps/screeps-tests.ts @@ -655,3 +655,10 @@ function keys(o: T): Array { } } } + +// Room event log + +{ + room.getEventLog(); + room.getEventLog(true); +}