clashofclans.js 2.8.0-dev.73631cc → 2.8.0-dev.8f7faa6

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/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './client/Client';
2
+ export * from './client/PollingClient';
2
3
  export * from './rest/RESTManager';
3
4
  export * from './rest/RequestHandler';
4
5
  export * from './rest/HTTPError';
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./client/Client"), exports);
14
+ __exportStar(require("./client/PollingClient"), exports);
14
15
  __exportStar(require("./rest/RESTManager"), exports);
15
16
  __exportStar(require("./rest/RequestHandler"), exports);
16
17
  __exportStar(require("./rest/HTTPError"), exports);
package/dist/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  import mod from "./index.js";
2
2
 
3
3
  export default mod;
4
- export const API_BASE_URL = mod.API_BASE_URL;
4
+ export const APIBaseURL = mod.APIBaseURL;
5
5
  export const Achievement = mod.Achievement;
6
- export const BUILDER_TROOPS = mod.BUILDER_TROOPS;
7
6
  export const Badge = mod.Badge;
8
7
  export const BatchThrottler = mod.BatchThrottler;
9
- export const CWL_ROUNDS = mod.CWL_ROUNDS;
8
+ export const BuilderTroops = mod.BuilderTroops;
9
+ export const CWLRounds = mod.CWLRounds;
10
10
  export const CacheStore = mod.CacheStore;
11
11
  export const ChatLanguage = mod.ChatLanguage;
12
12
  export const Clan = mod.Clan;
@@ -20,48 +20,49 @@ export const ClanWarLeagueRound = mod.ClanWarLeagueRound;
20
20
  export const ClanWarLog = mod.ClanWarLog;
21
21
  export const ClanWarMember = mod.ClanWarMember;
22
22
  export const Client = mod.Client;
23
- export const DARK_ELIXIR_SPELLS = mod.DARK_ELIXIR_SPELLS;
24
- export const DARK_ELIXIR_TROOPS = mod.DARK_ELIXIR_TROOPS;
25
- export const DEV_SITE_API_BASE_URL = mod.DEV_SITE_API_BASE_URL;
26
- export const ELIXIR_SPELLS = mod.ELIXIR_SPELLS;
27
- export const ELIXIR_TROOPS = mod.ELIXIR_TROOPS;
28
- export const EVENTS = mod.EVENTS;
29
- export const EventManager = mod.EventManager;
30
- export const FRIENDLY_WAR_PREPARATION_TIMES = mod.FRIENDLY_WAR_PREPARATION_TIMES;
23
+ export const DarkElixirSpells = mod.DarkElixirSpells;
24
+ export const DarkElixirTroops = mod.DarkElixirTroops;
25
+ export const DevSiteAPIBaseURL = mod.DevSiteAPIBaseURL;
26
+ export const ElixirSpells = mod.ElixirSpells;
27
+ export const ElixirTroops = mod.ElixirTroops;
28
+ export const FriendlyWarPreparationTimes = mod.FriendlyWarPreparationTimes;
31
29
  export const GoldPassSeason = mod.GoldPassSeason;
32
- export const HEROES = mod.HEROES;
33
- export const HERO_PETS = mod.HERO_PETS;
34
- export const HOME_TROOPS = mod.HOME_TROOPS;
35
30
  export const HTTPError = mod.HTTPError;
36
31
  export const Hero = mod.Hero;
32
+ export const HeroPets = mod.HeroPets;
33
+ export const Heroes = mod.Heroes;
34
+ export const HomeTroops = mod.HomeTroops;
37
35
  export const Icon = mod.Icon;
38
- export const LEAGUES = mod.LEAGUES;
39
- export const LEGEND_LEAGUE_ID = mod.LEGEND_LEAGUE_ID;
40
36
  export const Label = mod.Label;
41
37
  export const League = mod.League;
38
+ export const Leagues = mod.Leagues;
39
+ export const LegendLeagueId = mod.LegendLeagueId;
42
40
  export const LegendStatistics = mod.LegendStatistics;
43
41
  export const Location = mod.Location;
44
42
  export const NotInWarError = mod.NotInWarError;
45
43
  export const Player = mod.Player;
46
44
  export const PlayerClan = mod.PlayerClan;
45
+ export const PollingClient = mod.PollingClient;
46
+ export const PollingEventManager = mod.PollingEventManager;
47
+ export const PollingEvents = mod.PollingEvents;
47
48
  export const PrivateWarLogError = mod.PrivateWarLogError;
48
49
  export const QueueThrottler = mod.QueueThrottler;
49
- export const RAW_DATA = mod.RAW_DATA;
50
50
  export const RESTManager = mod.RESTManager;
51
51
  export const RankedClan = mod.RankedClan;
52
52
  export const RankedPlayer = mod.RankedPlayer;
53
+ export const RawData = mod.RawData;
53
54
  export const RequestHandler = mod.RequestHandler;
54
- export const SIEGE_MACHINES = mod.SIEGE_MACHINES;
55
- export const SPELLS = mod.SPELLS;
56
- export const SUPER_TROOPS = mod.SUPER_TROOPS;
57
55
  export const Season = mod.Season;
58
56
  export const SeasonRankedPlayer = mod.SeasonRankedPlayer;
57
+ export const SiegeMachines = mod.SiegeMachines;
59
58
  export const Spell = mod.Spell;
59
+ export const Spells = mod.Spells;
60
+ export const SuperTroops = mod.SuperTroops;
60
61
  export const Troop = mod.Troop;
61
- export const UNRANKED_LEAGUE_DATA = mod.UNRANKED_LEAGUE_DATA;
62
62
  export const Unit = mod.Unit;
63
+ export const UnrankedLeagueData = mod.UnrankedLeagueData;
63
64
  export const Util = mod.Util;
64
- export const WAR_LEAGUES = mod.WAR_LEAGUES;
65
65
  export const WarClan = mod.WarClan;
66
66
  export const WarLeague = mod.WarLeague;
67
+ export const WarLeagues = mod.WarLeagues;
67
68
  export const WarLogClan = mod.WarLogClan;
@@ -30,7 +30,7 @@ class RequestHandler {
30
30
  this.keys = options?.keys ?? [];
31
31
  this.retryLimit = options?.retryLimit ?? 0;
32
32
  this.throttler = options?.throttler ?? null;
33
- this.baseURL = options?.baseURL ?? Constants_1.API_BASE_URL;
33
+ this.baseURL = options?.baseURL ?? Constants_1.APIBaseURL;
34
34
  this.restRequestTimeout = options?.restRequestTimeout ?? 0;
35
35
  this.rejectIfNotValid = options?.rejectIfNotValid ?? true;
36
36
  if (typeof options?.cache === 'object')
@@ -120,7 +120,7 @@ class RequestHandler {
120
120
  }
121
121
  }
122
122
  async login() {
123
- const res = await (0, node_fetch_1.default)(`${Constants_1.DEV_SITE_API_BASE_URL}/login`, {
123
+ const res = await (0, node_fetch_1.default)(`${Constants_1.DevSiteAPIBaseURL}/login`, {
124
124
  method: 'POST',
125
125
  timeout: 10000,
126
126
  headers: { 'Content-Type': 'application/json' },
@@ -135,7 +135,7 @@ class RequestHandler {
135
135
  return this.getKeys(res.headers.get('set-cookie'), ip);
136
136
  }
137
137
  async getKeys(cookie, ip) {
138
- const res = await (0, node_fetch_1.default)(`${Constants_1.DEV_SITE_API_BASE_URL}/apikey/list`, {
138
+ const res = await (0, node_fetch_1.default)(`${Constants_1.DevSiteAPIBaseURL}/apikey/list`, {
139
139
  method: 'POST',
140
140
  timeout: 10000,
141
141
  headers: { 'Content-Type': 'application/json', cookie }
@@ -177,7 +177,7 @@ class RequestHandler {
177
177
  return this.keys;
178
178
  }
179
179
  async revokeKey(keyId, cookie) {
180
- const res = await (0, node_fetch_1.default)(`${Constants_1.DEV_SITE_API_BASE_URL}/apikey/revoke`, {
180
+ const res = await (0, node_fetch_1.default)(`${Constants_1.DevSiteAPIBaseURL}/apikey/revoke`, {
181
181
  method: 'POST',
182
182
  timeout: 10000,
183
183
  body: JSON.stringify({ id: keyId }),
@@ -186,7 +186,7 @@ class RequestHandler {
186
186
  return res.ok;
187
187
  }
188
188
  async createKey(cookie, ip) {
189
- const res = await (0, node_fetch_1.default)(`${Constants_1.DEV_SITE_API_BASE_URL}/apikey/create`, {
189
+ const res = await (0, node_fetch_1.default)(`${Constants_1.DevSiteAPIBaseURL}/apikey/create`, {
190
190
  method: 'POST',
191
191
  timeout: 10000,
192
192
  headers: { 'Content-Type': 'application/json', cookie },
@@ -7,6 +7,7 @@ import type { Player } from './Player';
7
7
  import { Location } from './Location';
8
8
  import { Label } from './Label';
9
9
  import { Badge } from './Badge';
10
+ import { ClanCapital } from './ClanCapital';
10
11
  /** Represents a Clan. */
11
12
  export declare class Clan {
12
13
  client: Client;
@@ -54,6 +55,8 @@ export declare class Clan {
54
55
  memberCount: number;
55
56
  /** An array of {@link Label} that the clan has. */
56
57
  labels: Label[];
58
+ /** The clan's Clan Capital information */
59
+ clanCapital: ClanCapital | null;
57
60
  /**
58
61
  * List of clan members.
59
62
  * - This property returns empty array for {@link Client.getClans} method.
@@ -7,6 +7,7 @@ const WarLeague_1 = require("./WarLeague");
7
7
  const Location_1 = require("./Location");
8
8
  const Label_1 = require("./Label");
9
9
  const Badge_1 = require("./Badge");
10
+ const ClanCapital_1 = require("./ClanCapital");
10
11
  /** Represents a Clan. */
11
12
  class Clan {
12
13
  constructor(client, data) {
@@ -33,6 +34,7 @@ class Clan {
33
34
  this.warLeague = data.warLeague ? new WarLeague_1.WarLeague(data.warLeague) : null;
34
35
  this.memberCount = data.members;
35
36
  this.labels = data.labels.map((label) => new Label_1.Label(label));
37
+ this.clanCapital = Object.keys(data.clanCapital).length > 0 ? new ClanCapital_1.ClanCapital(data.clanCapital) : null;
36
38
  this.members = data.memberList?.map((mem) => new ClanMember_1.ClanMember(this.client, mem)) ?? []; // eslint-disable-line
37
39
  }
38
40
  /** Get {@link Player} info for every Player in the clan. */
@@ -0,0 +1,12 @@
1
+ import { APIClanCapital } from '../types';
2
+ export declare class ClanCapital {
3
+ /** The clan capital hall level */
4
+ capitalHallLevel: number | null;
5
+ /** The clan capital districts */
6
+ districts: {
7
+ id: number;
8
+ name: string;
9
+ districtHallLevel: number;
10
+ }[] | null;
11
+ constructor(data: APIClanCapital);
12
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClanCapital = void 0;
4
+ class ClanCapital {
5
+ constructor(data) {
6
+ this.capitalHallLevel = data.capitalHallLevel ?? null;
7
+ this.districts = data.districts ? data.districts : null;
8
+ }
9
+ }
10
+ exports.ClanCapital = ClanCapital;
@@ -12,7 +12,7 @@ class ClanMember {
12
12
  this.role = data.role.replace('admin', 'elder');
13
13
  this.expLevel = data.expLevel;
14
14
  // eslint-disable-next-line
15
- this.league = new League_1.League(data.league ?? Constants_1.UNRANKED_LEAGUE_DATA);
15
+ this.league = new League_1.League(data.league ?? Constants_1.UnrankedLeagueData);
16
16
  this.trophies = data.trophies;
17
17
  this.versusTrophies = data.versusTrophies ?? null;
18
18
  this.clanRank = data.clanRank;
@@ -201,7 +201,7 @@ class ClanWar {
201
201
  /** Whether this is a friendly war. */
202
202
  get isFriendly() {
203
203
  const preparationTime = this.startTime.getTime() - this.preparationStartTime.getTime();
204
- return Constants_1.FRIENDLY_WAR_PREPARATION_TIMES.includes(preparationTime);
204
+ return Constants_1.FriendlyWarPreparationTimes.includes(preparationTime);
205
205
  }
206
206
  /** Whether this is a CWL. */
207
207
  get isCWL() {
@@ -12,7 +12,7 @@ class League {
12
12
  }
13
13
  /** Position of this League. Starting from 0 (Un-ranked) */
14
14
  get position() {
15
- return Constants_1.LEAGUES.indexOf(this.id);
15
+ return Constants_1.Leagues.indexOf(this.id);
16
16
  }
17
17
  }
18
18
  exports.League = League;
@@ -41,6 +41,8 @@ export declare class Player {
41
41
  donations: number;
42
42
  /** The player's donation received count for this season. */
43
43
  received: number;
44
+ /** The player's total Clan Capital contribution */
45
+ clanCapitalContributions: number;
44
46
  /** The player's role in the clan or `null` if not in a clan. */
45
47
  role: 'member' | 'elder' | 'coLeader' | 'leader' | null;
46
48
  /** Whether the player has selected that they are opted in. This will be `null` if the player is not in a clan. */
@@ -28,11 +28,12 @@ class Player {
28
28
  this.versusBattleWins = data.versusBattleWins ?? null;
29
29
  this.donations = data.donations;
30
30
  this.received = data.donationsReceived;
31
+ this.clanCapitalContributions = data.clanCapitalContributions;
31
32
  // @ts-expect-error
32
33
  this.role = data.role?.replace('admin', 'elder') ?? null;
33
34
  this.warOptedIn = data.warPreference ? data.warPreference === 'in' : null;
34
35
  this.clan = data.clan ? new PlayerClan_1.PlayerClan(client, data.clan) : null;
35
- this.league = new League_1.League(data.league ?? Constants_1.UNRANKED_LEAGUE_DATA);
36
+ this.league = new League_1.League(data.league ?? Constants_1.UnrankedLeagueData);
36
37
  this.legendStatistics = data.legendStatistics ? new LegendStatistics_1.LegendStatistics(data.legendStatistics) : null;
37
38
  this.achievements = data.achievements.map((data) => new Achievement_1.Achievement(data));
38
39
  this.labels = data.labels.map((data) => new Label_1.Label(data));
@@ -69,32 +70,32 @@ class Player {
69
70
  /** An array of the player's home base troops. */
70
71
  get homeTroops() {
71
72
  return this.troops
72
- .filter((entry) => Constants_1.HOME_TROOPS.includes(entry.name))
73
- .sort((a, b) => Constants_1.HOME_TROOPS.indexOf(a.name) - Constants_1.HOME_TROOPS.indexOf(b.name));
73
+ .filter((entry) => Constants_1.HomeTroops.includes(entry.name))
74
+ .sort((a, b) => Constants_1.HomeTroops.indexOf(a.name) - Constants_1.HomeTroops.indexOf(b.name));
74
75
  }
75
76
  /** An array of the player's builder base troops. */
76
77
  get builderTroops() {
77
78
  return this.troops
78
- .filter((entry) => Constants_1.BUILDER_TROOPS.includes(entry.name))
79
- .sort((a, b) => Constants_1.BUILDER_TROOPS.indexOf(a.name) - Constants_1.BUILDER_TROOPS.indexOf(b.name));
79
+ .filter((entry) => Constants_1.BuilderTroops.includes(entry.name))
80
+ .sort((a, b) => Constants_1.BuilderTroops.indexOf(a.name) - Constants_1.BuilderTroops.indexOf(b.name));
80
81
  }
81
82
  /** An array of the player's super troops. */
82
83
  get superTroops() {
83
84
  return this.troops
84
- .filter((entry) => Constants_1.SUPER_TROOPS.includes(entry.name))
85
- .sort((a, b) => Constants_1.SUPER_TROOPS.indexOf(a.name) - Constants_1.SUPER_TROOPS.indexOf(b.name));
85
+ .filter((entry) => Constants_1.SuperTroops.includes(entry.name))
86
+ .sort((a, b) => Constants_1.SuperTroops.indexOf(a.name) - Constants_1.SuperTroops.indexOf(b.name));
86
87
  }
87
88
  /** An array of the player's hero pets. */
88
89
  get heroPets() {
89
90
  return this.troops
90
- .filter((entry) => Constants_1.HERO_PETS.includes(entry.name))
91
- .sort((a, b) => Constants_1.HERO_PETS.indexOf(a.name) - Constants_1.HERO_PETS.indexOf(b.name));
91
+ .filter((entry) => Constants_1.HeroPets.includes(entry.name))
92
+ .sort((a, b) => Constants_1.HeroPets.indexOf(a.name) - Constants_1.HeroPets.indexOf(b.name));
92
93
  }
93
94
  /** An array of the player's siege machines. */
94
95
  get siegeMachines() {
95
96
  return this.troops
96
- .filter((entry) => Constants_1.SIEGE_MACHINES.includes(entry.name))
97
- .sort((a, b) => Constants_1.SIEGE_MACHINES.indexOf(a.name) - Constants_1.SIEGE_MACHINES.indexOf(b.name));
97
+ .filter((entry) => Constants_1.SiegeMachines.includes(entry.name))
98
+ .sort((a, b) => Constants_1.SiegeMachines.indexOf(a.name) - Constants_1.SiegeMachines.indexOf(b.name));
98
99
  }
99
100
  /** Get player's formatted link to open player in-game. */
100
101
  get shareLink() {
@@ -46,7 +46,7 @@ class RankedPlayer {
46
46
  // @ts-expect-error
47
47
  this.clan = data.clan ? new PlayerClan_1.PlayerClan(client, data.clan) : null;
48
48
  // @ts-expect-error
49
- this.league = data.trophies ? new League_1.League(data.league ?? Constants_1.UNRANKED_LEAGUE_DATA) : null; // eslint-disable-line
49
+ this.league = data.trophies ? new League_1.League(data.league ?? Constants_1.UnrankedLeagueData) : null; // eslint-disable-line
50
50
  }
51
51
  /** Get player's formatted link to open player in-game. */
52
52
  get shareLink() {
@@ -10,14 +10,14 @@ class Unit {
10
10
  this.level = unit.level;
11
11
  this.maxLevel = unit.maxLevel;
12
12
  this.village = unit.village;
13
- const rawSuperUnit = Constants_1.RAW_DATA.RAW_SUPER_UNITS.find((unit) => unit.name === this.name && this.isHomeBase);
14
- const rawUnit = Constants_1.RAW_DATA.RAW_UNITS.find((unit) => unit.name === this.name && unit.village === this.village);
13
+ const rawSuperUnit = Constants_1.RawData.RawSuperUnits.find((unit) => unit.name === this.name && this.isHomeBase);
14
+ const rawUnit = Constants_1.RawData.RawUnits.find((unit) => unit.name === this.name && unit.village === this.village);
15
15
  if (rawSuperUnit) {
16
16
  this.id = rawSuperUnit.id;
17
17
  this.housingSpace = rawSuperUnit.housingSpace;
18
18
  this.originalName = rawSuperUnit.original;
19
19
  this.minOriginalLevel = rawSuperUnit.minOriginalLevel;
20
- const original = Constants_1.RAW_DATA.RAW_UNITS.find((unit) => unit.village === 'home' && unit.name === rawSuperUnit.original);
20
+ const original = Constants_1.RawData.RawUnits.find((unit) => unit.village === 'home' && unit.name === rawSuperUnit.original);
21
21
  this.unlockHallLevel = original.levels.findIndex((level) => level >= rawSuperUnit.minOriginalLevel) + 1;
22
22
  this.unlockCost = original.unlock.cost;
23
23
  this.unlockTime = original.unlock.time;
@@ -87,7 +87,7 @@ class Troop extends Unit {
87
87
  }
88
88
  /** Whether this troop is a Super Troop. */
89
89
  get isSuperTroop() {
90
- return this.isActive || (this.isHomeBase && Constants_1.SUPER_TROOPS.includes(this.name));
90
+ return this.isActive || (this.isHomeBase && Constants_1.SuperTroops.includes(this.name));
91
91
  }
92
92
  }
93
93
  exports.Troop = Troop;
@@ -10,7 +10,7 @@ class WarLeague {
10
10
  }
11
11
  /** Position of this War League. Starting from 0 (Unranked) */
12
12
  get position() {
13
- return Constants_1.WAR_LEAGUES.indexOf(this.id);
13
+ return Constants_1.WarLeagues.indexOf(this.id);
14
14
  }
15
15
  }
16
16
  exports.WarLeague = WarLeague;
@@ -57,6 +57,7 @@ export interface APIClan {
57
57
  members: number;
58
58
  labels: APILabel[];
59
59
  memberList: APIClanMember[];
60
+ clanCapital: APIClanCapital;
60
61
  }
61
62
  export interface APIClanMember {
62
63
  name: string;
@@ -71,6 +72,14 @@ export interface APIClanMember {
71
72
  donations: number;
72
73
  donationsReceived: number;
73
74
  }
75
+ export interface APIClanCapital {
76
+ capitalHallLevel?: number;
77
+ districts?: {
78
+ id: number;
79
+ name: string;
80
+ districtHallLevel: number;
81
+ }[];
82
+ }
74
83
  /** /clans/{clanTag}/members */
75
84
  export interface APIClanMemberList {
76
85
  items: APIClanMember[];
@@ -179,6 +188,7 @@ export interface APIPlayer {
179
188
  versusBattleWinCount?: number;
180
189
  donations: number;
181
190
  donationsReceived: number;
191
+ clanCapitalContributions: number;
182
192
  role?: string;
183
193
  warPreference?: 'in' | 'out';
184
194
  clan?: APIPlayerClan;
@@ -1,17 +1,17 @@
1
- export declare const API_BASE_URL = "https://api.clashofclans.com/v1";
2
- export declare const DEV_SITE_API_BASE_URL = "https://developer.clashofclans.com/api";
3
- export declare const ELIXIR_TROOPS: string[];
4
- export declare const DARK_ELIXIR_TROOPS: string[];
5
- export declare const HOME_TROOPS: string[];
6
- export declare const SIEGE_MACHINES: string[];
7
- export declare const SUPER_TROOPS: string[];
8
- export declare const ELIXIR_SPELLS: string[];
9
- export declare const DARK_ELIXIR_SPELLS: string[];
10
- export declare const SPELLS: string[];
11
- export declare const BUILDER_TROOPS: string[];
12
- export declare const HEROES: string[];
13
- export declare const HERO_PETS: string[];
14
- export declare const UNRANKED_LEAGUE_DATA: {
1
+ export declare const APIBaseURL = "https://api.clashofclans.com/v1";
2
+ export declare const DevSiteAPIBaseURL = "https://developer.clashofclans.com/api";
3
+ export declare const ElixirTroops: string[];
4
+ export declare const DarkElixirTroops: string[];
5
+ export declare const HomeTroops: string[];
6
+ export declare const SiegeMachines: string[];
7
+ export declare const SuperTroops: string[];
8
+ export declare const ElixirSpells: string[];
9
+ export declare const DarkElixirSpells: string[];
10
+ export declare const Spells: string[];
11
+ export declare const BuilderTroops: string[];
12
+ export declare const Heroes: string[];
13
+ export declare const HeroPets: string[];
14
+ export declare const UnrankedLeagueData: {
15
15
  id: number;
16
16
  name: string;
17
17
  iconUrls: {
@@ -19,30 +19,30 @@ export declare const UNRANKED_LEAGUE_DATA: {
19
19
  tiny: string;
20
20
  };
21
21
  };
22
- export declare const LEGEND_LEAGUE_ID = 29000022;
23
- export declare const LEAGUES: number[];
24
- export declare const WAR_LEAGUES: number[];
25
- export declare const FRIENDLY_WAR_PREPARATION_TIMES: readonly [number, number, number, number, number, number, number, number, number, number, number, number];
26
- export declare const EVENTS: {
27
- readonly NEW_SEASON_START: "newSeasonStart";
28
- readonly CLAN_LOOP_START: "clanLoopStart";
29
- readonly CLAN_LOOP_END: "clanLoopEnd";
30
- readonly PLAYER_LOOP_START: "playerLoopStart";
31
- readonly PLAYER_LOOP_END: "playerLoopEnd";
32
- readonly WAR_LOOP_START: "warLoopEnd";
33
- readonly WAR_LOOP_END: "warLoopEnd";
34
- readonly MAINTENANCE_START: "maintenanceStart";
35
- readonly MAINTENANCE_END: "maintenanceEnd";
36
- readonly ERROR: "error";
37
- readonly DEBUG: "debug";
22
+ export declare const LegendLeagueId = 29000022;
23
+ export declare const Leagues: number[];
24
+ export declare const WarLeagues: number[];
25
+ export declare const FriendlyWarPreparationTimes: readonly [number, number, number, number, number, number, number, number, number, number, number, number];
26
+ export declare const PollingEvents: {
27
+ readonly NewSeasonStart: "newSeasonStart";
28
+ readonly ClanLoopStart: "clanLoopStart";
29
+ readonly ClanLoopEnd: "clanLoopEnd";
30
+ readonly PlayerLoopStart: "playerLoopStart";
31
+ readonly PlayerLoopEnd: "playerLoopEnd";
32
+ readonly WarLoopStart: "warLoopEnd";
33
+ readonly WarLoopEnd: "warLoopEnd";
34
+ readonly MaintenanceStart: "maintenanceStart";
35
+ readonly MaintenanceEnd: "maintenanceEnd";
36
+ readonly Error: "error";
37
+ readonly Debug: "debug";
38
38
  };
39
- export declare const CWL_ROUNDS: {
40
- readonly PREVIOUS_ROUND: "warEnded";
41
- readonly CURRENT_ROUND: "inWar";
42
- readonly NEXT_ROUND: "preparation";
39
+ export declare const CWLRounds: {
40
+ readonly PreviousRound: "warEnded";
41
+ readonly CurrentRound: "inWar";
42
+ readonly NextRound: "preparation";
43
43
  };
44
- export declare const RAW_DATA: {
45
- RAW_UNITS: {
44
+ export declare const RawData: {
45
+ RawUnits: {
46
46
  id: number;
47
47
  name: string;
48
48
  housingSpace: number;
@@ -69,7 +69,7 @@ export declare const RAW_DATA: {
69
69
  seasonal: boolean;
70
70
  levels: number[];
71
71
  }[];
72
- RAW_SUPER_UNITS: {
72
+ RawSuperUnits: {
73
73
  name: string;
74
74
  id: number;
75
75
  original: string;
@@ -3,11 +3,11 @@ 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.RAW_DATA = exports.CWL_ROUNDS = exports.EVENTS = exports.FRIENDLY_WAR_PREPARATION_TIMES = exports.WAR_LEAGUES = exports.LEAGUES = exports.LEGEND_LEAGUE_ID = exports.UNRANKED_LEAGUE_DATA = exports.HERO_PETS = exports.HEROES = exports.BUILDER_TROOPS = exports.SPELLS = exports.DARK_ELIXIR_SPELLS = exports.ELIXIR_SPELLS = exports.SUPER_TROOPS = exports.SIEGE_MACHINES = exports.HOME_TROOPS = exports.DARK_ELIXIR_TROOPS = exports.ELIXIR_TROOPS = exports.DEV_SITE_API_BASE_URL = exports.API_BASE_URL = void 0;
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;
7
7
  const raw_json_1 = __importDefault(require("../util/raw.json"));
8
- exports.API_BASE_URL = 'https://api.clashofclans.com/v1';
9
- exports.DEV_SITE_API_BASE_URL = 'https://developer.clashofclans.com/api';
10
- exports.ELIXIR_TROOPS = [
8
+ exports.APIBaseURL = 'https://api.clashofclans.com/v1';
9
+ exports.DevSiteAPIBaseURL = 'https://developer.clashofclans.com/api';
10
+ exports.ElixirTroops = [
11
11
  'Barbarian',
12
12
  'Archer',
13
13
  'Giant',
@@ -24,10 +24,10 @@ exports.ELIXIR_TROOPS = [
24
24
  'Yeti',
25
25
  'Dragon Rider'
26
26
  ];
27
- exports.DARK_ELIXIR_TROOPS = ['Minion', 'Hog Rider', 'Valkyrie', 'Golem', 'Witch', 'Lava Hound', 'Bowler', 'Ice Golem', 'Headhunter'];
28
- exports.HOME_TROOPS = [...exports.ELIXIR_TROOPS, ...exports.DARK_ELIXIR_TROOPS];
29
- exports.SIEGE_MACHINES = ['Wall Wrecker', 'Battle Blimp', 'Stone Slammer', 'Siege Barracks', 'Log Launcher', 'Flame Flinger'];
30
- exports.SUPER_TROOPS = [
27
+ exports.DarkElixirTroops = ['Minion', 'Hog Rider', 'Valkyrie', 'Golem', 'Witch', 'Lava Hound', 'Bowler', 'Ice Golem', 'Headhunter'];
28
+ exports.HomeTroops = [...exports.ElixirTroops, ...exports.DarkElixirTroops];
29
+ exports.SiegeMachines = ['Wall Wrecker', 'Battle Blimp', 'Stone Slammer', 'Siege Barracks', 'Log Launcher', 'Flame Flinger'];
30
+ exports.SuperTroops = [
31
31
  'Super Barbarian',
32
32
  'Super Archer',
33
33
  'Super Giant',
@@ -43,7 +43,7 @@ exports.SUPER_TROOPS = [
43
43
  'Ice Hound',
44
44
  'Super Bowler'
45
45
  ];
46
- exports.ELIXIR_SPELLS = [
46
+ exports.ElixirSpells = [
47
47
  'Lightning Spell',
48
48
  'Healing Spell',
49
49
  'Rage Spell',
@@ -52,9 +52,9 @@ exports.ELIXIR_SPELLS = [
52
52
  'Clone Spell',
53
53
  'Invisibility Spell'
54
54
  ];
55
- exports.DARK_ELIXIR_SPELLS = ['Poison Spell', 'Earthquake Spell', 'Haste Spell', 'Skeleton Spell', 'Bat Spell'];
56
- exports.SPELLS = [...exports.ELIXIR_SPELLS, ...exports.DARK_ELIXIR_SPELLS];
57
- exports.BUILDER_TROOPS = [
55
+ exports.DarkElixirSpells = ['Poison Spell', 'Earthquake Spell', 'Haste Spell', 'Skeleton Spell', 'Bat Spell'];
56
+ exports.Spells = [...exports.ElixirSpells, ...exports.DarkElixirSpells];
57
+ exports.BuilderTroops = [
58
58
  'Raged Barbarian',
59
59
  'Sneaky Archer',
60
60
  'Boxer Giant',
@@ -67,9 +67,9 @@ exports.BUILDER_TROOPS = [
67
67
  'Super P.E.K.K.A',
68
68
  'Hog Glider'
69
69
  ];
70
- exports.HEROES = ['Barbarian King', 'Archer Queen', 'Grand Warden', 'Royal Champion', 'Battle Machine'];
71
- exports.HERO_PETS = ['L.A.S.S.I', 'Electro Owl', 'Mighty Yak', 'Unicorn'];
72
- exports.UNRANKED_LEAGUE_DATA = {
70
+ 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'];
72
+ exports.UnrankedLeagueData = {
73
73
  id: 29000000,
74
74
  name: 'Unranked',
75
75
  iconUrls: {
@@ -77,8 +77,8 @@ exports.UNRANKED_LEAGUE_DATA = {
77
77
  tiny: 'https://api-assets.clashofclans.com/leagues/36/e--YMyIexEQQhE4imLoJcwhYn6Uy8KqlgyY3_kFV6t4.png'
78
78
  }
79
79
  };
80
- exports.LEGEND_LEAGUE_ID = 29000022;
81
- exports.LEAGUES = [
80
+ exports.LegendLeagueId = 29000022;
81
+ exports.Leagues = [
82
82
  29000000,
83
83
  29000001,
84
84
  29000002,
@@ -101,13 +101,13 @@ exports.LEAGUES = [
101
101
  29000019,
102
102
  29000020,
103
103
  29000021,
104
- exports.LEGEND_LEAGUE_ID
104
+ exports.LegendLeagueId
105
105
  ];
106
- exports.WAR_LEAGUES = [
106
+ exports.WarLeagues = [
107
107
  48000000, 48000001, 48000002, 48000003, 48000004, 48000005, 48000006, 48000007, 48000008, 48000009, 48000010, 48000011, 48000012,
108
108
  48000013, 48000014, 48000015, 48000016, 48000017, 48000018
109
109
  ];
110
- exports.FRIENDLY_WAR_PREPARATION_TIMES = [
110
+ exports.FriendlyWarPreparationTimes = [
111
111
  1000 * 60 * 60 * 24,
112
112
  1000 * 60 * 60 * 20,
113
113
  1000 * 60 * 60 * 16,
@@ -121,25 +121,25 @@ exports.FRIENDLY_WAR_PREPARATION_TIMES = [
121
121
  1000 * 60 * 15,
122
122
  1000 * 60 * 5
123
123
  ];
124
- exports.EVENTS = {
125
- NEW_SEASON_START: 'newSeasonStart',
126
- CLAN_LOOP_START: 'clanLoopStart',
127
- CLAN_LOOP_END: 'clanLoopEnd',
128
- PLAYER_LOOP_START: 'playerLoopStart',
129
- PLAYER_LOOP_END: 'playerLoopEnd',
130
- WAR_LOOP_START: 'warLoopEnd',
131
- WAR_LOOP_END: 'warLoopEnd',
132
- MAINTENANCE_START: 'maintenanceStart',
133
- MAINTENANCE_END: 'maintenanceEnd',
134
- ERROR: 'error',
135
- DEBUG: 'debug'
124
+ exports.PollingEvents = {
125
+ NewSeasonStart: 'newSeasonStart',
126
+ ClanLoopStart: 'clanLoopStart',
127
+ ClanLoopEnd: 'clanLoopEnd',
128
+ PlayerLoopStart: 'playerLoopStart',
129
+ PlayerLoopEnd: 'playerLoopEnd',
130
+ WarLoopStart: 'warLoopEnd',
131
+ WarLoopEnd: 'warLoopEnd',
132
+ MaintenanceStart: 'maintenanceStart',
133
+ MaintenanceEnd: 'maintenanceEnd',
134
+ Error: 'error',
135
+ Debug: 'debug'
136
136
  };
137
- exports.CWL_ROUNDS = {
138
- PREVIOUS_ROUND: 'warEnded',
139
- CURRENT_ROUND: 'inWar',
140
- NEXT_ROUND: 'preparation'
137
+ exports.CWLRounds = {
138
+ PreviousRound: 'warEnded',
139
+ CurrentRound: 'inWar',
140
+ NextRound: 'preparation'
141
141
  };
142
- exports.RAW_DATA = {
143
- RAW_UNITS: raw_json_1.default.RAW_UNITS,
144
- RAW_SUPER_UNITS: raw_json_1.default.RAW_SUPER_UNITS
142
+ exports.RawData = {
143
+ RawUnits: raw_json_1.default.RAW_UNITS,
144
+ RawSuperUnits: raw_json_1.default.RAW_SUPER_UNITS
145
145
  };
package/dist/util/Util.js CHANGED
@@ -132,11 +132,11 @@ class Util extends null {
132
132
  }));
133
133
  return {
134
134
  units: units.map((unit) => {
135
- const _unit = Constants_1.RAW_DATA.RAW_UNITS.find((raw) => raw.category === 'troop' && raw.id === unit.id);
135
+ const _unit = Constants_1.RawData.RawUnits.find((raw) => raw.category === 'troop' && raw.id === unit.id);
136
136
  return { name: _unit?.name ?? null, count: unit.total, id: unit.id };
137
137
  }),
138
138
  spells: spells.map((spell) => {
139
- const _spell = Constants_1.RAW_DATA.RAW_UNITS.find((raw) => raw.category === 'spell' && raw.id === spell.id);
139
+ const _spell = Constants_1.RawData.RawUnits.find((raw) => raw.category === 'spell' && raw.id === spell.id);
140
140
  return { name: _spell?.name ?? null, count: spell.total, id: spell.id };
141
141
  })
142
142
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clashofclans.js",
3
- "version": "2.8.0-dev.73631cc",
3
+ "version": "2.8.0-dev.8f7faa6",
4
4
  "description": "JavaScript library for interacting with the Clash of Clans API",
5
5
  "author": "SUVAJIT <suvajit.me@gmail.com>",
6
6
  "license": "MIT",