@screeps-arena-community/types 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/LICENSE +21 -0
- package/README.md +168 -0
- package/package.json +59 -0
- package/src/arena/season_1/construct_and_control/basic/basic.d.ts +4 -0
- package/src/arena/season_1/construct_and_control/basic/constants.d.ts +4 -0
- package/src/arena/season_1/construct_and_control/basic/prototypes/area-effect.d.ts +12 -0
- package/src/arena/season_1/construct_and_control/basic/prototypes/construction-boost.d.ts +9 -0
- package/src/arena/season_1/construct_and_control/basic/prototypes/structure-goal.d.ts +6 -0
- package/src/arena/season_1/construct_and_control/index.d.ts +8 -0
- package/src/arena/season_1/portal_exploration/basic/basic.d.ts +4 -0
- package/src/arena/season_1/portal_exploration/basic/prototypes/portal.d.ts +9 -0
- package/src/arena/season_1/portal_exploration/index.d.ts +8 -0
- package/src/arena/season_2/capture_the_flag/basic/prototypes/body-part.d.ts +12 -0
- package/src/arena/season_2/capture_the_flag/basic.d.ts +4 -0
- package/src/arena/season_2/capture_the_flag/index.d.ts +8 -0
- package/src/arena/season_2/power_split/basic/basic.d.ts +4 -0
- package/src/arena/season_2/power_split/basic/prototypes/bonus-flag.d.ts +10 -0
- package/src/arena/season_2/power_split/index.d.ts +8 -0
- package/src/game/constants.d.ts +112 -0
- package/src/game/index.d.ts +12 -0
- package/src/game/path-finder.d.ts +98 -0
- package/src/game/prototypes/construction-site.d.ts +26 -0
- package/src/game/prototypes/container.d.ts +14 -0
- package/src/game/prototypes/creep.d.ts +272 -0
- package/src/game/prototypes/extension.d.ts +10 -0
- package/src/game/prototypes/flag.d.ts +9 -0
- package/src/game/prototypes/game-object.d.ts +110 -0
- package/src/game/prototypes/index.d.ts +17 -0
- package/src/game/prototypes/owned-structure.d.ts +9 -0
- package/src/game/prototypes/rampart.d.ts +6 -0
- package/src/game/prototypes/resource.d.ts +14 -0
- package/src/game/prototypes/road.d.ts +6 -0
- package/src/game/prototypes/source.d.ts +13 -0
- package/src/game/prototypes/spawn.d.ts +73 -0
- package/src/game/prototypes/store.d.ts +17 -0
- package/src/game/prototypes/structure.d.ts +12 -0
- package/src/game/prototypes/tower.d.ts +45 -0
- package/src/game/prototypes/wall.d.ts +6 -0
- package/src/game/utils.d.ts +208 -0
- package/src/game/visual.d.ts +204 -0
- package/src/index.d.ts +8 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare module 'game/prototypes/container' {
|
|
2
|
+
import { Store } from 'game/prototypes/store'
|
|
3
|
+
import { OwnedStructure } from 'game/prototypes/owned-structure'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A small container that can be used to store resources.
|
|
7
|
+
* This is a walkable structure.
|
|
8
|
+
* All dropped resources automatically goes to the container at the same tile.
|
|
9
|
+
*/
|
|
10
|
+
export class StructureContainer extends OwnedStructure {
|
|
11
|
+
/** A {@link Store} object that contains cargo of this structure. */
|
|
12
|
+
store: Store
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
declare module 'game/prototypes/creep' {
|
|
2
|
+
import { Direction, FindPathOptions } from 'game/utils'
|
|
3
|
+
import {
|
|
4
|
+
OK,
|
|
5
|
+
ERR_NOT_OWNER,
|
|
6
|
+
ERR_NOT_ENOUGH_RESOURCES,
|
|
7
|
+
ERR_INVALID_TARGET,
|
|
8
|
+
ERR_FULL,
|
|
9
|
+
ERR_NOT_IN_RANGE,
|
|
10
|
+
ERR_INVALID_ARGS,
|
|
11
|
+
ERR_TIRED,
|
|
12
|
+
ERR_NO_BODYPART,
|
|
13
|
+
ATTACK,
|
|
14
|
+
CARRY,
|
|
15
|
+
HEAL,
|
|
16
|
+
MOVE,
|
|
17
|
+
RANGED_ATTACK,
|
|
18
|
+
WORK,
|
|
19
|
+
} from 'game/constants'
|
|
20
|
+
|
|
21
|
+
import { findPath } from 'game/utils'
|
|
22
|
+
import { Position } from 'game/utils'
|
|
23
|
+
import { GameObject } from 'game/prototypes/game-object'
|
|
24
|
+
import { Structure } from 'game/prototypes/structure'
|
|
25
|
+
import { ConstructionSite } from 'game/prototypes/construction-site'
|
|
26
|
+
import { Resource, ResourceType } from 'game/prototypes/resource'
|
|
27
|
+
import { Source } from 'game/prototypes/source'
|
|
28
|
+
import { Store } from 'game/prototypes/store'
|
|
29
|
+
|
|
30
|
+
type BodyPartType =
|
|
31
|
+
| typeof ATTACK
|
|
32
|
+
| typeof CARRY
|
|
33
|
+
| typeof HEAL
|
|
34
|
+
| typeof MOVE
|
|
35
|
+
| typeof RANGED_ATTACK
|
|
36
|
+
| typeof TOUGH
|
|
37
|
+
| typeof WORK
|
|
38
|
+
|
|
39
|
+
type CreepAttackResult =
|
|
40
|
+
| typeof OK
|
|
41
|
+
| typeof ERR_NOT_OWNER
|
|
42
|
+
| typeof ERR_NO_BODYPART
|
|
43
|
+
| typeof ERR_INVALID_TARGET
|
|
44
|
+
| typeof ERR_NOT_IN_RANGE
|
|
45
|
+
|
|
46
|
+
type CreepBuildResult =
|
|
47
|
+
| typeof OK
|
|
48
|
+
| typeof ERR_NOT_OWNER
|
|
49
|
+
| typeof ERR_NO_BODYPART
|
|
50
|
+
| typeof ERR_NOT_ENOUGH_RESOURCES
|
|
51
|
+
| typeof ERR_INVALID_TARGET
|
|
52
|
+
| typeof ERR_FULL
|
|
53
|
+
| typeof ERR_NOT_IN_RANGE
|
|
54
|
+
|
|
55
|
+
type CreepDropResult =
|
|
56
|
+
| typeof OK
|
|
57
|
+
| typeof ERR_NOT_OWNER
|
|
58
|
+
| typeof ERR_INVALID_ARGS
|
|
59
|
+
| typeof ERR_NOT_ENOUGH_RESOURCES
|
|
60
|
+
|
|
61
|
+
type CreepHarvestResult =
|
|
62
|
+
| typeof OK
|
|
63
|
+
| typeof ERR_NOT_OWNER
|
|
64
|
+
| typeof ERR_NO_BODYPART
|
|
65
|
+
| typeof ERR_INVALID_TARGET
|
|
66
|
+
| typeof ERR_NOT_ENOUGH_RESOURCES
|
|
67
|
+
| typeof ERR_NOT_IN_RANGE
|
|
68
|
+
|
|
69
|
+
type CreepHealResult =
|
|
70
|
+
| typeof OK
|
|
71
|
+
| typeof ERR_NOT_OWNER
|
|
72
|
+
| typeof ERR_NO_BODYPART
|
|
73
|
+
| typeof ERR_INVALID_TARGET
|
|
74
|
+
| typeof ERR_NOT_IN_RANGE
|
|
75
|
+
|
|
76
|
+
type CreepMoveResult =
|
|
77
|
+
| typeof OK
|
|
78
|
+
| typeof ERR_NOT_OWNER
|
|
79
|
+
| typeof ERR_NO_BODYPART
|
|
80
|
+
| typeof ERR_TIRED
|
|
81
|
+
| typeof ERR_INVALID_ARGS
|
|
82
|
+
|
|
83
|
+
type CreepPickupResult =
|
|
84
|
+
| typeof OK
|
|
85
|
+
| typeof ERR_NOT_OWNER
|
|
86
|
+
| typeof ERR_INVALID_TARGET
|
|
87
|
+
| typeof ERR_FULL
|
|
88
|
+
| typeof ERR_NOT_IN_RANGE
|
|
89
|
+
|
|
90
|
+
type CreepPullResult =
|
|
91
|
+
| typeof OK
|
|
92
|
+
| typeof ERR_NOT_OWNER
|
|
93
|
+
| typeof ERR_NO_BODYPART
|
|
94
|
+
| typeof ERR_TIRED
|
|
95
|
+
| typeof ERR_INVALID_TARGET
|
|
96
|
+
| typeof ERR_NOT_IN_RANGE
|
|
97
|
+
|
|
98
|
+
type CreepRangedAttackResult =
|
|
99
|
+
| typeof OK
|
|
100
|
+
| typeof ERR_NOT_OWNER
|
|
101
|
+
| typeof ERR_NO_BODYPART
|
|
102
|
+
| typeof ERR_INVALID_TARGET
|
|
103
|
+
| typeof ERR_NOT_IN_RANGE
|
|
104
|
+
|
|
105
|
+
type CreepRangedHealResult =
|
|
106
|
+
| typeof OK
|
|
107
|
+
| typeof ERR_NOT_OWNER
|
|
108
|
+
| typeof ERR_NO_BODYPART
|
|
109
|
+
| typeof ERR_INVALID_TARGET
|
|
110
|
+
| typeof ERR_NOT_IN_RANGE
|
|
111
|
+
|
|
112
|
+
type CreepRangedMassAttackResult =
|
|
113
|
+
| typeof OK
|
|
114
|
+
| typeof ERR_NOT_OWNER
|
|
115
|
+
| typeof ERR_NO_BODYPART
|
|
116
|
+
|
|
117
|
+
type CreepTransferResult =
|
|
118
|
+
| typeof OK
|
|
119
|
+
| typeof ERR_NOT_OWNER
|
|
120
|
+
| typeof ERR_INVALID_ARGS
|
|
121
|
+
| typeof ERR_INVALID_TARGET
|
|
122
|
+
| typeof ERR_NOT_IN_RANGE
|
|
123
|
+
| typeof ERR_FULL
|
|
124
|
+
| typeof ERR_NOT_ENOUGH_RESOURCES
|
|
125
|
+
|
|
126
|
+
type CreepWithdrawResult =
|
|
127
|
+
| typeof OK
|
|
128
|
+
| typeof ERR_NOT_OWNER
|
|
129
|
+
| typeof ERR_INVALID_ARGS
|
|
130
|
+
| typeof ERR_INVALID_TARGET
|
|
131
|
+
| typeof ERR_NOT_IN_RANGE
|
|
132
|
+
| typeof ERR_FULL
|
|
133
|
+
| typeof ERR_NOT_ENOUGH_RESOURCES
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Creeps are units that can move, harvest energy, construct structures, attack another creeps, and perform other actions.
|
|
137
|
+
* @extends GameObject
|
|
138
|
+
*/
|
|
139
|
+
export class Creep extends GameObject {
|
|
140
|
+
/** An array describing the creep’s body */
|
|
141
|
+
body: Array<{ type: BodyPartType; hits: number }>
|
|
142
|
+
|
|
143
|
+
/** The movement fatigue indicator. If it is greater than zero, the creep cannot move */
|
|
144
|
+
fatigue: number
|
|
145
|
+
|
|
146
|
+
/** The current amount of hit points of the creep */
|
|
147
|
+
hits: number
|
|
148
|
+
|
|
149
|
+
/** The maximum amount of hit points of the creep */
|
|
150
|
+
hitsMax: number
|
|
151
|
+
|
|
152
|
+
/** Whether it is your creep */
|
|
153
|
+
my: boolean
|
|
154
|
+
|
|
155
|
+
/** A {@link Store} object that contains cargo of this creep */
|
|
156
|
+
store: Store
|
|
157
|
+
|
|
158
|
+
/** Whether this creep is still being spawned */
|
|
159
|
+
spawning: boolean
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Attack another creep, structure, or construction site in a short-ranged attack. Requires the {@link ATTACK} body part
|
|
163
|
+
* @param target The target object
|
|
164
|
+
* @returns Either {@link OK} or one of ERR_* error codes
|
|
165
|
+
*/
|
|
166
|
+
attack(target: Creep | Structure | ConstructionSite): CreepAttackResult
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Build a structure at the target construction site using carried energy.
|
|
170
|
+
* Requires {@link WORK} and {@link CARRY} body parts
|
|
171
|
+
* @param target The target construction site to be built
|
|
172
|
+
* @returns Either {@link OK} or one of ERR_* error codes
|
|
173
|
+
*/
|
|
174
|
+
build(target: ConstructionSite): CreepBuildResult
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Drop a resource on the ground
|
|
178
|
+
* @param resource One of the RESOURCE_* constants
|
|
179
|
+
* @param amount The amount of resource units to be dropped. If omitted, all the available carried amount is used
|
|
180
|
+
* @returns Either {@link OK} or one of ERR_* error codes
|
|
181
|
+
*/
|
|
182
|
+
drop(resource: ResourceType, amount?: number): CreepDropResult
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Harvest energy from the source. Requires the {@link WORK} body part
|
|
186
|
+
* @param target The object to be harvested
|
|
187
|
+
* @returns Either {@link OK} or one of ERR_* error codes
|
|
188
|
+
*/
|
|
189
|
+
harvest(target: Source): CreepHarvestResult
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Heal self or another creep nearby. Requires the {@link HEAL} body part.
|
|
193
|
+
* @param target The target creep object
|
|
194
|
+
* @returns Either {@link OK} or one of ERR_* error codes
|
|
195
|
+
*/
|
|
196
|
+
heal(target: Creep): CreepHealResult
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Move the creep one square in the specified direction. Requires the {@link MOVE} body part
|
|
200
|
+
* @param direction The direction to move
|
|
201
|
+
* @returns Either {@link OK} or one of ERR_* error codes
|
|
202
|
+
*/
|
|
203
|
+
move(direction: Direction): CreepMoveResult
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Find the optimal path to the target and move to it. Requires the {@link MOVE} body part
|
|
207
|
+
* @param target The target to move to. Can be a {@link GameObject} or any object containing x and y properties.
|
|
208
|
+
* @param options An object with additional options that are passed to {@link findPath}
|
|
209
|
+
* @returns Either {@link OK} or one of ERR_* error codes
|
|
210
|
+
*/
|
|
211
|
+
moveTo(target: Position, options?: FindPathOptions): CreepMoveResult
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Pick up an item (a dropped piece of resource). Requires the {@link CARRY} body part.
|
|
215
|
+
* @param target The target object to be picked up
|
|
216
|
+
* @returns Either {@link OK} or one of ERR_* error codes
|
|
217
|
+
*/
|
|
218
|
+
pickup(target: Resource): CreepPickupResult
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Help another creep to follow this creep. Requires the {@link MOVE} body part
|
|
222
|
+
* @param target The target creep
|
|
223
|
+
* @returns Either {@link OK} or one of ERR_* error codes
|
|
224
|
+
*/
|
|
225
|
+
pull(target: Creep): CreepPullResult
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* A ranged attack against another creep or structure. Requires the {@link RANGED_ATTACK} body part
|
|
229
|
+
* @param target The target object to be attacked
|
|
230
|
+
* @returns Either {@link OK} or one of ERR_* error codes
|
|
231
|
+
*/
|
|
232
|
+
rangedAttack(target: Creep | Structure): CreepRangedAttackResult
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Heal another creep at a distance. Requires the {@link HEAL} body part
|
|
236
|
+
* @param target The target creep object
|
|
237
|
+
* @returns Either {@link OK} or one of ERR_* error codes
|
|
238
|
+
*/
|
|
239
|
+
rangedHeal(target: Creep): CreepRangedHealResult
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* A ranged attack against all hostile creeps or structures within 3 squares range. Requires the {@link RANGED_ATTACK} body part
|
|
243
|
+
* @returns Either {@link OK} or one of ERR_* error codes
|
|
244
|
+
*/
|
|
245
|
+
rangedMassAttack(): CreepRangedMassAttackResult
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Transfer resource from the creep to another object
|
|
249
|
+
* @param target The target object
|
|
250
|
+
* @param resource One of the RESOURCE_* constants
|
|
251
|
+
* @param amount The amount of resources to be transferred. If omitted, all the available carried amount is used
|
|
252
|
+
*/
|
|
253
|
+
transfer(
|
|
254
|
+
target: Structure | Creep,
|
|
255
|
+
resource: ResourceType,
|
|
256
|
+
amount?: number
|
|
257
|
+
): CreepTransferResult
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Withdraw resources from a structure
|
|
261
|
+
* @param target The target structure
|
|
262
|
+
* @param resource One of the RESOURCE_* constants
|
|
263
|
+
* @param amount The amount of resources to be transferred. If omitted, all the available carried amount is used
|
|
264
|
+
* @returns Either {@link OK} or one of ERR_* error codes
|
|
265
|
+
*/
|
|
266
|
+
withdraw(
|
|
267
|
+
target: Structure,
|
|
268
|
+
resource: ResourceType,
|
|
269
|
+
amount?: number
|
|
270
|
+
): CreepWithdrawResult
|
|
271
|
+
}
|
|
272
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare module 'game/prototypes/extension' {
|
|
2
|
+
import { Store } from 'game/prototypes/store'
|
|
3
|
+
import { OwnedStructure } from 'game/prototypes/owned-structure'
|
|
4
|
+
|
|
5
|
+
/** Contains energy that can be spent on spawning bigger creeps */
|
|
6
|
+
export class StructureExtension extends OwnedStructure {
|
|
7
|
+
/** A {@link Store} object that contains cargo of this structure. */
|
|
8
|
+
store: Store
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare module 'game/prototypes/flag' {
|
|
2
|
+
import { GameObject } from 'game/prototypes'
|
|
3
|
+
|
|
4
|
+
/** A flag is a key game object for this arena. Capture all flags to win the game */
|
|
5
|
+
export class Flag extends GameObject {
|
|
6
|
+
/** Equals to true or false if the flag is owned. Returns undefined if it is neutral */
|
|
7
|
+
readonly my?: boolean
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { SearchPathOptions } from '../path-finder'
|
|
2
|
+
|
|
3
|
+
declare module 'game/prototypes/game-object' {
|
|
4
|
+
import { getObjectById, FindPathOptions } from 'game/utils'
|
|
5
|
+
|
|
6
|
+
import { findPath } from 'game/utils' // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
7
|
+
|
|
8
|
+
/** Position of object in the room */
|
|
9
|
+
export type Position = {
|
|
10
|
+
/** The X coordinate in the room */
|
|
11
|
+
x: number
|
|
12
|
+
|
|
13
|
+
/** The Y coordinate in the room */
|
|
14
|
+
y: number
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type EffectData = {
|
|
18
|
+
/** The effect multiplier */
|
|
19
|
+
multiplier: number
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Represents an effect applied to a game object */
|
|
23
|
+
export class Effect {
|
|
24
|
+
/** The effect type */
|
|
25
|
+
effectType: string
|
|
26
|
+
/** The effect data */
|
|
27
|
+
data: EffectData
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Basic prototype for game objects.
|
|
32
|
+
* All objects and classes are inherited from this class
|
|
33
|
+
*/
|
|
34
|
+
export class GameObject extends Position {
|
|
35
|
+
/** true if this object is live in the game at the moment */
|
|
36
|
+
exists: boolean
|
|
37
|
+
|
|
38
|
+
/** The unique ID of this object that you can use in {@link getObjectById} */
|
|
39
|
+
id: number | string
|
|
40
|
+
|
|
41
|
+
/** If defined, then this object will disappear after this number of ticks*/
|
|
42
|
+
ticksToDecay?: number
|
|
43
|
+
|
|
44
|
+
/** The X coordinate in the room */
|
|
45
|
+
x: number
|
|
46
|
+
|
|
47
|
+
/** The Y coordinate in the room */
|
|
48
|
+
y: number
|
|
49
|
+
|
|
50
|
+
/** An array with the effects applied to this object */
|
|
51
|
+
effects?: Effect[] | null
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Find a position with the shortest path from this game object
|
|
55
|
+
* @param positions The positions to search among. An array of {@link GameObject} or any objects containing x and y properties
|
|
56
|
+
* @param options An object containing additional pathfinding flags
|
|
57
|
+
* @param options.costMatrix Custom navigation cost data
|
|
58
|
+
* @param options.plainCost Cost for walking on plain positions. The default is 2
|
|
59
|
+
* @param options.swampCost Cost for walking on swamp positions. The default is 10
|
|
60
|
+
* @param options.flee Instead of searching for a path to the goals this will search for a path away from the goals. The default is false
|
|
61
|
+
* @param options.maxOps The maximum allowed pathfinding operations. The default value is 50000
|
|
62
|
+
* @param options.maxCost The maximum allowed cost of the path returned. The default is Infinity
|
|
63
|
+
* @param options.heuristicWeight Weight from 1 to 9 to apply to the heuristic in the A* formula F = G + weight * H. The default value is 1.2
|
|
64
|
+
* @param options.ignore objects which should not be treated as obstacles during the search
|
|
65
|
+
* @returns the closest object from {@link positions}, or null if there was no valid positions
|
|
66
|
+
*/
|
|
67
|
+
findClosestByPath<T extends Position>(
|
|
68
|
+
positions: T[],
|
|
69
|
+
options?: FindPathOptions
|
|
70
|
+
): T
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Find a position with the shortest linear distance from this game object
|
|
74
|
+
* @param positions The positions to search among. An array of {@link GameObject} or any objects containing x and y properties
|
|
75
|
+
* @returns the closest object from {@link positions}
|
|
76
|
+
*/
|
|
77
|
+
findClosestByRange<T extends Position>(positions: T[]): T
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Find all objects in the specified linear range
|
|
81
|
+
* @param positions The positions to search. An array of {@link GameObject} or any objects containing x and y properties
|
|
82
|
+
* @param range The range distance
|
|
83
|
+
* @returns an array with the objects found
|
|
84
|
+
*/
|
|
85
|
+
findInRange<T extends Position>(positions: T[], range: number): T[]
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Find a path from this object to the given position
|
|
89
|
+
* @param pos The target position. May be {@link GameObject} or any object containing x and y properties
|
|
90
|
+
* @param options An object with additional options that are passed to {@link findPath}
|
|
91
|
+
* @param options.costMatrix Custom navigation cost data
|
|
92
|
+
* @param options.plainCost Cost for walking on plain positions. The default is 2
|
|
93
|
+
* @param options.swampCost Cost for walking on swamp positions. The default is 10
|
|
94
|
+
* @param options.flee Instead of searching for a path to the goals this will search for a path away from the goals. The default is false
|
|
95
|
+
* @param options.maxOps The maximum allowed pathfinding operations. The default value is 50000
|
|
96
|
+
* @param options.maxCost The maximum allowed cost of the path returned. The default is Infinity
|
|
97
|
+
* @param options.heuristicWeight Weight from 1 to 9 to apply to the heuristic in the A* formula F = G + weight * H. The default value is 1.2
|
|
98
|
+
* @param options.ignore objects which should not be treated as obstacles during the search
|
|
99
|
+
* @returns the path found as an array of objects containing x and y properties
|
|
100
|
+
*/
|
|
101
|
+
findPathTo(pos: Position, options?: FindPathOptions): Position[]
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Get linear range between this and target object
|
|
105
|
+
* @param pos The target object. May be {@link GameObject} or any object containing x and y properties
|
|
106
|
+
* @returns a number of squares between two objects
|
|
107
|
+
*/
|
|
108
|
+
getRangeTo(pos: Position): number
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare module 'game/prototypes' {
|
|
2
|
+
export { Creep } from 'game/prototypes/creep'
|
|
3
|
+
export { GameObject } from 'game/prototypes/game-object'
|
|
4
|
+
export { Structure } from 'game/prototypes/structure'
|
|
5
|
+
export { OwnedStructure } from 'game/prototypes/owned-structure'
|
|
6
|
+
export { StructureTower } from 'game/prototypes/tower'
|
|
7
|
+
export { StructureSpawn } from 'game/prototypes/spawn'
|
|
8
|
+
export { StructureWall } from 'game/prototypes/wall'
|
|
9
|
+
export { StructureContainer } from 'game/prototypes/container'
|
|
10
|
+
export { Source } from 'game/prototypes/source'
|
|
11
|
+
export { Resource } from 'game/prototypes/resource'
|
|
12
|
+
export { StructureRampart } from 'game/prototypes/rampart'
|
|
13
|
+
export { ConstructionSite } from 'game/prototypes/construction-site'
|
|
14
|
+
export { StructureExtension } from 'game/prototypes/extension'
|
|
15
|
+
export { StructureRoad } from 'game/prototypes/road'
|
|
16
|
+
export { Flag } from 'game/prototypes/flag'
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare module 'game/prototypes/owned-structure' {
|
|
2
|
+
import { Structure } from 'game/prototypes/structure'
|
|
3
|
+
|
|
4
|
+
/** The base prototype for a structure that has an owner */
|
|
5
|
+
export abstract class OwnedStructure extends Structure {
|
|
6
|
+
/** true for your structure, false for a hostile structure, undefined for a neutral structure */
|
|
7
|
+
readonly my?: boolean
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare module 'game/prototypes/rampart' {
|
|
2
|
+
import { OwnedStructure } from 'game/prototypes/owned-structure'
|
|
3
|
+
|
|
4
|
+
/** Blocks movement of hostile creeps, and defends your creeps and structures on the same position. */
|
|
5
|
+
export class StructureRampart extends OwnedStructure {}
|
|
6
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare module 'game/prototypes/resource' {
|
|
2
|
+
import { GameObject } from 'game/prototypes/game-object'
|
|
3
|
+
|
|
4
|
+
type ResourceType = string // TODO: develop resource type
|
|
5
|
+
|
|
6
|
+
/** A dropped piece of resource. Dropped resource pile decays for ceil(amount/1000) units per tick */
|
|
7
|
+
export class Resource extends GameObject {
|
|
8
|
+
/** The amount of dropped resource */
|
|
9
|
+
amount: number
|
|
10
|
+
|
|
11
|
+
/** The type of dropped resource (one of RESOURCE_* constants) */
|
|
12
|
+
resourceType: ResourceType
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare module 'game/prototypes/source' {
|
|
2
|
+
import { WORK } from 'game/constants' // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import { GameObject } from 'game/prototypes/game-object'
|
|
4
|
+
|
|
5
|
+
/** An energy source object. Can be harvested by creeps with a {@link WORK} body part */
|
|
6
|
+
export class Source extends GameObject {
|
|
7
|
+
/** Current amount of energy in the source */
|
|
8
|
+
energy: number
|
|
9
|
+
|
|
10
|
+
/** The maximum amount of energy in the source */
|
|
11
|
+
energyCapacity: number
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
declare module 'game/prototypes/spawn' {
|
|
2
|
+
import {
|
|
3
|
+
OK,
|
|
4
|
+
ERR_NOT_OWNER,
|
|
5
|
+
ERR_BUSY,
|
|
6
|
+
ERR_INVALID_ARGS,
|
|
7
|
+
ERR_NOT_ENOUGH_ENERGY,
|
|
8
|
+
} from 'game/constants'
|
|
9
|
+
|
|
10
|
+
import { BodyPartType } from 'game/prototypes/creep'
|
|
11
|
+
import { Creep } from 'game/prototypes/creep'
|
|
12
|
+
import { Store } from 'game/prototypes/store'
|
|
13
|
+
import { OwnedStructure } from 'game/prototypes/owned-structure'
|
|
14
|
+
|
|
15
|
+
/** {@link createConstructionSite} call result*/
|
|
16
|
+
export interface SpawnCreepResult {
|
|
17
|
+
/** the instance of the {@link Creep} being spawned */
|
|
18
|
+
object?: Creep | undefined
|
|
19
|
+
|
|
20
|
+
/** the error code */
|
|
21
|
+
error?:
|
|
22
|
+
| typeof ERR_NOT_OWNER
|
|
23
|
+
| typeof ERR_INVALID_ARGS
|
|
24
|
+
| typeof ERR_NOT_ENOUGH_ENERGY
|
|
25
|
+
| typeof ERR_BUSY
|
|
26
|
+
| undefined
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type SetDirectionsResult =
|
|
30
|
+
| typeof OK
|
|
31
|
+
| typeof ERR_NOT_OWNER
|
|
32
|
+
| typeof ERR_INVALID_ARGS
|
|
33
|
+
|
|
34
|
+
/** Details of the creep being spawned currently */
|
|
35
|
+
export class Spawning {
|
|
36
|
+
/** Time needed in total to complete the spawning */
|
|
37
|
+
needTime: number
|
|
38
|
+
|
|
39
|
+
/** Remaining time to go */
|
|
40
|
+
remainingTime: number
|
|
41
|
+
|
|
42
|
+
/** The creep that being spawned */
|
|
43
|
+
creep: Creep
|
|
44
|
+
|
|
45
|
+
/** Cancel spawning immediately */
|
|
46
|
+
cancel(): typeof OK | typeof ERR_NOT_OWNER | undefined
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** This structure can create creeps. It also auto-regenerate a little amount of energy each tick */
|
|
50
|
+
export class StructureSpawn extends OwnedStructure {
|
|
51
|
+
/** A {@link Store} object that contains cargo of this structure */
|
|
52
|
+
store: Store
|
|
53
|
+
|
|
54
|
+
/** If the spawn is in process of spawning a new creep, this object will contain a {@link Spawning} object, or null otherwise */
|
|
55
|
+
spawning: Spawning
|
|
56
|
+
|
|
57
|
+
/** The directions in which the spawn can create creeps */
|
|
58
|
+
directions: DirectionConstant[]
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Set the directions in which the spawn can create creeps
|
|
62
|
+
* @param directions An array of direction constants
|
|
63
|
+
*/
|
|
64
|
+
setDirections(directions: DirectionConstant[]): SetDirectionsResult
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Start the creep spawning process
|
|
68
|
+
* @param body An array describing the new creep’s body
|
|
69
|
+
* @returns a {@link SpawnCreepResult} object with the call result
|
|
70
|
+
*/
|
|
71
|
+
spawnCreep(body: BodyPartType[]): SpawnCreepResult
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare module 'game/prototypes/store' {
|
|
2
|
+
type ResourceType = string // TODO: develop resource type
|
|
3
|
+
|
|
4
|
+
/** An object that class contain resources in its cargo */
|
|
5
|
+
export type Store = {
|
|
6
|
+
/** Returns capacity of this store for the specified resource */
|
|
7
|
+
getCapacity(resource?: ResourceType): number | null
|
|
8
|
+
|
|
9
|
+
/** Returns free capacity for the store */
|
|
10
|
+
getUsedCapacity(resource?: ResourceType): number | null
|
|
11
|
+
|
|
12
|
+
/** Returns the capacity used by the specified resource */
|
|
13
|
+
getFreeCapacity(resource?: ResourceType): number | null
|
|
14
|
+
} & {
|
|
15
|
+
[resource: ResourceType]: number
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare module 'game/prototypes/structure' {
|
|
2
|
+
import { GameObject } from 'game/prototypes/game-object'
|
|
3
|
+
|
|
4
|
+
/** The base prototype object of all structures. */
|
|
5
|
+
export class Structure extends GameObject {
|
|
6
|
+
/** The current amount of hit points of the structure */
|
|
7
|
+
readonly hits?: number
|
|
8
|
+
|
|
9
|
+
/** The maximum amount of hit points of the structure */
|
|
10
|
+
readonly hitsMax?: number
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
declare module 'game/prototypes/tower' {
|
|
2
|
+
import {
|
|
3
|
+
OK,
|
|
4
|
+
ERR_NOT_OWNER,
|
|
5
|
+
ERR_TIRED,
|
|
6
|
+
ERR_INVALID_TARGET,
|
|
7
|
+
ERR_NOT_ENOUGH_ENERGY,
|
|
8
|
+
} from 'game/constants'
|
|
9
|
+
import { OwnedStructure } from 'game/prototypes/owned-structure'
|
|
10
|
+
import { Store } from 'game/prototypes/store'
|
|
11
|
+
|
|
12
|
+
type TowerAttackResult =
|
|
13
|
+
| typeof OK
|
|
14
|
+
| typeof ERR_NOT_OWNER
|
|
15
|
+
| typeof ERR_TIRED
|
|
16
|
+
| typeof ERR_INVALID_TARGET
|
|
17
|
+
| typeof ERR_NOT_ENOUGH_ENERGY
|
|
18
|
+
type TowerHealResult =
|
|
19
|
+
| typeof OK
|
|
20
|
+
| typeof ERR_NOT_OWNER
|
|
21
|
+
| typeof ERR_TIRED
|
|
22
|
+
| typeof ERR_INVALID_TARGET
|
|
23
|
+
| typeof ERR_NOT_ENOUGH_ENERGY
|
|
24
|
+
|
|
25
|
+
/** Remotely attacks game objects or heals creeps within its range */
|
|
26
|
+
export class StructureTower extends OwnedStructure {
|
|
27
|
+
/** A {@link Store} object that contains cargo of this structure. */
|
|
28
|
+
store: Store
|
|
29
|
+
|
|
30
|
+
/** The remaining amount of ticks while this tower cannot be used */
|
|
31
|
+
cooldown: number
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Remotely attack any creep or structure in range
|
|
35
|
+
* @param target The target object
|
|
36
|
+
*/
|
|
37
|
+
attack(target: Creep | Structure): TowerAttackResult
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Remotely heal any creep in range
|
|
41
|
+
* @param target The target creep
|
|
42
|
+
*/
|
|
43
|
+
heal(target: Creep): TowerHealResult
|
|
44
|
+
}
|
|
45
|
+
}
|