clashofclans.js 3.0.0-dev.392ca4c → 3.0.0-dev.70cb1c7

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.
@@ -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 node_fetch_1 = __importDefault(require("node-fetch"));
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 https_1.default.Agent({ keepAlive: true });
26
- /** Represents a Request Handler. */
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
  }
@@ -0,0 +1,49 @@
1
+ import { Client } from '../client/Client';
2
+ import { APICapitalRaidSeason, APICapitalRaidSeasonAttackLog, APICapitalRaidSeasonDefenseLog, APICapitalRaidSeasonMember, OverrideOptions } from '../types';
3
+ import { Player } from './Player';
4
+ export declare class CapitalRaidSeasonMember {
5
+ /** The player's tag. */
6
+ name: string;
7
+ /** The player's name. */
8
+ tag: string;
9
+ /** The number of attacks the player has made. */
10
+ attacks: number;
11
+ /** The number of attacks the player can make. */
12
+ attackLimit: number;
13
+ /** The number of bonus attacks the player can make. */
14
+ bonusAttackLimit: number;
15
+ /** The number of capital resources the player has looted. */
16
+ capitalResourcesLooted: number;
17
+ constructor(data: APICapitalRaidSeasonMember);
18
+ }
19
+ /** Represents a Capital Raid Season. */
20
+ export declare class CapitalRaidSeason {
21
+ private readonly client;
22
+ /** The state of the raid season. */
23
+ state: 'ongoing' | 'ended';
24
+ /** The start time of the raid season. */
25
+ startTime: Date;
26
+ /** The end time of the raid season. */
27
+ endTime: Date;
28
+ /** The total loot collected from the capital. */
29
+ capitalTotalLoot: number;
30
+ /** The number of raids completed. */
31
+ raidsCompleted: number;
32
+ /** The total number of attacks. */
33
+ totalAttacks: number;
34
+ /** The number of enemy districts destroyed. */
35
+ enemyDistrictsDestroyed: number;
36
+ /** The offensive reward. */
37
+ offensiveReward: number;
38
+ /** The defensive reward. */
39
+ defensiveReward: number;
40
+ /** The members of the raid season. */
41
+ members: APICapitalRaidSeasonMember[];
42
+ /** The attack log of the raid season. */
43
+ attackLog: APICapitalRaidSeasonAttackLog[];
44
+ /** The defense log of the raid season. */
45
+ defenseLog: APICapitalRaidSeasonDefenseLog[];
46
+ constructor(client: Client, data: APICapitalRaidSeason);
47
+ /** Get {@link Player} info for every Player in the clan. */
48
+ fetchMembers(options?: OverrideOptions): Promise<Player[]>;
49
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CapitalRaidSeason = exports.CapitalRaidSeasonMember = void 0;
4
+ const Util_1 = require("../util/Util");
5
+ class CapitalRaidSeasonMember {
6
+ constructor(data) {
7
+ this.tag = data.tag;
8
+ this.name = data.name;
9
+ this.attacks = data.attacks;
10
+ this.attackLimit = data.attackLimit;
11
+ this.bonusAttackLimit = data.bonusAttackLimit;
12
+ this.capitalResourcesLooted = data.capitalResourcesLooted;
13
+ }
14
+ }
15
+ exports.CapitalRaidSeasonMember = CapitalRaidSeasonMember;
16
+ /** Represents a Capital Raid Season. */
17
+ class CapitalRaidSeason {
18
+ constructor(client, data) {
19
+ this.client = client;
20
+ this.state = data.state;
21
+ this.startTime = Util_1.Util.formatDate(data.startTime);
22
+ this.endTime = Util_1.Util.formatDate(data.endTime);
23
+ this.capitalTotalLoot = data.capitalTotalLoot;
24
+ this.raidsCompleted = data.raidsCompleted;
25
+ this.totalAttacks = data.totalAttacks;
26
+ this.enemyDistrictsDestroyed = data.enemyDistrictsDestroyed;
27
+ this.offensiveReward = data.offensiveReward;
28
+ this.defensiveReward = data.defensiveReward;
29
+ this.attackLog = data.attackLog;
30
+ this.defenseLog = data.defenseLog;
31
+ this.members = (data.members ?? []).map((member) => new CapitalRaidSeasonMember(member));
32
+ }
33
+ /** Get {@link Player} info for every Player in the clan. */
34
+ async fetchMembers(options) {
35
+ return (await Promise.allSettled(this.members.map((m) => this.client.getPlayer(m.tag, { ...options, ignoreRateLimit: true }))))
36
+ .filter((res) => res.status === 'fulfilled')
37
+ .map((res) => res.value);
38
+ }
39
+ }
40
+ exports.CapitalRaidSeason = CapitalRaidSeason;
@@ -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';
@@ -4,7 +4,7 @@ exports.ClanCapital = void 0;
4
4
  class ClanCapital {
5
5
  constructor(data) {
6
6
  this.capitalHallLevel = data.capitalHallLevel ?? null;
7
- this.districts = data.districts ? data.districts : null;
7
+ this.districts = data.districts ?? null;
8
8
  }
9
9
  }
10
10
  exports.ClanCapital = ClanCapital;
@@ -101,11 +101,21 @@ export declare class WarClan {
101
101
  /** Get clan's formatted link to open clan in-game. */
102
102
  get shareLink(): string;
103
103
  }
104
- /** Represents a Clan War in Clash of Clans. */
104
+ /**
105
+ * Represents a Clan War in Clash of Clans.
106
+ *
107
+ * :::caution
108
+ * It's recommended to see if ClanWar#state is `notInWar` available before performing operations or reading data from it. You can check this with data.ok property.
109
+ * :::
110
+ */
105
111
  export declare class ClanWar {
106
112
  client: Client;
107
- /** The clan's current war state. */
108
- state: 'preparation' | 'inWar' | 'warEnded';
113
+ /**
114
+ * The clan's current war state.
115
+ *
116
+ * :warning: Other properties won't be available if the state is `notInWar`.
117
+ */
118
+ state: 'preparation' | 'inWar' | 'warEnded' | 'notInWar';
109
119
  /** The number of players on each side. */
110
120
  teamSize: number;
111
121
  /** The number of attacks each member has. */
@@ -135,6 +145,8 @@ export declare class ClanWar {
135
145
  getAttack(attackerTag: string, defenderTag: string): ClanWarAttack | null;
136
146
  /** Return a list of {@link ClanWarAttack} for the defenderTag provided. */
137
147
  getDefenses(defenderTag: string): ClanWarAttack[];
148
+ /** Whether the clan is not in war. */
149
+ get isNotInWar(): boolean;
138
150
  /** Whether this is a Battle Day. */
139
151
  get isBattleDay(): boolean;
140
152
  /** Whether this is a Preparation Day. */
@@ -137,26 +137,33 @@ class WarClan {
137
137
  }
138
138
  }
139
139
  exports.WarClan = WarClan;
140
- /** Represents a Clan War in Clash of Clans. */
140
+ /**
141
+ * Represents a Clan War in Clash of Clans.
142
+ *
143
+ * :::caution
144
+ * It's recommended to see if ClanWar#state is `notInWar` available before performing operations or reading data from it. You can check this with data.ok property.
145
+ * :::
146
+ */
141
147
  class ClanWar {
142
148
  constructor(client, data, extra) {
143
149
  Object.defineProperty(this, 'client', { value: client });
144
- // @ts-expect-error
145
150
  this.state = data.state;
146
- this.teamSize = data.teamSize;
147
- this.attacksPerMember = data.attacksPerMember ?? (extra.warTag ? 1 : 2);
148
- this.preparationStartTime = client.util.formatDate(data.preparationStartTime);
149
- this.startTime = client.util.formatDate(data.startTime);
150
- this.endTime = client.util.formatDate(data.endTime);
151
- this.warTag = extra.warTag ?? null;
152
- let [clan, opponent] = [data.clan, data.opponent];
153
- const clanTag = extra.clanTag && client.util.formatTag(extra.clanTag);
154
- if (clanTag && [data.clan.tag, data.opponent.tag].includes(clanTag)) {
155
- clan = data.clan.tag === clanTag ? data.clan : data.opponent;
156
- opponent = data.clan.tag === clan.tag ? data.opponent : data.clan;
151
+ if (this.state !== 'notInWar') {
152
+ this.teamSize = data.teamSize;
153
+ this.attacksPerMember = data.attacksPerMember ?? (extra.warTag ? 1 : 2);
154
+ this.preparationStartTime = client.util.formatDate(data.preparationStartTime);
155
+ this.startTime = client.util.formatDate(data.startTime);
156
+ this.endTime = client.util.formatDate(data.endTime);
157
+ this.warTag = extra.warTag ?? null;
158
+ let [clan, opponent] = [data.clan, data.opponent];
159
+ const clanTag = extra.clanTag && client.util.formatTag(extra.clanTag);
160
+ if (clanTag && [data.clan.tag, data.opponent.tag].includes(clanTag)) {
161
+ clan = data.clan.tag === clanTag ? data.clan : data.opponent;
162
+ opponent = data.clan.tag === clan.tag ? data.opponent : data.clan;
163
+ }
164
+ this.clan = new WarClan(this, clan);
165
+ this.opponent = new WarClan(this, opponent);
157
166
  }
158
- this.clan = new WarClan(this, clan);
159
- this.opponent = new WarClan(this, opponent);
160
167
  this.maxAge = extra.maxAge;
161
168
  }
162
169
  /** Return a {@link ClanWarMember} with the tag provided. */
@@ -178,6 +185,10 @@ class ClanWar {
178
185
  }
179
186
  return this.opponent.attacks.filter((atk) => atk.defenderTag === defenderTag);
180
187
  }
188
+ /** Whether the clan is not in war. */
189
+ get isNotInWar() {
190
+ return this.state === 'notInWar';
191
+ }
181
192
  /** Whether this is a Battle Day. */
182
193
  get isBattleDay() {
183
194
  return this.state === 'inWar';
@@ -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. */
@@ -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';
@@ -39,8 +39,6 @@ export declare class Unit {
39
39
  seasonal: boolean;
40
40
  /** Damage per second of this unit. */
41
41
  dps: number;
42
- /** Resource type of this unit. */
43
- resourceType: string;
44
42
  /** Training time of this unit. */
45
43
  trainingTime: number;
46
44
  /** @internal */
@@ -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];
@@ -17,3 +17,5 @@ export * from './Ranking';
17
17
  export * from './Season';
18
18
  export * from './Unit';
19
19
  export * from './WarLeague';
20
+ export * from './ClanCapital';
21
+ export * from './CapitalRaidSeason';
@@ -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.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
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];
@@ -29,3 +33,5 @@ __exportStar(require("./Ranking"), exports);
29
33
  __exportStar(require("./Season"), exports);
30
34
  __exportStar(require("./Unit"), exports);
31
35
  __exportStar(require("./WarLeague"), exports);
36
+ __exportStar(require("./ClanCapital"), exports);
37
+ __exportStar(require("./CapitalRaidSeason"), exports);
@@ -169,6 +169,64 @@ export interface APIClanWarLeagueClanMember {
169
169
  export interface APIClanWarLeagueRound {
170
170
  warTags: string[];
171
171
  }
172
+ export interface APICapitalRaidSeason {
173
+ state: 'ongoing' | 'ended';
174
+ startTime: string;
175
+ endTime: string;
176
+ capitalTotalLoot: number;
177
+ raidsCompleted: number;
178
+ totalAttacks: number;
179
+ enemyDistrictsDestroyed: number;
180
+ offensiveReward: number;
181
+ defensiveReward: number;
182
+ members?: APICapitalRaidSeasonMember[];
183
+ attackLog: APICapitalRaidSeasonAttackLog[];
184
+ defenseLog: APICapitalRaidSeasonDefenseLog[];
185
+ }
186
+ export interface APICapitalRaidSeasonMember {
187
+ tag: string;
188
+ name: string;
189
+ attacks: number;
190
+ attackLimit: number;
191
+ bonusAttackLimit: number;
192
+ capitalResourcesLooted: number;
193
+ }
194
+ export interface APICapitalRaidSeasonClan {
195
+ tag: string;
196
+ name: string;
197
+ level: number;
198
+ badgeUrls: {
199
+ small: string;
200
+ large: string;
201
+ medium: string;
202
+ };
203
+ }
204
+ export interface APICapitalRaidSeasonDistrict {
205
+ id: number;
206
+ name: string;
207
+ districtHallLevel: number;
208
+ destructionPercent: number;
209
+ attackCount: number;
210
+ totalLooted: number;
211
+ }
212
+ export interface APICapitalRaidSeasonAttackLog {
213
+ defender: APICapitalRaidSeasonClan;
214
+ attackCount: number;
215
+ districtCount: number;
216
+ districtsDestroyed: number;
217
+ districts: APICapitalRaidSeasonDistrict[];
218
+ }
219
+ export interface APICapitalRaidSeasonDefenseLog {
220
+ attacker: APICapitalRaidSeasonClan;
221
+ attackCount: number;
222
+ districtCount: number;
223
+ districtsDestroyed: number;
224
+ districts: APICapitalRaidSeasonDistrict[];
225
+ }
226
+ export interface APICapitalRaidSeasons {
227
+ items: APICapitalRaidSeason[];
228
+ paging: APIPaging;
229
+ }
172
230
  /** /players/{playerTag} */
173
231
  export interface APIPlayer {
174
232
  name: string;
@@ -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.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
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];
@@ -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): boolean | Promise<boolean>;
4
- get(key: string): T | null | Promise<T | null>;
5
- delete(key: string): boolean | Promise<boolean>;
6
- clear(): void | Promise<void>;
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 {
@@ -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;
@@ -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';
@@ -22,11 +22,20 @@ exports.ElixirTroops = [
22
22
  'Miner',
23
23
  'Electro Dragon',
24
24
  'Yeti',
25
- 'Dragon Rider'
25
+ 'Dragon Rider',
26
+ 'Electro Titan'
26
27
  ];
27
28
  exports.DarkElixirTroops = ['Minion', 'Hog Rider', 'Valkyrie', 'Golem', 'Witch', 'Lava Hound', 'Bowler', 'Ice Golem', 'Headhunter'];
28
29
  exports.HomeTroops = [...exports.ElixirTroops, ...exports.DarkElixirTroops];
29
- exports.SiegeMachines = ['Wall Wrecker', 'Battle Blimp', 'Stone Slammer', 'Siege Barracks', 'Log Launcher', 'Flame Flinger'];
30
+ exports.SiegeMachines = [
31
+ 'Wall Wrecker',
32
+ 'Battle Blimp',
33
+ 'Stone Slammer',
34
+ 'Siege Barracks',
35
+ 'Log Launcher',
36
+ 'Flame Flinger',
37
+ 'Battle Drill'
38
+ ];
30
39
  exports.SuperTroops = [
31
40
  'Super Barbarian',
32
41
  'Super Archer',
@@ -50,7 +59,8 @@ exports.ElixirSpells = [
50
59
  'Jump Spell',
51
60
  'Freeze Spell',
52
61
  'Clone Spell',
53
- 'Invisibility Spell'
62
+ 'Invisibility Spell',
63
+ 'Recall Spell'
54
64
  ];
55
65
  exports.DarkElixirSpells = ['Poison Spell', 'Earthquake Spell', 'Haste Spell', 'Skeleton Spell', 'Bat Spell'];
56
66
  exports.Spells = [...exports.ElixirSpells, ...exports.DarkElixirSpells];
@@ -68,7 +78,7 @@ exports.BuilderTroops = [
68
78
  'Hog Glider'
69
79
  ];
70
80
  exports.Heroes = ['Barbarian King', 'Archer Queen', 'Grand Warden', 'Royal Champion', 'Battle Machine'];
71
- exports.HeroPets = ['L.A.S.S.I', 'Electro Owl', 'Mighty Yak', 'Unicorn'];
81
+ exports.HeroPets = ['L.A.S.S.I', 'Electro Owl', 'Mighty Yak', 'Unicorn', 'Poison Lizard', 'Diggy', 'Frosty', 'Phoenix'];
72
82
  exports.UnrankedLeagueData = {
73
83
  id: 29000000,
74
84
  name: 'Unranked',
@@ -122,18 +132,27 @@ exports.FriendlyWarPreparationTimes = [
122
132
  1000 * 60 * 5
123
133
  ];
124
134
  exports.PollingEvents = {
125
- NewSeasonStart: 'newSeasonStart',
126
135
  ClanLoopStart: 'clanLoopStart',
127
136
  ClanLoopEnd: 'clanLoopEnd',
128
137
  PlayerLoopStart: 'playerLoopStart',
129
138
  PlayerLoopEnd: 'playerLoopEnd',
130
139
  WarLoopStart: 'warLoopEnd',
131
140
  WarLoopEnd: 'warLoopEnd',
141
+ NewSeasonStart: 'newSeasonStart',
132
142
  MaintenanceStart: 'maintenanceStart',
133
143
  MaintenanceEnd: 'maintenanceEnd',
134
144
  Error: 'error',
135
145
  Debug: 'debug'
136
146
  };
147
+ exports.ClientEvents = {
148
+ Error: 'error',
149
+ Debug: 'debug'
150
+ };
151
+ exports.RestEvents = {
152
+ Error: 'error',
153
+ Debug: 'debug',
154
+ RateLimited: 'rateLimited'
155
+ };
137
156
  exports.CWLRounds = {
138
157
  PreviousRound: 'warEnded',
139
158
  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 = link.match(/u(?<units>[\d+x-]+)/);
118
- const spellsMatches = link.match(/s(?<spells>[\d+x-]+)/);
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