clashofclans.js 3.0.0-dev.392ca4c → 3.0.0-dev.ec60c82
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/dist/client/Client.d.ts +26 -2
- package/dist/client/Client.js +8 -6
- package/dist/client/PollingClient.d.ts +105 -32
- package/dist/client/PollingClient.js +265 -6
- package/dist/index.d.ts +0 -1
- package/dist/index.js +5 -2
- package/dist/index.mjs +2 -1
- package/dist/rest/RESTManager.d.ts +36 -3
- package/dist/rest/RESTManager.js +35 -29
- package/dist/rest/RequestHandler.d.ts +30 -2
- package/dist/rest/RequestHandler.js +12 -6
- package/dist/struct/Clan.d.ts +1 -1
- package/dist/struct/Player.d.ts +1 -1
- package/dist/struct/Ranking.d.ts +1 -1
- package/dist/struct/Unit.d.ts +0 -2
- package/dist/struct/Unit.js +0 -2
- package/dist/struct/index.js +5 -1
- package/dist/types/index.js +5 -1
- package/dist/types/lib.d.ts +4 -4
- package/dist/util/Constants.d.ts +38 -3
- package/dist/util/Constants.js +11 -2
- package/dist/util/Util.js +2 -2
- package/dist/util/raw.json +1 -1
- package/package.json +6 -59
- package/dist/client/EventManager.d.ts +0 -86
- package/dist/client/EventManager.js +0 -278
package/dist/rest/RESTManager.js
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RESTManager = void 0;
|
|
4
|
-
const
|
|
4
|
+
const node_events_1 = require("node:events");
|
|
5
5
|
const Util_1 = require("../util/Util");
|
|
6
|
+
const Constants_1 = require("../util/Constants");
|
|
7
|
+
const RequestHandler_1 = require("./RequestHandler");
|
|
6
8
|
/** Represents a REST Manager of the client. */
|
|
7
|
-
class RESTManager {
|
|
9
|
+
class RESTManager extends node_events_1.EventEmitter {
|
|
8
10
|
constructor(options) {
|
|
9
|
-
|
|
11
|
+
super();
|
|
12
|
+
this.requestHandler = new RequestHandler_1.RequestHandler(options)
|
|
13
|
+
.on(Constants_1.RestEvents.Debug, this.emit.bind(this, Constants_1.RestEvents.Debug))
|
|
14
|
+
.on(Constants_1.RestEvents.Error, this.emit.bind(this, Constants_1.RestEvents.Error))
|
|
15
|
+
.on(Constants_1.RestEvents.RateLimited, this.emit.bind(this, Constants_1.RestEvents.RateLimited));
|
|
10
16
|
}
|
|
11
17
|
/** Contains various general-purpose utility methods. */
|
|
12
18
|
get util() {
|
|
@@ -21,122 +27,122 @@ class RESTManager {
|
|
|
21
27
|
* ```
|
|
22
28
|
*/
|
|
23
29
|
login(options) {
|
|
24
|
-
return this.
|
|
30
|
+
return this.requestHandler.init(options);
|
|
25
31
|
}
|
|
26
32
|
/** Set Clash of Clans API keys. */
|
|
27
33
|
setKeys(keys) {
|
|
28
|
-
this.
|
|
34
|
+
this.requestHandler.setKeys(keys);
|
|
29
35
|
return this;
|
|
30
36
|
}
|
|
31
37
|
/** Search all clans by name and/or filtering the results using various criteria. */
|
|
32
38
|
getClans(query, options) {
|
|
33
|
-
return this.
|
|
39
|
+
return this.requestHandler.request(`/clans${Util_1.Util.queryString(query)}`, options);
|
|
34
40
|
}
|
|
35
41
|
/** Get info about a clan. */
|
|
36
42
|
getClan(clanTag, options) {
|
|
37
|
-
return this.
|
|
43
|
+
return this.requestHandler.request(`/clans/${Util_1.Util.encodeURI(clanTag)}`, options);
|
|
38
44
|
}
|
|
39
45
|
/** Get list of clan members. */
|
|
40
46
|
getClanMembers(clanTag, options) {
|
|
41
47
|
const query = Util_1.Util.queryString(options);
|
|
42
|
-
return this.
|
|
48
|
+
return this.requestHandler.request(`/clans/${Util_1.Util.encodeURI(clanTag)}/members${query}`, options);
|
|
43
49
|
}
|
|
44
50
|
/** Get clan war log. */
|
|
45
51
|
getClanWarLog(clanTag, options) {
|
|
46
52
|
const query = Util_1.Util.queryString(options);
|
|
47
|
-
return this.
|
|
53
|
+
return this.requestHandler.request(`/clans/${Util_1.Util.encodeURI(clanTag)}/warlog${query}`, options);
|
|
48
54
|
}
|
|
49
55
|
/** Get info about currently running war in the clan. */
|
|
50
56
|
getCurrentWar(clanTag, options) {
|
|
51
|
-
return this.
|
|
57
|
+
return this.requestHandler.request(`/clans/${Util_1.Util.encodeURI(clanTag)}/currentwar`, options);
|
|
52
58
|
}
|
|
53
59
|
/** Get info about clan war league. */
|
|
54
60
|
getClanWarLeagueGroup(clanTag, options) {
|
|
55
|
-
return this.
|
|
61
|
+
return this.requestHandler.request(`/clans/${Util_1.Util.encodeURI(clanTag)}/currentwar/leaguegroup`, options);
|
|
56
62
|
}
|
|
57
63
|
/** Get info about a CWL round by WarTag. */
|
|
58
64
|
getClanWarLeagueRound(warTag, options) {
|
|
59
|
-
return this.
|
|
65
|
+
return this.requestHandler.request(`/clanwarleagues/wars/${Util_1.Util.encodeURI(warTag)}`, options);
|
|
60
66
|
}
|
|
61
67
|
/** Get info about a player by tag. */
|
|
62
68
|
getPlayer(playerTag, options) {
|
|
63
|
-
return this.
|
|
69
|
+
return this.requestHandler.request(`/players/${Util_1.Util.encodeURI(playerTag)}`, options);
|
|
64
70
|
}
|
|
65
71
|
/** Verify Player API token that can be found from the Game settings. */
|
|
66
72
|
verifyPlayerToken(playerTag, token, options) {
|
|
67
73
|
const opts = { method: 'POST', body: JSON.stringify({ token }), ...options };
|
|
68
|
-
return this.
|
|
74
|
+
return this.requestHandler.request(`/players/${Util_1.Util.encodeURI(playerTag)}/verifytoken`, opts);
|
|
69
75
|
}
|
|
70
76
|
/** Get list of Leagues. */
|
|
71
77
|
getLeagues(options) {
|
|
72
78
|
const query = Util_1.Util.queryString(options);
|
|
73
|
-
return this.
|
|
79
|
+
return this.requestHandler.request(`/leagues${query}`, options);
|
|
74
80
|
}
|
|
75
81
|
/** Get a League info. */
|
|
76
82
|
getLeague(leagueId, options) {
|
|
77
|
-
return this.
|
|
83
|
+
return this.requestHandler.request(`/leagues/${leagueId}`, options);
|
|
78
84
|
}
|
|
79
85
|
/** Get Legend League season Ids. */
|
|
80
86
|
getLeagueSeasons(leagueId, options) {
|
|
81
87
|
const query = Util_1.Util.queryString(options);
|
|
82
|
-
return this.
|
|
88
|
+
return this.requestHandler.request(`/leagues/${leagueId}/seasons${query}`, options);
|
|
83
89
|
}
|
|
84
90
|
/** Get Legend League season rankings by season Id. */
|
|
85
91
|
getSeasonRankings(leagueId, seasonId, options) {
|
|
86
92
|
const query = Util_1.Util.queryString(options);
|
|
87
|
-
return this.
|
|
93
|
+
return this.requestHandler.request(`/leagues/${leagueId}/seasons/${seasonId}${query}`, options);
|
|
88
94
|
}
|
|
89
95
|
/** Get list of Clan War Leagues. */
|
|
90
96
|
getWarLeagues(options) {
|
|
91
97
|
const query = Util_1.Util.queryString(options);
|
|
92
|
-
return this.
|
|
98
|
+
return this.requestHandler.request(`/warleagues${query}`, options);
|
|
93
99
|
}
|
|
94
100
|
/** Get info about a Clan War League. */
|
|
95
101
|
getWarLeague(leagueId, options) {
|
|
96
|
-
return this.
|
|
102
|
+
return this.requestHandler.request(`/warleagues/${leagueId}`, options);
|
|
97
103
|
}
|
|
98
104
|
/** Get list of Locations. */
|
|
99
105
|
getLocations(options) {
|
|
100
106
|
const query = Util_1.Util.queryString(options);
|
|
101
|
-
return this.
|
|
107
|
+
return this.requestHandler.request(`/locations${query}`, options);
|
|
102
108
|
}
|
|
103
109
|
/** Get info about a Location. */
|
|
104
110
|
getLocation(locationId, options) {
|
|
105
|
-
return this.
|
|
111
|
+
return this.requestHandler.request(`/locations/${locationId}`, options);
|
|
106
112
|
}
|
|
107
113
|
/** Get clan rankings for a specific location. */
|
|
108
114
|
getClanRanks(locationId, options) {
|
|
109
115
|
const query = Util_1.Util.queryString(options);
|
|
110
|
-
return this.
|
|
116
|
+
return this.requestHandler.request(`/locations/${locationId}/rankings/clans${query}`, options);
|
|
111
117
|
}
|
|
112
118
|
/** Get player rankings for a specific location. */
|
|
113
119
|
getPlayerRanks(locationId, options) {
|
|
114
120
|
const query = Util_1.Util.queryString(options);
|
|
115
|
-
return this.
|
|
121
|
+
return this.requestHandler.request(`/locations/${locationId}/rankings/players${query}`, options);
|
|
116
122
|
}
|
|
117
123
|
/** Get clan versus rankings for a specific location. */
|
|
118
124
|
getVersusClanRanks(locationId, options) {
|
|
119
125
|
const query = Util_1.Util.queryString(options);
|
|
120
|
-
return this.
|
|
126
|
+
return this.requestHandler.request(`/locations/${locationId}/rankings/clans-versus${query}`, options);
|
|
121
127
|
}
|
|
122
128
|
/** Get player versus rankings for a specific location. */
|
|
123
129
|
getVersusPlayerRanks(locationId, options) {
|
|
124
130
|
const query = Util_1.Util.queryString(options);
|
|
125
|
-
return this.
|
|
131
|
+
return this.requestHandler.request(`/locations/${locationId}/rankings/players-versus${query}`, options);
|
|
126
132
|
}
|
|
127
133
|
/** Get list of clan labels. */
|
|
128
134
|
getClanLabels(options) {
|
|
129
135
|
const query = Util_1.Util.queryString(options);
|
|
130
|
-
return this.
|
|
136
|
+
return this.requestHandler.request(`/labels/clans${query}`, options);
|
|
131
137
|
}
|
|
132
138
|
/** Get list of player labels. */
|
|
133
139
|
getPlayerLabels(options) {
|
|
134
140
|
const query = Util_1.Util.queryString(options);
|
|
135
|
-
return this.
|
|
141
|
+
return this.requestHandler.request(`/labels/players${query}`, options);
|
|
136
142
|
}
|
|
137
143
|
/** Get info about gold pass season. */
|
|
138
144
|
getGoldPassSeason(options) {
|
|
139
|
-
return this.
|
|
145
|
+
return this.requestHandler.request('/goldpass/seasons/current', options);
|
|
140
146
|
}
|
|
141
147
|
}
|
|
142
148
|
exports.RESTManager = RESTManager;
|
|
@@ -1,6 +1,34 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'node:events';
|
|
1
3
|
import { Response, RequestOptions, LoginOptions, RequestHandlerOptions } from '../types';
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
+
import { IRestEvents } from './RESTManager';
|
|
5
|
+
export interface RequestHandler {
|
|
6
|
+
emit: (<K extends keyof IRestEvents>(event: K, ...args: IRestEvents[K]) => boolean) & (<S extends string | symbol>(event: Exclude<S, keyof IRestEvents>, ...args: any[]) => boolean);
|
|
7
|
+
off: (<K extends keyof IRestEvents>(event: K, listener: (...args: IRestEvents[K]) => void) => this) & (<S extends string | symbol>(event: Exclude<S, keyof IRestEvents>, listener: (...args: any[]) => void) => this);
|
|
8
|
+
on: (<K extends keyof IRestEvents>(event: K, listener: (...args: IRestEvents[K]) => void) => this) & (<S extends string | symbol>(event: Exclude<S, keyof IRestEvents>, listener: (...args: any[]) => void) => this);
|
|
9
|
+
once: (<K extends keyof IRestEvents>(event: K, listener: (...args: IRestEvents[K]) => void) => this) & (<S extends string | symbol>(event: Exclude<S, keyof IRestEvents>, listener: (...args: any[]) => void) => this);
|
|
10
|
+
removeAllListeners: (<K extends keyof IRestEvents>(event?: K) => this) & (<S extends string | symbol>(event?: Exclude<S, keyof IRestEvents>) => this);
|
|
11
|
+
/**
|
|
12
|
+
* Emitted for general debugging information.
|
|
13
|
+
* @public
|
|
14
|
+
* @event
|
|
15
|
+
*/
|
|
16
|
+
debug: string;
|
|
17
|
+
/**
|
|
18
|
+
* Emitted when the client encounters an error.
|
|
19
|
+
* @public
|
|
20
|
+
* @event
|
|
21
|
+
*/
|
|
22
|
+
error: string;
|
|
23
|
+
/**
|
|
24
|
+
* Emitted when the client is rate limited.
|
|
25
|
+
* @public
|
|
26
|
+
* @event
|
|
27
|
+
*/
|
|
28
|
+
rateLimited: string;
|
|
29
|
+
}
|
|
30
|
+
/** Represents the class that manages handlers for endpoints. */
|
|
31
|
+
export declare class RequestHandler extends EventEmitter {
|
|
4
32
|
#private;
|
|
5
33
|
private email;
|
|
6
34
|
private password;
|
|
@@ -16,16 +16,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
var _RequestHandler_keyIndex;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.RequestHandler = void 0;
|
|
19
|
+
const node_https_1 = __importDefault(require("node:https"));
|
|
20
|
+
const node_events_1 = require("node:events");
|
|
21
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
19
22
|
const Constants_1 = require("../util/Constants");
|
|
20
|
-
const HTTPError_1 = require("./HTTPError");
|
|
21
23
|
const Store_1 = require("../util/Store");
|
|
22
|
-
const
|
|
23
|
-
const https_1 = __importDefault(require("https"));
|
|
24
|
+
const HTTPError_1 = require("./HTTPError");
|
|
24
25
|
const IP_REGEX = /\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}/g;
|
|
25
|
-
const agent = new
|
|
26
|
-
/** Represents
|
|
27
|
-
class RequestHandler {
|
|
26
|
+
const agent = new node_https_1.default.Agent({ keepAlive: true });
|
|
27
|
+
/** Represents the class that manages handlers for endpoints. */
|
|
28
|
+
class RequestHandler extends node_events_1.EventEmitter {
|
|
28
29
|
constructor(options) {
|
|
30
|
+
super();
|
|
29
31
|
_RequestHandler_keyIndex.set(this, 0); // eslint-disable-line
|
|
30
32
|
this.keys = options?.keys ?? [];
|
|
31
33
|
this.retryLimit = options?.retryLimit ?? 0;
|
|
@@ -89,6 +91,10 @@ class RequestHandler {
|
|
|
89
91
|
if (!res?.ok && this.rejectIfNotValid) {
|
|
90
92
|
throw new HTTPError_1.HTTPError(data, res?.status ?? 504, path, maxAge, options.method);
|
|
91
93
|
}
|
|
94
|
+
if (res?.status === 429) {
|
|
95
|
+
this.emit(Constants_1.RestEvents.RateLimited, path, res.status, options.method);
|
|
96
|
+
}
|
|
97
|
+
this.emit(Constants_1.RestEvents.Debug, path, res?.status ?? 504, options.method);
|
|
92
98
|
if (this.cached && maxAge > 0 && options.cache !== false && res?.ok) {
|
|
93
99
|
await this.cached.set(path, { data, ttl: Date.now() + maxAge, status: res.status }, maxAge);
|
|
94
100
|
}
|
package/dist/struct/Clan.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { APIClan, OverrideOptions } from '../types';
|
|
2
|
+
import { Client } from '../client/Client';
|
|
2
3
|
import { ChatLanguage } from './ChatLanguage';
|
|
3
4
|
import { ClanMember } from './ClanMember';
|
|
4
|
-
import { Client } from '../client/Client';
|
|
5
5
|
import { WarLeague } from './WarLeague';
|
|
6
6
|
import type { Player } from './Player';
|
|
7
7
|
import { Location } from './Location';
|
package/dist/struct/Player.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { APIPlayer, OverrideOptions } from '../types';
|
|
2
|
+
import { Client } from '../client/Client';
|
|
2
3
|
import { LegendStatistics } from './LegendStatistics';
|
|
3
4
|
import { Achievement } from './Achievement';
|
|
4
5
|
import { Hero, Spell, Troop } from './Unit';
|
|
5
6
|
import { PlayerClan } from './PlayerClan';
|
|
6
|
-
import { Client } from '../client/Client';
|
|
7
7
|
import { League } from './League';
|
|
8
8
|
import { Label } from './Label';
|
|
9
9
|
/** Represents a Clash of Clans Player. */
|
package/dist/struct/Ranking.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { APIClanRanking, APIClanVersusRanking, APIPlayerRanking, APIPlayerVersusRanking } from '../types';
|
|
2
|
-
import { PlayerClan } from './PlayerClan';
|
|
3
2
|
import { Client } from '../client/Client';
|
|
3
|
+
import { PlayerClan } from './PlayerClan';
|
|
4
4
|
import { Location } from './Location';
|
|
5
5
|
import { League } from './League';
|
|
6
6
|
import { Badge } from './Badge';
|
package/dist/struct/Unit.d.ts
CHANGED
package/dist/struct/Unit.js
CHANGED
|
@@ -25,7 +25,6 @@ class Unit {
|
|
|
25
25
|
this.unlockBuilding = original.unlock.building;
|
|
26
26
|
this.unlockBuildingLevel = original.unlock.buildingLevel;
|
|
27
27
|
this.dps = rawUnit.dps[this.level - 1];
|
|
28
|
-
this.resourceType = rawSuperUnit.resource;
|
|
29
28
|
this.trainingTime = rawUnit.trainingTime;
|
|
30
29
|
const origin = data.troops.find((troop) => troop.village === 'home' && troop.name === original.name);
|
|
31
30
|
this.level = origin.level;
|
|
@@ -49,7 +48,6 @@ class Unit {
|
|
|
49
48
|
this.upgradeCost = rawUnit.upgrade.cost[this.level - 1] ?? 0;
|
|
50
49
|
this.upgradeTime = rawUnit.upgrade.time[this.level - 1] ?? 0;
|
|
51
50
|
this.dps = rawUnit.dps[this.level - 1];
|
|
52
|
-
this.resourceType = rawUnit.resourceType;
|
|
53
51
|
this.trainingTime = rawUnit.trainingTime;
|
|
54
52
|
if (rawUnit.category === 'hero')
|
|
55
53
|
this.regenerationTime = rawUnit.regenerationTimes[this.level - 1];
|
package/dist/struct/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/types/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/types/lib.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { QueueThrottler, BatchThrottler } from '../rest/Throttler';
|
|
2
2
|
export interface Store<T = any> {
|
|
3
|
-
set(key: string, value: T, ttl?: number)
|
|
4
|
-
get(key: string)
|
|
5
|
-
delete(key: string)
|
|
6
|
-
clear()
|
|
3
|
+
set: (key: string, value: T, ttl?: number) => boolean | Promise<boolean>;
|
|
4
|
+
get: (key: string) => T | null | Promise<T | null>;
|
|
5
|
+
delete: (key: string) => boolean | Promise<boolean>;
|
|
6
|
+
clear: () => void | Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
/** Options for a {@link Client} */
|
|
9
9
|
export interface ClientOptions {
|
package/dist/util/Constants.d.ts
CHANGED
|
@@ -24,25 +24,60 @@ export declare const Leagues: number[];
|
|
|
24
24
|
export declare const WarLeagues: number[];
|
|
25
25
|
export declare const FriendlyWarPreparationTimes: readonly [number, number, number, number, number, number, number, number, number, number, number, number];
|
|
26
26
|
export declare const PollingEvents: {
|
|
27
|
-
readonly NewSeasonStart: "newSeasonStart";
|
|
28
27
|
readonly ClanLoopStart: "clanLoopStart";
|
|
29
28
|
readonly ClanLoopEnd: "clanLoopEnd";
|
|
30
29
|
readonly PlayerLoopStart: "playerLoopStart";
|
|
31
30
|
readonly PlayerLoopEnd: "playerLoopEnd";
|
|
32
31
|
readonly WarLoopStart: "warLoopEnd";
|
|
33
32
|
readonly WarLoopEnd: "warLoopEnd";
|
|
33
|
+
readonly NewSeasonStart: "newSeasonStart";
|
|
34
34
|
readonly MaintenanceStart: "maintenanceStart";
|
|
35
35
|
readonly MaintenanceEnd: "maintenanceEnd";
|
|
36
36
|
readonly Error: "error";
|
|
37
37
|
readonly Debug: "debug";
|
|
38
38
|
};
|
|
39
|
+
export declare const ClientEvents: {
|
|
40
|
+
readonly Error: "error";
|
|
41
|
+
readonly Debug: "debug";
|
|
42
|
+
};
|
|
43
|
+
export declare const RestEvents: {
|
|
44
|
+
readonly Error: "error";
|
|
45
|
+
readonly Debug: "debug";
|
|
46
|
+
readonly RateLimited: "rateLimited";
|
|
47
|
+
};
|
|
39
48
|
export declare const CWLRounds: {
|
|
40
49
|
readonly PreviousRound: "warEnded";
|
|
41
50
|
readonly CurrentRound: "inWar";
|
|
42
51
|
readonly NextRound: "preparation";
|
|
43
52
|
};
|
|
44
53
|
export declare const RawData: {
|
|
45
|
-
RawUnits: {
|
|
54
|
+
RawUnits: ({
|
|
55
|
+
id: number;
|
|
56
|
+
name: string;
|
|
57
|
+
housingSpace: number;
|
|
58
|
+
village: string;
|
|
59
|
+
category: string;
|
|
60
|
+
subCategory: string;
|
|
61
|
+
unlock: {
|
|
62
|
+
hall: number;
|
|
63
|
+
cost: number;
|
|
64
|
+
time: number;
|
|
65
|
+
resource: string;
|
|
66
|
+
building: string;
|
|
67
|
+
buildingLevel: number;
|
|
68
|
+
};
|
|
69
|
+
trainingTime: number;
|
|
70
|
+
regenerationTimes: number[];
|
|
71
|
+
dps: number[];
|
|
72
|
+
upgrade: {
|
|
73
|
+
cost: number[];
|
|
74
|
+
time: number[];
|
|
75
|
+
resource: string;
|
|
76
|
+
};
|
|
77
|
+
seasonal: boolean;
|
|
78
|
+
levels: number[];
|
|
79
|
+
resourceType?: undefined;
|
|
80
|
+
} | {
|
|
46
81
|
id: number;
|
|
47
82
|
name: string;
|
|
48
83
|
housingSpace: number;
|
|
@@ -68,7 +103,7 @@ export declare const RawData: {
|
|
|
68
103
|
};
|
|
69
104
|
seasonal: boolean;
|
|
70
105
|
levels: number[];
|
|
71
|
-
}[];
|
|
106
|
+
})[];
|
|
72
107
|
RawSuperUnits: {
|
|
73
108
|
name: string;
|
|
74
109
|
id: number;
|
package/dist/util/Constants.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.RawData = exports.CWLRounds = exports.PollingEvents = exports.FriendlyWarPreparationTimes = exports.WarLeagues = exports.Leagues = exports.LegendLeagueId = exports.UnrankedLeagueData = exports.HeroPets = exports.Heroes = exports.BuilderTroops = exports.Spells = exports.DarkElixirSpells = exports.ElixirSpells = exports.SuperTroops = exports.SiegeMachines = exports.HomeTroops = exports.DarkElixirTroops = exports.ElixirTroops = exports.DevSiteAPIBaseURL = exports.APIBaseURL = void 0;
|
|
6
|
+
exports.RawData = exports.CWLRounds = exports.RestEvents = exports.ClientEvents = exports.PollingEvents = exports.FriendlyWarPreparationTimes = exports.WarLeagues = exports.Leagues = exports.LegendLeagueId = exports.UnrankedLeagueData = exports.HeroPets = exports.Heroes = exports.BuilderTroops = exports.Spells = exports.DarkElixirSpells = exports.ElixirSpells = exports.SuperTroops = exports.SiegeMachines = exports.HomeTroops = exports.DarkElixirTroops = exports.ElixirTroops = exports.DevSiteAPIBaseURL = exports.APIBaseURL = void 0;
|
|
7
7
|
const raw_json_1 = __importDefault(require("../util/raw.json"));
|
|
8
8
|
exports.APIBaseURL = 'https://api.clashofclans.com/v1';
|
|
9
9
|
exports.DevSiteAPIBaseURL = 'https://developer.clashofclans.com/api';
|
|
@@ -122,18 +122,27 @@ exports.FriendlyWarPreparationTimes = [
|
|
|
122
122
|
1000 * 60 * 5
|
|
123
123
|
];
|
|
124
124
|
exports.PollingEvents = {
|
|
125
|
-
NewSeasonStart: 'newSeasonStart',
|
|
126
125
|
ClanLoopStart: 'clanLoopStart',
|
|
127
126
|
ClanLoopEnd: 'clanLoopEnd',
|
|
128
127
|
PlayerLoopStart: 'playerLoopStart',
|
|
129
128
|
PlayerLoopEnd: 'playerLoopEnd',
|
|
130
129
|
WarLoopStart: 'warLoopEnd',
|
|
131
130
|
WarLoopEnd: 'warLoopEnd',
|
|
131
|
+
NewSeasonStart: 'newSeasonStart',
|
|
132
132
|
MaintenanceStart: 'maintenanceStart',
|
|
133
133
|
MaintenanceEnd: 'maintenanceEnd',
|
|
134
134
|
Error: 'error',
|
|
135
135
|
Debug: 'debug'
|
|
136
136
|
};
|
|
137
|
+
exports.ClientEvents = {
|
|
138
|
+
Error: 'error',
|
|
139
|
+
Debug: 'debug'
|
|
140
|
+
};
|
|
141
|
+
exports.RestEvents = {
|
|
142
|
+
Error: 'error',
|
|
143
|
+
Debug: 'debug',
|
|
144
|
+
RateLimited: 'rateLimited'
|
|
145
|
+
};
|
|
137
146
|
exports.CWLRounds = {
|
|
138
147
|
PreviousRound: 'warEnded',
|
|
139
148
|
CurrentRound: 'inWar',
|
package/dist/util/Util.js
CHANGED
|
@@ -114,8 +114,8 @@ class Util extends null {
|
|
|
114
114
|
}
|
|
115
115
|
/** Parse in-game army link into troops and spells count with respective Id's. */
|
|
116
116
|
static parseArmyLink(link) {
|
|
117
|
-
const unitsMatches =
|
|
118
|
-
const spellsMatches =
|
|
117
|
+
const unitsMatches = /u(?<units>[\d+x-]+)/.exec(link);
|
|
118
|
+
const spellsMatches = /s(?<spells>[\d+x-]+)/.exec(link);
|
|
119
119
|
const unitsPart = unitsMatches?.groups?.unit?.split('-') ?? [];
|
|
120
120
|
const spellParts = spellsMatches?.groups?.spells?.split('-') ?? [];
|
|
121
121
|
const units = unitsPart
|