@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
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.0.0] - 2026-02-04
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Initial release of @screeps-arena-community/types
|
|
13
|
+
- Core game API types (game/\*)
|
|
14
|
+
- Constants, prototypes, utils, path-finder, visual
|
|
15
|
+
- All game objects: Creep, Structure, Tower, Spawn, etc.
|
|
16
|
+
- Season 1 arena types
|
|
17
|
+
- Construct and Control mode
|
|
18
|
+
- Portal Exploration mode
|
|
19
|
+
- Season 2 arena types
|
|
20
|
+
- Capture the Flag mode
|
|
21
|
+
- Power Split mode
|
|
22
|
+
- Comprehensive TypeScript type definitions
|
|
23
|
+
- Package exports for tree-shaking support
|
|
24
|
+
- Full documentation and usage examples
|
|
25
|
+
|
|
26
|
+
[1.0.0]: https://github.com/screeps-arena-community/types/releases/tag/v1.0.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Screeps Arena Types Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# @screeps-arena-community/types
|
|
2
|
+
|
|
3
|
+
Typescript types for the game [Screeps Arena](https://store.steampowered.com/app/1137320/Screeps_Arena) based on the official [Screeps Arena Docs](https://arena.screeps.com/docs).
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@screeps-arena-community/types)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install --save-dev @screeps-arena-community/types
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
Add the package to your `tsconfig.json`:
|
|
17
|
+
|
|
18
|
+
```json
|
|
19
|
+
{
|
|
20
|
+
"compilerOptions": {
|
|
21
|
+
"types": ["@screeps-arena-community/types"],
|
|
22
|
+
"moduleResolution": "node",
|
|
23
|
+
"module": "ESNext",
|
|
24
|
+
"target": "ES2020"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
For custom path mappings (optional):
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"compilerOptions": {
|
|
34
|
+
"types": ["@screeps-arena-community/types"],
|
|
35
|
+
"paths": {
|
|
36
|
+
"game/*": ["node_modules/@screeps-arena-community/types/src/game/*"],
|
|
37
|
+
"arena/*": ["node_modules/@screeps-arena-community/types/src/arena/*"]
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
### Core Game API
|
|
46
|
+
|
|
47
|
+
The core game API is available for all arena modes:
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { Creep, Structure } from 'game/prototypes'
|
|
51
|
+
import { getObjectsByPrototype, getRange } from 'game/utils'
|
|
52
|
+
import { searchPath } from 'game/path-finder'
|
|
53
|
+
import { ATTACK, MOVE, HEAL } from 'game/constants'
|
|
54
|
+
|
|
55
|
+
export function loop() {
|
|
56
|
+
const myCreeps = getObjectsByPrototype(Creep).filter((c) => c.my)
|
|
57
|
+
// Your game logic here...
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Season-Specific Types
|
|
62
|
+
|
|
63
|
+
Import types specific to your arena mode:
|
|
64
|
+
|
|
65
|
+
#### Season 1: Construct and Control
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
import {
|
|
69
|
+
StructureGoal,
|
|
70
|
+
AreaEffect,
|
|
71
|
+
} from 'arena/season_1/construct_and_control/basic'
|
|
72
|
+
import { EFFECT_DAMAGE } from 'arena/season_1/construct_and_control/basic/constants'
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
#### Season 1: Portal Exploration
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import { Portal } from 'arena/season_1/portal_exploration/basic'
|
|
79
|
+
|
|
80
|
+
export function loop() {
|
|
81
|
+
const portals = getObjectsByPrototype(Portal)
|
|
82
|
+
// Navigate through portals...
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
#### Season 2: Capture the Flag
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
import { BodyPart } from 'arena/season_2/capture_the_flag/basic'
|
|
90
|
+
|
|
91
|
+
export function loop() {
|
|
92
|
+
const droppedParts = getObjectsByPrototype(BodyPart)
|
|
93
|
+
// Collect body parts...
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
#### Season 2: Power Split
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
import { BonusFlag } from 'arena/season_2/power_split/basic'
|
|
101
|
+
import { EFF_CONSTRUCT_BOOST } from 'arena/season_2/power_split/basic/constants'
|
|
102
|
+
|
|
103
|
+
export function loop() {
|
|
104
|
+
const flags = getObjectsByPrototype(BonusFlag)
|
|
105
|
+
// Capture bonus flags...
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Available Arena Modes
|
|
110
|
+
|
|
111
|
+
| Season | Mode | Import Path |
|
|
112
|
+
| -------- | --------------------- | -------------------------------------- |
|
|
113
|
+
| Season 1 | Construct and Control | `arena/season_1/construct_and_control` |
|
|
114
|
+
| Season 1 | Portal Exploration | `arena/season_1/portal_exploration` |
|
|
115
|
+
| Season 2 | Capture the Flag | `arena/season_2/capture_the_flag` |
|
|
116
|
+
| Season 2 | Power Split | `arena/season_2/power_split` |
|
|
117
|
+
|
|
118
|
+
## Package Structure
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
@screeps-arena/types/
|
|
122
|
+
├── src/
|
|
123
|
+
│ ├── index.d.ts # Main entry (core game types)
|
|
124
|
+
│ ├── game/ # Core game API
|
|
125
|
+
│ │ ├── constants.d.ts
|
|
126
|
+
│ │ ├── prototypes/ # Game objects (Creep, Structure, etc.)
|
|
127
|
+
│ │ ├── utils.d.ts
|
|
128
|
+
│ │ ├── path-finder.d.ts
|
|
129
|
+
│ │ └── visual.d.ts
|
|
130
|
+
│ └── arena/ # Arena-specific types
|
|
131
|
+
│ ├── season_1/
|
|
132
|
+
│ │ ├── construct_and_control/
|
|
133
|
+
│ │ └── portal_exploration/
|
|
134
|
+
│ └── season_2/
|
|
135
|
+
│ ├── capture_the_flag/
|
|
136
|
+
│ └── power_split/
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Version Compatibility
|
|
140
|
+
|
|
141
|
+
| Package Version | Game Version | Notes |
|
|
142
|
+
| --------------- | ------------ | ------------------------------------------ |
|
|
143
|
+
| 1.0.0 | Season 1 & 2 | Initial release with all major arena modes |
|
|
144
|
+
|
|
145
|
+
## Documentation
|
|
146
|
+
|
|
147
|
+
- [Screeps Arena Documentation](https://docs.screeps.com/arena/)
|
|
148
|
+
- [Screeps Arena on Steam](https://store.steampowered.com/app/1137320/Screeps_Arena/)
|
|
149
|
+
|
|
150
|
+
## Contributing
|
|
151
|
+
|
|
152
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
153
|
+
|
|
154
|
+
1. Fork the repository
|
|
155
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
156
|
+
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
|
|
157
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
158
|
+
5. Open a Pull Request
|
|
159
|
+
|
|
160
|
+
## License
|
|
161
|
+
|
|
162
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
163
|
+
|
|
164
|
+
## Links
|
|
165
|
+
|
|
166
|
+
- [NPM Package](https://www.npmjs.com/package/@screeps-arena-community/types)
|
|
167
|
+
- [GitHub Repository](https://github.com/screeps-arena-community/types)
|
|
168
|
+
- [Issue Tracker](https://github.com/screeps-arena-community/types/issues)
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@screeps-arena-community/types",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "TypeScript type definitions for Screeps Arena",
|
|
5
|
+
"main": "src/index.d.ts",
|
|
6
|
+
"types": "src/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./src/index.d.ts",
|
|
9
|
+
"./game": "./src/game/index.d.ts",
|
|
10
|
+
"./game/*": "./src/game/*.d.ts",
|
|
11
|
+
"./arena/season_1/construct_and_control": "./src/arena/season_1/construct_and_control/index.d.ts",
|
|
12
|
+
"./arena/season_1/construct_and_control/*": "./src/arena/season_1/construct_and_control/*.d.ts",
|
|
13
|
+
"./arena/season_1/portal_exploration": "./src/arena/season_1/portal_exploration/index.d.ts",
|
|
14
|
+
"./arena/season_1/portal_exploration/*": "./src/arena/season_1/portal_exploration/*.d.ts",
|
|
15
|
+
"./arena/season_2/capture_the_flag": "./src/arena/season_2/capture_the_flag/index.d.ts",
|
|
16
|
+
"./arena/season_2/capture_the_flag/*": "./src/arena/season_2/capture_the_flag/*.d.ts",
|
|
17
|
+
"./arena/season_2/power_split": "./src/arena/season_2/power_split/index.d.ts",
|
|
18
|
+
"./arena/season_2/power_split/*": "./src/arena/season_2/power_split/*.d.ts"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"src/**/*.d.ts",
|
|
22
|
+
"README.md",
|
|
23
|
+
"LICENSE",
|
|
24
|
+
"CHANGELOG.md"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"test": "tsc --project tsconfig.test.json",
|
|
28
|
+
"prepublishOnly": "npm test"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"screeps",
|
|
32
|
+
"screeps-arena",
|
|
33
|
+
"screeps-arena-community",
|
|
34
|
+
"screeps-arena-types",
|
|
35
|
+
"screeps-arena-community-types",
|
|
36
|
+
"screeps-arena-definitions"
|
|
37
|
+
],
|
|
38
|
+
"author": "Kreash <kreash.dev@gmail.com>",
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "https://github.com/screeps-arena-community/types.git"
|
|
43
|
+
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public",
|
|
46
|
+
"registry": "https://registry.npmjs.org/"
|
|
47
|
+
},
|
|
48
|
+
"bugs": {
|
|
49
|
+
"url": "https://github.com/screeps-arena-community/types/issues"
|
|
50
|
+
},
|
|
51
|
+
"homepage": "https://github.com/screeps-arena-community/types#readme",
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": ">=14.0.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"prettier": "3.8.1",
|
|
57
|
+
"typescript": "^5.0.0"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare module 'arena/season_1/construct_and_control/basic/prototypes' {
|
|
2
|
+
import { GameObject } from 'game/prototypes'
|
|
3
|
+
import { EFFECT_SLOWDOWN } from 'arena/season_1/construct_and_control/basic/constants'
|
|
4
|
+
|
|
5
|
+
type AreaEffectType = typeof EFFECT_SLOWDOWN
|
|
6
|
+
|
|
7
|
+
/** An object that applies an effect of the specified type to all creeps at the same tile */
|
|
8
|
+
export class AreaEffect extends GameObject {
|
|
9
|
+
/** The effect type */
|
|
10
|
+
readonly effect: AreaEffectType
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare module 'arena/season_1/construct_and_control/basic/prototypes' {
|
|
2
|
+
import { GameObject } from 'game/prototypes'
|
|
3
|
+
|
|
4
|
+
/** An object that provides a construction boost effect to the creep that steps onto this object for 200 ticks */
|
|
5
|
+
export class ConstructionBoost extends GameObject {
|
|
6
|
+
/** The number of ticks until this object disappears */
|
|
7
|
+
ticksToDecay: number
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare module 'arena/season_1/portal_exploration/basic/prototypes' {
|
|
2
|
+
import { GameObject } from 'game/prototypes'
|
|
3
|
+
|
|
4
|
+
/** A portal is a special type of game object that allows creeps to teleport */
|
|
5
|
+
export class Portal extends GameObject {
|
|
6
|
+
/** The destination coordinates of the portal */
|
|
7
|
+
readonly destination: { x: number; y: number }
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare module 'arena/season_2/capture_the_flag/basic/prototypes' {
|
|
2
|
+
import { BodyPartType, GameObject } from 'game/prototypes'
|
|
3
|
+
|
|
4
|
+
/** A separate part of creep body */
|
|
5
|
+
export class BodyPart extends GameObject {
|
|
6
|
+
/** The type of the body part */
|
|
7
|
+
readonly type: BodyPartType
|
|
8
|
+
|
|
9
|
+
/** The number of ticks until this object disappears */
|
|
10
|
+
readonly ticksToDecay: number
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare module 'arena/season_2/power_split/basic/prototypes' {
|
|
2
|
+
import { Flag } from 'game/prototypes'
|
|
3
|
+
import { BodyPartType } from 'game/prototypes/creep'
|
|
4
|
+
|
|
5
|
+
/** An object that applies an effect of the specified type to all creeps belonging to the player who captured it. */
|
|
6
|
+
export class BonusFlag extends Flag {
|
|
7
|
+
/** The affected bodypart type */
|
|
8
|
+
readonly bonusType: BodyPartType
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
declare module 'game/constants' {
|
|
2
|
+
export const OK = 0
|
|
3
|
+
export const ERR_NOT_OWNER = -1
|
|
4
|
+
export const ERR_NO_PATH = -2
|
|
5
|
+
export const ERR_NAME_EXISTS = -3
|
|
6
|
+
export const ERR_BUSY = -4
|
|
7
|
+
export const ERR_NOT_FOUND = -5
|
|
8
|
+
export const ERR_NOT_ENOUGH_ENERGY = -6
|
|
9
|
+
export const ERR_NOT_ENOUGH_RESOURCES = -6
|
|
10
|
+
export const ERR_INVALID_TARGET = -7
|
|
11
|
+
export const ERR_FULL = -8
|
|
12
|
+
export const ERR_NOT_IN_RANGE = -9
|
|
13
|
+
export const ERR_INVALID_ARGS = -10
|
|
14
|
+
export const ERR_TIRED = -11
|
|
15
|
+
export const ERR_NO_BODYPART = -12
|
|
16
|
+
export const ERR_NOT_ENOUGH_EXTENSIONS = -6
|
|
17
|
+
|
|
18
|
+
export const MOVE = 'move'
|
|
19
|
+
export const RANGED_ATTACK = 'ranged_attack'
|
|
20
|
+
export const HEAL = 'heal'
|
|
21
|
+
export const ATTACK = 'attack'
|
|
22
|
+
export const CARRY = 'carry'
|
|
23
|
+
export const TOUGH = 'tough'
|
|
24
|
+
export const WORK = 'work'
|
|
25
|
+
|
|
26
|
+
export const TOP = 1
|
|
27
|
+
export const TOP_RIGHT = 2
|
|
28
|
+
export const RIGHT = 3
|
|
29
|
+
export const BOTTOM_RIGHT = 4
|
|
30
|
+
export const BOTTOM = 5
|
|
31
|
+
export const BOTTOM_LEFT = 6
|
|
32
|
+
export const LEFT = 7
|
|
33
|
+
export const TOP_LEFT = 8
|
|
34
|
+
|
|
35
|
+
export const TERRAIN_PLAIN = 0
|
|
36
|
+
export const TERRAIN_WALL = 1
|
|
37
|
+
export const TERRAIN_SWAMP = 2
|
|
38
|
+
|
|
39
|
+
export const BODYPART_HITS = 100
|
|
40
|
+
|
|
41
|
+
export const RANGED_ATTACK_POWER = 10
|
|
42
|
+
export const RANGED_ATTACK_DISTANCE_RATE
|
|
43
|
+
export const ATTACK_POWER = 30
|
|
44
|
+
export const HEAL_POWER = 12
|
|
45
|
+
export const RANGED_HEAL_POWER = 4
|
|
46
|
+
export const CARRY_CAPACITY = 50
|
|
47
|
+
export const REPAIR_POWER = 100
|
|
48
|
+
export const DISMANTLE_POWER = 50
|
|
49
|
+
export const REPAIR_COST = 0.01
|
|
50
|
+
export const DISMANTLE_COST = 0.005
|
|
51
|
+
export const HARVEST_POWER = 2
|
|
52
|
+
export const BUILD_POWER = 5
|
|
53
|
+
|
|
54
|
+
export const OBSTACLE_OBJECT_TYPES
|
|
55
|
+
|
|
56
|
+
export const TOWER_ENERGY_COST = 10
|
|
57
|
+
export const TOWER_RANGE = 20
|
|
58
|
+
export const TOWER_HITS = 3000
|
|
59
|
+
export const TOWER_CAPACITY = 10
|
|
60
|
+
export const TOWER_POWER_ATTACK = 1000
|
|
61
|
+
export const TOWER_POWER_HEAL = 600
|
|
62
|
+
export const TOWER_POWER_REPAIR = 200
|
|
63
|
+
export const TOWER_OPTIMAL_RANGE = 1
|
|
64
|
+
export const TOWER_FALLOFF_RANGE = 20
|
|
65
|
+
export const TOWER_FALLOFF = 1
|
|
66
|
+
export const TOWER_COOLDOWN = 10
|
|
67
|
+
|
|
68
|
+
export const BODYPART_COST
|
|
69
|
+
|
|
70
|
+
export const MAX_CREEP_SIZE = 50
|
|
71
|
+
export const CREEP_SPAWN_TIME = 3
|
|
72
|
+
|
|
73
|
+
export const RESOURCE_ENERGY = 'energy'
|
|
74
|
+
export const RESOURCES_ALL
|
|
75
|
+
|
|
76
|
+
export const SOURCE_ENERGY_REGEN = 10
|
|
77
|
+
|
|
78
|
+
export const RESOURCE_DECAY = 1000
|
|
79
|
+
|
|
80
|
+
export const MAX_CONSTRUCTION_SITES = 10
|
|
81
|
+
|
|
82
|
+
export const CONSTRUCTION_COST
|
|
83
|
+
export const STRUCTURE_PROTOTYPES
|
|
84
|
+
|
|
85
|
+
export const CONSTRUCTION_COST_ROAD_SWAMP_RATIO = 5
|
|
86
|
+
export const CONSTRUCTION_COST_ROAD_WALL_RATIO = 150
|
|
87
|
+
|
|
88
|
+
export const CONTAINER_HITS = 300
|
|
89
|
+
export const CONTAINER_CAPACITY = 2000
|
|
90
|
+
|
|
91
|
+
export const WALL_HITS = 10000
|
|
92
|
+
export const WALL_HITS_MAX = 10000
|
|
93
|
+
|
|
94
|
+
export const RAMPART_HITS = 10000
|
|
95
|
+
export const RAMPART_HITS_MAX = 10000
|
|
96
|
+
|
|
97
|
+
export const ROAD_HITS = 500
|
|
98
|
+
export const ROAD_WEAROUT = 1
|
|
99
|
+
|
|
100
|
+
export const EXTENSION_HITS = 100
|
|
101
|
+
export const EXTENSION_ENERGY_CAPACITY = 100
|
|
102
|
+
|
|
103
|
+
export const SPAWN_ENERGY_CAPACITY = 1000
|
|
104
|
+
export const SPAWN_HITS = 3000
|
|
105
|
+
|
|
106
|
+
export const EFF_CONSTRUCTION_BOOST = 'eff_construction_boost'
|
|
107
|
+
export const EFF_HEAL_BOOST = 'eff_heal_boost'
|
|
108
|
+
export const EFF_RANGED_ATTACK_BOOST = 'eff_ranged_attack_boost'
|
|
109
|
+
export const EFF_ATTACK_BOOST = 'eff_attack_boost'
|
|
110
|
+
export const EFF_WORK_BOOST = 'eff_work_boost'
|
|
111
|
+
export const EFF_MOVE_BOOST = 'eff_move_boost'
|
|
112
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare module 'game' {
|
|
2
|
+
export * from 'game/constants'
|
|
3
|
+
export * as constants from 'game/constants'
|
|
4
|
+
export * from 'game/prototypes'
|
|
5
|
+
export * as prototypes from 'game/prototypes'
|
|
6
|
+
export * from 'game/path-finder'
|
|
7
|
+
export * as pathFinder from 'game/path-finder'
|
|
8
|
+
export * from 'game/utils'
|
|
9
|
+
export * as utils from 'game/utils'
|
|
10
|
+
export * from 'game/visual'
|
|
11
|
+
export * as visual from 'game/visual'
|
|
12
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
declare module 'game/path-finder' {
|
|
2
|
+
import { Position } from 'game/prototypes'
|
|
3
|
+
|
|
4
|
+
export type SearchPathOptions = {
|
|
5
|
+
/** Custom navigation cost data */
|
|
6
|
+
costMatrix?: CostMatrix
|
|
7
|
+
|
|
8
|
+
/** Cost for walking on plain positions. The default is 2 */
|
|
9
|
+
plainCost?: number
|
|
10
|
+
|
|
11
|
+
/** Cost for walking on swamp positions. The default is 10 */
|
|
12
|
+
swampCost?: number
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Instead of searching for a path to the goals this will search for a path away from the goals.
|
|
16
|
+
* The cheapest path that is out of range of every goal will be returned.
|
|
17
|
+
* The default is false
|
|
18
|
+
*/
|
|
19
|
+
flee?: boolean
|
|
20
|
+
|
|
21
|
+
/** The maximum allowed pathfinding operations. The default value is 50000 */
|
|
22
|
+
maxOps?: number
|
|
23
|
+
|
|
24
|
+
/** The maximum allowed cost of the path returned. The default is Infinity */
|
|
25
|
+
maxCost?: number
|
|
26
|
+
|
|
27
|
+
/** Weight from 1 to 9 to apply to the heuristic in the A* formula F = G + weight * H. The default value is 1.2 */
|
|
28
|
+
heuristicWeight?: number
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type SearchPathResult = {
|
|
32
|
+
/** The path found as an array of objects containing x and y properties */
|
|
33
|
+
path: Position[]
|
|
34
|
+
|
|
35
|
+
/** Total number of operations performed before this path was calculated */
|
|
36
|
+
ops: number
|
|
37
|
+
|
|
38
|
+
/** The total cost of the path as derived from plainCost, swampCost, and given CostMatrix instance */
|
|
39
|
+
cost: number
|
|
40
|
+
|
|
41
|
+
/** If the pathfinder fails to find a complete path, this will be true */
|
|
42
|
+
incomplete: boolean
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Container for custom navigation cost data.
|
|
47
|
+
* If a non-0 value is found in the CostMatrix then that value will be used instead of the default terrain cost.
|
|
48
|
+
*/
|
|
49
|
+
export class CostMatrix {
|
|
50
|
+
/**
|
|
51
|
+
* Creates a new {@link CostMatrix} containing 0's for all positions.
|
|
52
|
+
*/
|
|
53
|
+
constructor()
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Get the cost of a position in this {@link CostMatrix}.
|
|
57
|
+
* @param x The X position in the game
|
|
58
|
+
* @param y The Y position in the game
|
|
59
|
+
* @returns the cost at the specified position
|
|
60
|
+
*/
|
|
61
|
+
get(x: number, y: number): number
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Set the cost of a position in this {@link CostMatrix}.
|
|
65
|
+
* @param x The X position in the game
|
|
66
|
+
* @param y The Y position in the game
|
|
67
|
+
* @param cost Cost of this position.
|
|
68
|
+
*/
|
|
69
|
+
set(x: number, y: number, cost: number): void
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @returns a new {@link CostMatrix} instance.
|
|
73
|
+
*/
|
|
74
|
+
clone(): CostMatrix
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export type Goal = Position | { pos: Position; range: number }
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Find an optimal path between origin and goal.
|
|
81
|
+
* @param origin The start position.
|
|
82
|
+
* @param goal A goal or an array of goals
|
|
83
|
+
* @param options An object containing additional pathfinding flags
|
|
84
|
+
* @param options.costMatrix Custom navigation cost data
|
|
85
|
+
* @param options.plainCost Cost for walking on plain positions. The default is 2
|
|
86
|
+
* @param options.swampCost Cost for walking on swamp positions. The default is 10
|
|
87
|
+
* @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
|
|
88
|
+
* @param options.maxOps The maximum allowed pathfinding operations. The default value is 50000
|
|
89
|
+
* @param options.maxCost The maximum allowed cost of the path returned. The default is Infinity
|
|
90
|
+
* @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
|
|
91
|
+
* @returns a {@link SearchPathResult} object with the search result
|
|
92
|
+
*/
|
|
93
|
+
export function searchPath(
|
|
94
|
+
origin: Position,
|
|
95
|
+
goal: Goal | Goal[],
|
|
96
|
+
options?: SearchPathOptions
|
|
97
|
+
): SearchPathResult
|
|
98
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare module 'game/prototypes/construction-site' {
|
|
2
|
+
import { Structure } from 'game/prototypes/structure'
|
|
3
|
+
import { GameObject } from 'game/prototypes/game-object'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A site of a structure which is currently under construction
|
|
7
|
+
*/
|
|
8
|
+
export class ConstructionSite extends GameObject {
|
|
9
|
+
/** The current construction progress */
|
|
10
|
+
readonly progress?: number
|
|
11
|
+
|
|
12
|
+
/** The total construction progress needed for the structure to be built */
|
|
13
|
+
readonly progressTotal?: number
|
|
14
|
+
|
|
15
|
+
/** The structure that will be built (when the construction site is completed) */
|
|
16
|
+
readonly structure?: Structure
|
|
17
|
+
|
|
18
|
+
/** Whether it is your construction site */
|
|
19
|
+
readonly my?: boolean
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Remove this construction site
|
|
23
|
+
*/
|
|
24
|
+
remove(): void
|
|
25
|
+
}
|
|
26
|
+
}
|