Skip to content

Commit 27b2335

Browse files
authored
Merge pull request screepers#1 from screepers/TS2
Merge updates
2 parents 67ef2c0 + d88ada3 commit 27b2335

File tree

8 files changed

+223
-286
lines changed

8 files changed

+223
-286
lines changed

dist/screeps.d.ts

+108-140
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ declare var RESOURCE_CATALYZED_ZYNTHIUM_ALKALIDE: string;
214214
declare var RESOURCE_CATALYZED_GHODIUM_ACID: string;
215215
declare var RESOURCE_CATALYZED_GHODIUM_ALKALIDE: string;
216216
declare var RESOURCES_ALL: string[];
217+
declare var SUBSCRIPTION_TOKEN: string;
217218
declare var CONTROLLER_LEVELS: {
218219
[level: number]: number;
219220
};
@@ -302,135 +303,15 @@ declare var NUKE_DAMAGE: {
302303
4: number;
303304
};
304305
declare var REACTIONS: {
305-
H: {
306-
O: string;
307-
L: string;
308-
K: string;
309-
U: string;
310-
Z: string;
311-
G: string;
306+
[reagent: string]: {
307+
[reagent: string]: string;
312308
};
313-
O: {
314-
H: string;
315-
L: string;
316-
K: string;
317-
U: string;
318-
Z: string;
319-
G: string;
320-
};
321-
Z: {
322-
K: string;
323-
H: string;
324-
O: string;
325-
};
326-
L: {
327-
U: string;
328-
H: string;
329-
O: string;
330-
};
331-
K: {
332-
Z: string;
333-
H: string;
334-
O: string;
335-
};
336-
G: {
337-
H: string;
338-
O: string;
339-
};
340-
U: {
341-
L: string;
342-
H: string;
343-
O: string;
344-
};
345-
OH: {
346-
UH: string;
347-
UO: string;
348-
ZH: string;
349-
ZO: string;
350-
KH: string;
351-
KO: string;
352-
LH: string;
353-
LO: string;
354-
GH: string;
355-
GO: string;
356-
};
357-
X: {
358-
UH2O: string;
359-
UHO2: string;
360-
LH2O: string;
361-
LHO2: string;
362-
KH2O: string;
363-
KHO2: string;
364-
ZH2O: string;
365-
ZHO2: string;
366-
GH2O: string;
367-
GHO2: string;
368-
};
369-
ZK: {
370-
UL: string;
371-
};
372-
UL: {
373-
ZK: string;
374-
};
375-
LH: {
376-
OH: string;
377-
};
378-
ZH: {
379-
OH: string;
380-
};
381-
GH: {
382-
OH: string;
383-
};
384-
KH: {
385-
OH: string;
386-
};
387-
UH: {
388-
OH: string;
389-
};
390-
LO: {
391-
OH: string;
392-
};
393-
ZO: {
394-
OH: string;
395-
};
396-
KO: {
397-
OH: string;
398-
};
399-
UO: {
400-
OH: string;
401-
};
402-
GO: {
403-
OH: string;
404-
};
405-
LH2O: {
406-
X: string;
407-
};
408-
KH2O: {
409-
X: string;
410-
};
411-
ZH2O: {
412-
X: string;
413-
};
414-
UH2O: {
415-
X: string;
416-
};
417-
GH2O: {
418-
X: string;
419-
};
420-
LHO2: {
421-
X: string;
422-
};
423-
UHO2: {
424-
X: string;
425-
};
426-
KHO2: {
427-
X: string;
428-
};
429-
ZHO2: {
430-
X: string;
431-
};
432-
GHO2: {
433-
X: string;
309+
};
310+
declare var BOOSTS: {
311+
[part: string]: {
312+
[boost: string]: {
313+
[action: string]: number;
314+
};
434315
};
435316
};
436317
declare var LOOK_CREEPS: string;
@@ -443,6 +324,8 @@ declare var LOOK_FLAGS: string;
443324
declare var LOOK_CONSTRUCTION_SITES: string;
444325
declare var LOOK_NUKES: string;
445326
declare var LOOK_TERRAIN: string;
327+
declare var ORDER_SELL: string;
328+
declare var ORDER_BUY: string;
446329
/**
447330
* A site of a structure which is currently under construction.
448331
*/
@@ -817,7 +700,7 @@ interface Game {
817700
* @param id The unique identificator.
818701
* @returns an object instance or null if it cannot be found.
819702
*/
820-
getObjectById<T>(id: string): T;
703+
getObjectById<T>(id: string): T | null;
821704
/**
822705
* Send a custom message at your profile email. This way, you can set up notifications to yourself on any occasion within the game. You can schedule up to 20 notifications during one game tick. Not available in the Simulation Room.
823706
* @param message Custom text which will be sent in the message. Maximum length is 1000 characters.
@@ -872,13 +755,15 @@ interface LookAtResultWithPos {
872755
x: number;
873756
y: number;
874757
type: string;
758+
constructionSite?: ConstructionSite;
875759
creep?: Creep;
876760
terrain?: string;
877761
structure?: Structure;
878762
flag?: Flag;
879763
energy?: Resource;
880764
exit?: any;
881765
source?: Source;
766+
mineral?: Mineral;
882767
}
883768
interface LookAtResult {
884769
type: string;
@@ -890,6 +775,7 @@ interface LookAtResult {
890775
source?: Source;
891776
structure?: Structure;
892777
terrain?: string;
778+
mineral?: Mineral;
893779
}
894780
interface LookAtResultMatrix {
895781
[coord: number]: LookAtResultMatrix | LookAtResult[];
@@ -920,7 +806,7 @@ interface FindPathOpts {
920806
* @param costMatrix The current CostMatrix
921807
* @returns The new CostMatrix to use
922808
*/
923-
costCallBack?(roomName: string, costMatrix: CostMatrix): CostMatrix;
809+
costCallback?(roomName: string, costMatrix: CostMatrix): CostMatrix;
924810
/**
925811
* An array of the room's objects or RoomPosition objects which should be treated as walkable tiles during the search. This option
926812
* cannot be used when the new PathFinder is enabled (use costCallback option instead).
@@ -1064,25 +950,60 @@ declare class GameMap {
1064950
}
1065951
/**
1066952
* A global object representing the in-game market. You can use this object to track resource transactions to/from your
1067-
* terminals, and your buy/sell orders (in development). The object is accessible via the singleton Game.market property.
953+
* terminals, and your buy/sell orders. The object is accessible via the singleton Game.market property.
1068954
*/
1069955
declare class Market {
956+
/**
957+
* Your current credits balance.
958+
*/
959+
credits: number;
1070960
/**
1071961
* An array of the last 100 incoming transactions to your terminals
1072962
*/
1073963
incomingTransactions: Transaction[];
964+
/**
965+
* An object with your active and inactive buy/sell orders on the market.
966+
*/
967+
orders: {
968+
[key: string]: Order;
969+
};
1074970
/**
1075971
* An array of the last 100 outgoing transactions from your terminals
1076972
*/
1077973
outgoingTransactions: Transaction[];
974+
/**
975+
* Estimate the energy transaction cost of StructureTerminal.send and Market.deal methods.
976+
*/
977+
calcTransactionCost(amount: number, roomName1: string, roomName2: string): number;
978+
/**
979+
* Cancel a previously created order. The 5% fee is not returned.
980+
*/
981+
cancelOrder(orderId: string): number;
982+
/**
983+
* Create a market order in your terminal. You will be charged price*amount*0.05 credits when the order is placed.
984+
* The maximum orders count is 20 per player. You can create an order at any time with any amount,
985+
* it will be automatically activated and deactivated depending on the resource/credits availability.
986+
*/
987+
createOrder(type: string, resourceType: string, price: number, totalAmount: number, roomName?: string): number;
988+
/**
989+
* Execute a trade deal from your Terminal to another player's Terminal using the specified buy/sell order.
990+
* Your Terminal will be charged energy units of transfer cost regardless of the order resource type.
991+
* You can use Game.market.calcTransactionCost method to estimate it.
992+
* When multiple players try to execute the same deal, the one with the shortest distance takes precedence.
993+
*/
994+
deal(orderId: string, amount: number, targetRoomName?: string): number;
995+
/**
996+
* Get other players' orders currently active on the market.
997+
*/
998+
getAllOrders(filter?: OrderFilter | ((o: Order) => boolean)): Order[];
1078999
}
10791000
interface Transaction {
10801001
transactionId: string;
10811002
time: number;
1082-
sender: {
1003+
sender?: {
10831004
username: string;
10841005
};
1085-
recipient: {
1006+
recipient?: {
10861007
username: string;
10871008
};
10881009
resourceType: string;
@@ -1091,6 +1012,28 @@ interface Transaction {
10911012
to: string;
10921013
description: string;
10931014
}
1015+
interface Order {
1016+
id: string;
1017+
created: number;
1018+
active?: boolean;
1019+
type: string;
1020+
resourceType: string;
1021+
roomName?: string;
1022+
amount: number;
1023+
remainingAmount: number;
1024+
totalAmount?: number;
1025+
price: number;
1026+
}
1027+
interface OrderFilter {
1028+
id?: string;
1029+
created?: number;
1030+
type?: string;
1031+
resourceType?: string;
1032+
roomName?: string;
1033+
amount?: number;
1034+
remainingAmount?: number;
1035+
price?: number;
1036+
}
10941037
interface Memory {
10951038
[name: string]: any;
10961039
creeps: {
@@ -1131,6 +1074,23 @@ interface Mineral extends RoomObject {
11311074
*/
11321075
ticksToRegeneration: number;
11331076
}
1077+
/**
1078+
* A nuke landing position. This object cannot be removed or modified. You can find incoming nukes in the room using the FIND_NUKES constant.
1079+
*/
1080+
declare class Nuke extends RoomObject {
1081+
/**
1082+
* A unique object identificator. You can use Game.getObjectById method to retrieve an object instance by its id.
1083+
*/
1084+
id: string;
1085+
/**
1086+
* The name of the room where this nuke has been launched from.
1087+
*/
1088+
launchRoomName: string;
1089+
/**
1090+
* The remaining landing time.
1091+
*/
1092+
timeToLand: number;
1093+
}
11341094
/**
11351095
* Contains powerful methods for pathfinding in the game world. Support exists for custom navigation costs and paths which span multiple rooms.
11361096
* Additionally PathFinder can search for paths through rooms you can't see, although you won't be able to detect any dynamic obstacles like creeps or buildings.
@@ -1478,7 +1438,7 @@ declare class Room {
14781438
/**
14791439
* The Controller structure of this room, if present, otherwise undefined.
14801440
*/
1481-
controller: Controller;
1441+
controller: Controller | undefined;
14821442
/**
14831443
* Total amount of energy available in all spawns and extensions in the room.
14841444
*/
@@ -1503,15 +1463,15 @@ declare class Room {
15031463
/**
15041464
* The Storage structure of this room, if present, otherwise undefined.
15051465
*/
1506-
storage: StructureStorage;
1466+
storage: StructureStorage | undefined;
15071467
/**
15081468
* An object with survival game info if available
15091469
*/
1510-
survivalInfo: SurvivalGameInfo;
1470+
survivalInfo: SurvivalGameInfo | undefined;
15111471
/**
15121472
* The Terminal structure of this room, if present, otherwise undefined.
15131473
*/
1514-
terminal: Terminal;
1474+
terminal: Terminal | undefined;
15151475
/**
15161476
* Create new ConstructionSite at the specified location.
15171477
* @param x The X position.
@@ -1555,7 +1515,7 @@ declare class Room {
15551515
* @returns An array with the objects found.
15561516
*/
15571517
find<T>(type: number, opts?: {
1558-
filter: any | string;
1518+
filter: Object | Function | string;
15591519
}): T[];
15601520
/**
15611521
* Find the exit direction en route to another room.
@@ -1578,7 +1538,7 @@ declare class Room {
15781538
* @param y The Y position.
15791539
* @returns A RoomPosition object or null if it cannot be obtained.
15801540
*/
1581-
getPositionAt(x: number, y: number): RoomPosition;
1541+
getPositionAt(x: number, y: number): RoomPosition | null;
15821542
/**
15831543
* Get the list of objects at the specified room position.
15841544
* @param x The X position.
@@ -1857,6 +1817,10 @@ declare class StructureController extends OwnedStructure {
18571817
* The amount of game ticks when this controller will lose one level. This timer can be reset by using Creep.upgradeController.
18581818
*/
18591819
ticksToDowngrade: number;
1820+
/**
1821+
* The amount of game ticks while this controller cannot be upgraded due to attack.
1822+
*/
1823+
upgradeBlocked: number;
18601824
/**
18611825
* Make your claimed controller neutral again.
18621826
*/
@@ -1914,7 +1878,7 @@ declare class StructureKeeperLair extends OwnedStructure {
19141878
/**
19151879
* Time to spawning of the next Source Keeper.
19161880
*/
1917-
ticksToSpawn: number;
1881+
ticksToSpawn: number | undefined;
19181882
}
19191883
/**
19201884
* Provides visibility into a distant room from your script.
@@ -2087,6 +2051,10 @@ declare class StructureExtractor extends OwnedStructure {
20872051
* Produces mineral compounds from base minerals and boosts creeps.
20882052
*/
20892053
declare class StructureLab extends OwnedStructure {
2054+
/**
2055+
* The amount of game ticks the lab has to wait until the next reaction is possible.
2056+
*/
2057+
cooldown: number;
20902058
/**
20912059
* The amount of energy containing in the lab. Energy is used for boosting creeps.
20922060
*/

0 commit comments

Comments
 (0)