clashofclans.js 3.0.0-dev.f6ce42f → 3.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.
@@ -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,4 +1,4 @@
1
- import { APIPlayer, OverrideOptions } from '../types';
1
+ import { APIPlayer, APIPlayerHouse, OverrideOptions } from '../types';
2
2
  import { Client } from '../client/Client';
3
3
  import { LegendStatistics } from './LegendStatistics';
4
4
  import { Achievement } from './Achievement';
@@ -63,6 +63,8 @@ export declare class Player {
63
63
  spells: Spell[];
64
64
  /** An array of player's heroes (both home base and build base). */
65
65
  heroes: Hero[];
66
+ /** The player's clan capital house details. */
67
+ playerHouse?: APIPlayerHouse | null;
66
68
  constructor(client: Client, data: APIPlayer);
67
69
  /** Whether this clan member is in the clan. */
68
70
  get inClan(): boolean;
@@ -40,6 +40,7 @@ class Player {
40
40
  this.troops = data.troops.map((unit) => new Unit_1.Troop(data, unit));
41
41
  this.spells = data.spells.map((unit) => new Unit_1.Spell(data, unit));
42
42
  this.heroes = data.heroes.map((unit) => new Unit_1.Hero(data, unit));
43
+ this.playerHouse = data.playerHouse ?? null;
43
44
  }
44
45
  /** Whether this clan member is in the clan. */
45
46
  get inClan() {
@@ -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';
@@ -33,3 +33,5 @@ __exportStar(require("./Ranking"), exports);
33
33
  __exportStar(require("./Season"), exports);
34
34
  __exportStar(require("./Unit"), exports);
35
35
  __exportStar(require("./WarLeague"), exports);
36
+ __exportStar(require("./ClanCapital"), exports);
37
+ __exportStar(require("./CapitalRaidSeason"), exports);
@@ -58,6 +58,9 @@ export interface APIClan {
58
58
  labels: APILabel[];
59
59
  memberList: APIClanMember[];
60
60
  clanCapital: APIClanCapital;
61
+ isFamilyFriendly: boolean;
62
+ clanCapitalPoints: number;
63
+ capitalLeague?: APICapitalLeague;
61
64
  }
62
65
  export interface APIClanMember {
63
66
  name: string;
@@ -71,6 +74,13 @@ export interface APIClanMember {
71
74
  previousClanRank: number;
72
75
  donations: number;
73
76
  donationsReceived: number;
77
+ playerHouse?: APIPlayerHouse;
78
+ }
79
+ export interface APIPlayerHouse {
80
+ elements: {
81
+ type: string;
82
+ id: number;
83
+ }[];
74
84
  }
75
85
  export interface APIClanCapital {
76
86
  capitalHallLevel?: number;
@@ -169,6 +179,64 @@ export interface APIClanWarLeagueClanMember {
169
179
  export interface APIClanWarLeagueRound {
170
180
  warTags: string[];
171
181
  }
182
+ export interface APICapitalRaidSeason {
183
+ state: 'ongoing' | 'ended';
184
+ startTime: string;
185
+ endTime: string;
186
+ capitalTotalLoot: number;
187
+ raidsCompleted: number;
188
+ totalAttacks: number;
189
+ enemyDistrictsDestroyed: number;
190
+ offensiveReward: number;
191
+ defensiveReward: number;
192
+ members?: APICapitalRaidSeasonMember[];
193
+ attackLog: APICapitalRaidSeasonAttackLog[];
194
+ defenseLog: APICapitalRaidSeasonDefenseLog[];
195
+ }
196
+ export interface APICapitalRaidSeasonMember {
197
+ tag: string;
198
+ name: string;
199
+ attacks: number;
200
+ attackLimit: number;
201
+ bonusAttackLimit: number;
202
+ capitalResourcesLooted: number;
203
+ }
204
+ export interface APICapitalRaidSeasonClan {
205
+ tag: string;
206
+ name: string;
207
+ level: number;
208
+ badgeUrls: {
209
+ small: string;
210
+ large: string;
211
+ medium: string;
212
+ };
213
+ }
214
+ export interface APICapitalRaidSeasonDistrict {
215
+ id: number;
216
+ name: string;
217
+ districtHallLevel: number;
218
+ destructionPercent: number;
219
+ attackCount: number;
220
+ totalLooted: number;
221
+ }
222
+ export interface APICapitalRaidSeasonAttackLog {
223
+ defender: APICapitalRaidSeasonClan;
224
+ attackCount: number;
225
+ districtCount: number;
226
+ districtsDestroyed: number;
227
+ districts: APICapitalRaidSeasonDistrict[];
228
+ }
229
+ export interface APICapitalRaidSeasonDefenseLog {
230
+ attacker: APICapitalRaidSeasonClan;
231
+ attackCount: number;
232
+ districtCount: number;
233
+ districtsDestroyed: number;
234
+ districts: APICapitalRaidSeasonDistrict[];
235
+ }
236
+ export interface APICapitalRaidSeasons {
237
+ items: APICapitalRaidSeason[];
238
+ paging: APIPaging;
239
+ }
172
240
  /** /players/{playerTag} */
173
241
  export interface APIPlayer {
174
242
  name: string;
@@ -199,6 +267,7 @@ export interface APIPlayer {
199
267
  heroes: APIPlayerItem[];
200
268
  spells: APIPlayerItem[];
201
269
  labels: APILabel[];
270
+ playerHouse?: APIPlayerHouse;
202
271
  }
203
272
  export interface APILegendStatistics {
204
273
  previousSeason?: APISeason;
@@ -313,6 +382,22 @@ export interface APIPlayerVersusRanking {
313
382
  previousRank: number;
314
383
  clan?: APIPlayerClan;
315
384
  }
385
+ export interface APIClanCapitalRanking {
386
+ clanLevel: number;
387
+ clanPoints: number;
388
+ location: APILocation;
389
+ members: number;
390
+ tag: string;
391
+ name: string;
392
+ rank: number;
393
+ previousRank: number;
394
+ badgeUrls: APIBadge;
395
+ clanCapitalPoints: number;
396
+ }
397
+ export interface APIClanCapitalRankingList {
398
+ items: APIClanCapitalRanking[];
399
+ paging: APIPaging;
400
+ }
316
401
  /** /leagues */
317
402
  export interface APILeagueList {
318
403
  items: APILeague[];
@@ -346,6 +431,14 @@ export interface APIWarLeague {
346
431
  id: number;
347
432
  name: string;
348
433
  }
434
+ export interface APICapitalLeague {
435
+ id: number;
436
+ name: string;
437
+ }
438
+ export interface APICapitalLeagueList {
439
+ items: APICapitalLeague[];
440
+ paging: APIPaging;
441
+ }
349
442
  export interface APILabel {
350
443
  id: number;
351
444
  name: string;
@@ -24,21 +24,26 @@ 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
+ };
39
43
  export declare const RestEvents: {
40
44
  readonly Error: "error";
41
45
  readonly Debug: "debug";
46
+ readonly RateLimited: "rateLimited";
42
47
  };
43
48
  export declare const CWLRounds: {
44
49
  readonly PreviousRound: "warEnded";
@@ -46,7 +51,33 @@ export declare const CWLRounds: {
46
51
  readonly NextRound: "preparation";
47
52
  };
48
53
  export declare const RawData: {
49
- 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
+ } | {
50
81
  id: number;
51
82
  name: string;
52
83
  housingSpace: number;
@@ -72,7 +103,7 @@ export declare const RawData: {
72
103
  };
73
104
  seasonal: boolean;
74
105
  levels: number[];
75
- }[];
106
+ })[];
76
107
  RawSuperUnits: {
77
108
  name: string;
78
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.RestEvents = 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,22 +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
  };
137
- exports.RestEvents = {
147
+ exports.ClientEvents = {
138
148
  Error: 'error',
139
149
  Debug: 'debug'
140
150
  };
151
+ exports.RestEvents = {
152
+ Error: 'error',
153
+ Debug: 'debug',
154
+ RateLimited: 'rateLimited'
155
+ };
141
156
  exports.CWLRounds = {
142
157
  PreviousRound: 'warEnded',
143
158
  CurrentRound: 'inWar',