@chronodivide/game-api 0.73.0 → 0.74.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 +12 -0
- package/dist/index.d.ts +70 -12
- package/dist/index.js +15 -1
- package/dist/res/ra2cd.mix +0 -0
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
# 0.74.0
|
|
4
|
+
|
|
5
|
+
- Update game engine version to 0.79
|
|
6
|
+
- Deprecated `GameApi.mapApi` in favor of `GameApi.map`
|
|
7
|
+
- Deprecated `GameApi.rulesApi` in favor of `GameApi.rules`
|
|
8
|
+
- Add `options` parameter to `GameApi.canPlaceBuilding` method
|
|
9
|
+
- **BREAKING**: Remove deprecated `MapApi.findPath` method signature
|
|
10
|
+
- Add `MapApi.getReachabilityMap`
|
|
11
|
+
- Add `PlayerApi`, including player-scoped functionality from `GameApi` as well as from `ActionsApi` and `ProductionApi`
|
|
12
|
+
- Group bot-scoped APIs under a single `Bot.context` property and deprecate `*Api` properties
|
|
13
|
+
- Add `Bot.onGameInit` method
|
|
14
|
+
|
|
3
15
|
# 0.73.0
|
|
4
16
|
|
|
5
17
|
- Update game engine version to 0.78
|
package/dist/index.d.ts
CHANGED
|
@@ -102,10 +102,16 @@ export declare class Bot {
|
|
|
102
102
|
#private;
|
|
103
103
|
name: string;
|
|
104
104
|
country: string;
|
|
105
|
-
protected
|
|
106
|
-
protected
|
|
107
|
-
protected
|
|
108
|
-
|
|
105
|
+
protected context: BotContext;
|
|
106
|
+
protected get game(): GameApi;
|
|
107
|
+
protected get player(): PlayerApi;
|
|
108
|
+
/** @deprecated Use {@link Bot.game} instead */
|
|
109
|
+
protected get gameApi(): GameApi;
|
|
110
|
+
/** @deprecated Use {@link Bot.player} instead */
|
|
111
|
+
protected get actionsApi(): ActionsApi;
|
|
112
|
+
/** @deprecated Use {@link Bot.player} instead */
|
|
113
|
+
protected get productionApi(): ProductionApi;
|
|
114
|
+
protected get logger(): LoggerApi;
|
|
109
115
|
constructor(name: string, country: string);
|
|
110
116
|
/**
|
|
111
117
|
* Toggles bot debug mode, allowing the bot implementation to switch some debug features on or off.
|
|
@@ -115,11 +121,18 @@ export declare class Bot {
|
|
|
115
121
|
*/
|
|
116
122
|
setDebugMode(debugMode: boolean): this;
|
|
117
123
|
getDebugMode(): boolean;
|
|
124
|
+
onGameInit(gameApi: GameApi): void;
|
|
118
125
|
onGameStart(gameApi: GameApi): void;
|
|
119
126
|
onGameTick(gameApi: GameApi): void;
|
|
120
127
|
onGameEvent(ev: ApiEvent, gameApi: GameApi): void;
|
|
121
128
|
}
|
|
122
129
|
|
|
130
|
+
export declare class BotContext {
|
|
131
|
+
game: GameApi;
|
|
132
|
+
player: PlayerApi;
|
|
133
|
+
logger: LoggerApi;
|
|
134
|
+
}
|
|
135
|
+
|
|
123
136
|
export declare class Box2 extends THREE.Box2 {
|
|
124
137
|
}
|
|
125
138
|
|
|
@@ -271,6 +284,8 @@ export declare class CrewRules {
|
|
|
271
284
|
sovietCrew: string;
|
|
272
285
|
sovietSurvivorDivisor: number;
|
|
273
286
|
survivorRate: number;
|
|
287
|
+
thirdCrew: string;
|
|
288
|
+
thirdSurvivorDivisor: number;
|
|
274
289
|
readIni(ini: IniSection): this;
|
|
275
290
|
}
|
|
276
291
|
|
|
@@ -320,11 +335,15 @@ export declare enum FactoryType {
|
|
|
320
335
|
|
|
321
336
|
export declare class GameApi {
|
|
322
337
|
#private;
|
|
323
|
-
|
|
324
|
-
|
|
338
|
+
map: MapApi;
|
|
339
|
+
rules: RulesApi;
|
|
340
|
+
/** @deprecated Use {@link GameApi.map} instead */
|
|
341
|
+
get mapApi(): MapApi;
|
|
342
|
+
/** @deprecated Use {@link GameApi.rules} instead */
|
|
343
|
+
get rulesApi(): RulesApi;
|
|
325
344
|
isPlayerDefeated(playerName: string): boolean;
|
|
326
345
|
areAlliedPlayers(p1Name: string, p2Name: string): boolean;
|
|
327
|
-
canPlaceBuilding(playerName: string, buildingName: string, tile: Tile): boolean;
|
|
346
|
+
canPlaceBuilding(playerName: string, buildingName: string, tile: Tile, options?: PlaceCheckOptions): boolean;
|
|
328
347
|
getBuildingPlacementData(objName: string): BuildingPlacementData;
|
|
329
348
|
getPlayers(): string[];
|
|
330
349
|
getPlayerData(playerName: string): PlayerData;
|
|
@@ -503,6 +522,7 @@ export declare class GeneralRules {
|
|
|
503
522
|
spyMoneyStealPercent: number;
|
|
504
523
|
spyPowerBlackout: number;
|
|
505
524
|
technician: string;
|
|
525
|
+
thirdDisguise: string;
|
|
506
526
|
threat: ThreatRules;
|
|
507
527
|
treeStrength: number;
|
|
508
528
|
unitsUnsellable: boolean;
|
|
@@ -708,8 +728,13 @@ export declare class MapApi {
|
|
|
708
728
|
* This method has a big performance penalty and should be used with care.
|
|
709
729
|
*/
|
|
710
730
|
findPath(speedType: SpeedType, subCell: boolean, from: PathNode, to: PathNode, options?: PathFinderOptions): PathNode[];
|
|
711
|
-
/**
|
|
712
|
-
|
|
731
|
+
/**
|
|
732
|
+
* Used to determine connectivity between path nodes for the given SpeedType.
|
|
733
|
+
*
|
|
734
|
+
* Should only be used with ground, non-teleporting units.
|
|
735
|
+
* Preferred over {@link MapApi.findPath} when the full path is not needed. Complexity is O(1).
|
|
736
|
+
*/
|
|
737
|
+
getReachabilityMap(speedType: SpeedType, subCell: boolean): ReachabilityMap;
|
|
713
738
|
/** If the tile is not covered by shroud for the specified player */
|
|
714
739
|
isVisibleTile(tile: Tile, playerName: string, tileElevation?: number): boolean;
|
|
715
740
|
getTileResourceData(tile: Tile): TileResourceData | undefined;
|
|
@@ -929,6 +954,7 @@ export declare class ParadropRules {
|
|
|
929
954
|
/** In leptons */
|
|
930
955
|
paradropRadius: number;
|
|
931
956
|
sovParaDrop: ParadropSquad[];
|
|
957
|
+
yuriParaDrop: ParadropSquad[];
|
|
932
958
|
readIni(ini: IniSection): this;
|
|
933
959
|
private readParadropSquad;
|
|
934
960
|
getParadropSquads(sideType: SideType): ParadropSquad[];
|
|
@@ -963,6 +989,24 @@ export declare enum PipColor {
|
|
|
963
989
|
Blue = 4
|
|
964
990
|
}
|
|
965
991
|
|
|
992
|
+
export declare interface PlaceCheckOptions {
|
|
993
|
+
/** Skips adjacency checks. Defaults to false, except for buildings with ConstructionYard=yes */
|
|
994
|
+
ignoreAdjacent?: boolean;
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
export declare class PlayerApi {
|
|
998
|
+
#private;
|
|
999
|
+
name: string;
|
|
1000
|
+
actions: ActionsApi;
|
|
1001
|
+
production: ProductionApi;
|
|
1002
|
+
getPlayerData(): PlayerData;
|
|
1003
|
+
isDefeated(): boolean;
|
|
1004
|
+
isAlliedWith(otherPlayerName: string): boolean;
|
|
1005
|
+
canPlaceBuilding(buildingName: string, tile: Tile): boolean;
|
|
1006
|
+
/** See {@link GameApi.getVisibleUnits} */
|
|
1007
|
+
getVisibleUnits(type: "self" | "allied" | "hostile" | "enemy", filter?: (r: TechnoRules) => boolean): number[];
|
|
1008
|
+
}
|
|
1009
|
+
|
|
966
1010
|
export declare interface PlayerData {
|
|
967
1011
|
name: string;
|
|
968
1012
|
country: Country | undefined;
|
|
@@ -1193,6 +1237,13 @@ export declare class RadiationRules {
|
|
|
1193
1237
|
readIni(ini: IniSection): void;
|
|
1194
1238
|
}
|
|
1195
1239
|
|
|
1240
|
+
export declare interface ReachabilityMap {
|
|
1241
|
+
/** Checks if two nodes are connected. */
|
|
1242
|
+
isReachable(from: PathNode, to: PathNode): boolean;
|
|
1243
|
+
/** A number representing the connected region. Undefined if impassable terrain. */
|
|
1244
|
+
getRegionId(node: PathNode): number | undefined;
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1196
1247
|
export declare interface Rectangle {
|
|
1197
1248
|
x: number;
|
|
1198
1249
|
y: number;
|
|
@@ -1247,12 +1298,17 @@ export declare class RulesApi {
|
|
|
1247
1298
|
getIni(): IniFile;
|
|
1248
1299
|
}
|
|
1249
1300
|
|
|
1250
|
-
/**
|
|
1301
|
+
/**
|
|
1302
|
+
* Side/faction types (ally/soviet). Relic naming since tiberian sun.
|
|
1303
|
+
* Do not change the order. The numerical values are mapped to fields in rules.ini such as AIBasePlanningSide.
|
|
1304
|
+
*/
|
|
1251
1305
|
export declare enum SideType {
|
|
1252
1306
|
GDI = 0,
|
|
1253
1307
|
Nod = 1,
|
|
1254
|
-
|
|
1255
|
-
|
|
1308
|
+
/** Yuri */
|
|
1309
|
+
ThirdSide = 2,
|
|
1310
|
+
Civilian = 3,
|
|
1311
|
+
Mutant = 4
|
|
1256
1312
|
}
|
|
1257
1313
|
|
|
1258
1314
|
export declare interface Size {
|
|
@@ -1341,6 +1397,7 @@ export declare class TechnoRules extends ObjectRules {
|
|
|
1341
1397
|
private forbiddenHouses;
|
|
1342
1398
|
requiresStolenAlliedTech: boolean;
|
|
1343
1399
|
requiresStolenSovietTech: boolean;
|
|
1400
|
+
requiresStolenThirdTech: boolean;
|
|
1344
1401
|
cost: number;
|
|
1345
1402
|
points: number;
|
|
1346
1403
|
soylent: number;
|
|
@@ -1468,6 +1525,7 @@ export declare class TechnoRules extends ObjectRules {
|
|
|
1468
1525
|
immuneToRadiation: boolean;
|
|
1469
1526
|
immuneToPsionics: boolean;
|
|
1470
1527
|
typeImmune: boolean;
|
|
1528
|
+
damageSelf: boolean;
|
|
1471
1529
|
warpable: boolean;
|
|
1472
1530
|
/** Only for vehicles */
|
|
1473
1531
|
isTilter: boolean;
|