clashofclans.js 1.5.4 → 2.0.0-dev.2c5b083

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.
Files changed (69) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/LICENSE +2 -1
  3. package/README.md +39 -110
  4. package/dist/client/Client.d.ts +177 -0
  5. package/dist/client/Client.js +237 -0
  6. package/dist/client/EventManager.d.ts +86 -0
  7. package/dist/client/EventManager.js +279 -0
  8. package/dist/index.d.ts +9 -0
  9. package/dist/index.js +21 -0
  10. package/dist/rest/HTTPError.d.ts +24 -0
  11. package/dist/rest/HTTPError.js +42 -0
  12. package/dist/rest/RESTManager.d.ts +56 -0
  13. package/dist/rest/RESTManager.js +123 -0
  14. package/dist/rest/RequestHandler.d.ts +162 -0
  15. package/dist/rest/RequestHandler.js +198 -0
  16. package/dist/rest/Throttler.d.ts +31 -0
  17. package/dist/rest/Throttler.js +86 -0
  18. package/dist/struct/Achievement.d.ts +25 -0
  19. package/dist/struct/Achievement.js +28 -0
  20. package/dist/struct/Badge.d.ts +16 -0
  21. package/dist/struct/Badge.js +27 -0
  22. package/dist/struct/ChatLanguage.d.ts +11 -0
  23. package/dist/struct/ChatLanguage.js +12 -0
  24. package/dist/struct/Clan.d.ts +64 -0
  25. package/dist/struct/Clan.js +44 -0
  26. package/dist/struct/ClanMember.d.ts +32 -0
  27. package/dist/struct/ClanMember.js +28 -0
  28. package/dist/struct/ClanWar.d.ts +137 -0
  29. package/dist/struct/ClanWar.js +198 -0
  30. package/dist/struct/ClanWarLeagueGroup.d.ts +63 -0
  31. package/dist/struct/ClanWarLeagueGroup.js +85 -0
  32. package/dist/struct/ClanWarLog.d.ts +54 -0
  33. package/dist/struct/ClanWarLog.js +46 -0
  34. package/dist/struct/Icon.d.ts +16 -0
  35. package/dist/struct/Icon.js +27 -0
  36. package/dist/struct/Label.d.ts +12 -0
  37. package/dist/struct/Label.js +13 -0
  38. package/dist/struct/League.d.ts +14 -0
  39. package/dist/struct/League.js +18 -0
  40. package/dist/struct/LegendStatistics.d.ts +18 -0
  41. package/dist/struct/LegendStatistics.js +17 -0
  42. package/dist/struct/Location.d.ts +15 -0
  43. package/dist/struct/Location.js +14 -0
  44. package/dist/struct/Player.d.ts +78 -0
  45. package/dist/struct/Player.js +72 -0
  46. package/dist/struct/PlayerClan.d.ts +19 -0
  47. package/dist/struct/PlayerClan.js +19 -0
  48. package/dist/struct/Ranking.d.ts +58 -0
  49. package/dist/struct/Ranking.js +50 -0
  50. package/dist/struct/Season.d.ts +19 -0
  51. package/dist/struct/Season.js +21 -0
  52. package/dist/struct/Unit.d.ts +68 -0
  53. package/dist/struct/Unit.js +90 -0
  54. package/dist/struct/WarLeague.d.ts +11 -0
  55. package/dist/struct/WarLeague.js +16 -0
  56. package/dist/struct/index.d.ts +19 -0
  57. package/dist/struct/index.js +31 -0
  58. package/dist/types/index.d.ts +350 -0
  59. package/dist/types/index.js +2 -0
  60. package/dist/util/Constants.d.ts +41 -0
  61. package/dist/util/Constants.js +122 -0
  62. package/dist/util/Util.d.ts +18 -0
  63. package/dist/util/Util.js +53 -0
  64. package/dist/util/raw.json +1 -0
  65. package/package.json +109 -36
  66. package/src/index.d.ts +0 -811
  67. package/src/index.js +0 -5
  68. package/src/struct/Client.js +0 -481
  69. package/src/util/Extension.js +0 -130
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClanWarLog = exports.WarLogClan = void 0;
4
+ const Util_1 = require("../util/Util");
5
+ const Badge_1 = require("./Badge");
6
+ /**
7
+ * Represents War Log Clan.
8
+ *
9
+ * :::caution
10
+ * If this is called via {@link ClanWarLog.opponent}, then {@link WarLogClan.attackCount} and {@link WarLogClan.expEarned} will be `null`.
11
+ * For CWL entries {@link WarLogClan.name} and {@link WarLogClan.tag} are `null`.
12
+ * :::
13
+ */
14
+ class WarLogClan {
15
+ constructor(data) {
16
+ this.name = data.name ?? null;
17
+ this.tag = data.tag ?? null;
18
+ this.badge = new Badge_1.Badge(data.badgeUrls);
19
+ this.level = data.clanLevel;
20
+ this.stars = data.stars;
21
+ this.attackCount = data.attacks ?? null;
22
+ this.destruction = data.destructionPercentage;
23
+ this.expEarned = data.expEarned ?? null;
24
+ }
25
+ }
26
+ exports.WarLogClan = WarLogClan;
27
+ class ClanWarLog {
28
+ constructor(client, data) {
29
+ this.client = client;
30
+ this.result = data.result ?? null;
31
+ this.endTime = Util_1.Util.parseDate(data.endTime);
32
+ this.teamSize = data.teamSize;
33
+ this.attacksPerMember = data.attacksPerMember ?? null;
34
+ this.clan = new WarLogClan(data.clan);
35
+ this.opponent = new WarLogClan(data.opponent);
36
+ }
37
+ /** Returns either `friendly`, `cwl` or `normal`. */
38
+ get type() {
39
+ if (!this.clan.expEarned)
40
+ return 'friendly';
41
+ if (!this.opponent.tag)
42
+ return 'cwl';
43
+ return 'normal';
44
+ }
45
+ }
46
+ exports.ClanWarLog = ClanWarLog;
@@ -0,0 +1,16 @@
1
+ import { APIIcon } from '../types';
2
+ /** Represents a Clash of Clans Icon. */
3
+ export declare class Icon {
4
+ private readonly _data;
5
+ /** The default icon URL. */
6
+ url: string;
7
+ constructor(data: APIIcon);
8
+ /** The medium icon URL. */
9
+ get medium(): string;
10
+ /** The tiny icon URL. */
11
+ get tiny(): string;
12
+ /** The small icon URL. */
13
+ get small(): string;
14
+ /** Get unique hash of this Badge. */
15
+ get hash(): string;
16
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Icon = void 0;
4
+ /** Represents a Clash of Clans Icon. */
5
+ class Icon {
6
+ constructor(data) {
7
+ Object.defineProperty(this, '_data', { value: data });
8
+ this.url = data.medium ?? data.small;
9
+ }
10
+ /** The medium icon URL. */
11
+ get medium() {
12
+ return this._data.medium ?? this._data.small;
13
+ }
14
+ /** The tiny icon URL. */
15
+ get tiny() {
16
+ return this._data.tiny ?? this._data.small;
17
+ }
18
+ /** The small icon URL. */
19
+ get small() {
20
+ return this._data.small;
21
+ }
22
+ /** Get unique hash of this Badge. */
23
+ get hash() {
24
+ return this.url.split('/').pop();
25
+ }
26
+ }
27
+ exports.Icon = Icon;
@@ -0,0 +1,12 @@
1
+ import { APILabel } from '../types';
2
+ import { Icon } from './Icon';
3
+ /** Represents a Clan or Player Label. */
4
+ export declare class Label {
5
+ /** The label's unique Id. */
6
+ id: number;
7
+ /** The label's name. */
8
+ name: string;
9
+ /** The label's icon. */
10
+ icon: Icon;
11
+ constructor(data: APILabel);
12
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Label = void 0;
4
+ const Icon_1 = require("./Icon");
5
+ /** Represents a Clan or Player Label. */
6
+ class Label {
7
+ constructor(data) {
8
+ this.id = data.id;
9
+ this.name = data.name;
10
+ this.icon = new Icon_1.Icon(data.iconUrls);
11
+ }
12
+ }
13
+ exports.Label = Label;
@@ -0,0 +1,14 @@
1
+ import { APILeague } from '../types';
2
+ import { Icon } from './Icon';
3
+ /** Represents a Player's League. */
4
+ export declare class League {
5
+ /** The league Id. */
6
+ id: number;
7
+ /** The league name. */
8
+ name: string;
9
+ /** The League Icon. */
10
+ icon: Icon;
11
+ constructor(data: APILeague);
12
+ /** Position of this League. Starting from 0 (Un-ranked) */
13
+ get position(): number;
14
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.League = void 0;
4
+ const Constants_1 = require("../util/Constants");
5
+ const Icon_1 = require("./Icon");
6
+ /** Represents a Player's League. */
7
+ class League {
8
+ constructor(data) {
9
+ this.id = data.id;
10
+ this.name = data.name;
11
+ this.icon = new Icon_1.Icon(data.iconUrls);
12
+ }
13
+ /** Position of this League. Starting from 0 (Un-ranked) */
14
+ get position() {
15
+ return Constants_1.LEAGUES.indexOf(this.id);
16
+ }
17
+ }
18
+ exports.League = League;
@@ -0,0 +1,18 @@
1
+ import { APILegendStatistics } from '../types';
2
+ import { Season } from './Season';
3
+ /** Represents the Legend Statistics. */
4
+ export declare class LegendStatistics {
5
+ /** The player's legend trophies. */
6
+ legendTrophies: number;
7
+ /** Legend statistics for previous season. */
8
+ previousSeason: Season | null;
9
+ /** Legend statistics for this season. */
10
+ currentSeason: Season | null;
11
+ /** Legend statistics for this player's best season. */
12
+ bestSeason: Season | null;
13
+ /** Versus Legend statistics for previous season. */
14
+ previousVersusSeason: Season | null;
15
+ /** Versus Legend statistics for this player's best season. */
16
+ bestVersusSeason: Season | null;
17
+ constructor(data: APILegendStatistics);
18
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LegendStatistics = void 0;
4
+ const Season_1 = require("./Season");
5
+ /** Represents the Legend Statistics. */
6
+ class LegendStatistics {
7
+ constructor(data) {
8
+ this.legendTrophies = data.legendTrophies;
9
+ this.previousSeason = data.previousSeason ? new Season_1.Season(data.previousSeason) : null;
10
+ // #blame-supercell
11
+ this.currentSeason = data.currentSeason?.rank ? new Season_1.Season(data.currentSeason) : null;
12
+ this.bestSeason = data.bestSeason ? new Season_1.Season(data.bestSeason) : null;
13
+ this.previousVersusSeason = data.previousVersusSeason ? new Season_1.Season(data.previousVersusSeason) : null;
14
+ this.bestVersusSeason = data.bestVersusSeason ? new Season_1.Season(data.bestVersusSeason) : null;
15
+ }
16
+ }
17
+ exports.LegendStatistics = LegendStatistics;
@@ -0,0 +1,15 @@
1
+ import { APILocation } from '../types';
2
+ /** Represents a Clash of Clans Location. */
3
+ export declare class Location {
4
+ /** The location Id. */
5
+ id: number;
6
+ /** The location name. */
7
+ name: string;
8
+ /** A localized name of the location. */
9
+ localizedName: string | null;
10
+ /** Indicates whether the location is a country. */
11
+ isCountry: boolean;
12
+ /** The country code of the location. */
13
+ countryCode: string | null;
14
+ constructor(data: APILocation);
15
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Location = void 0;
4
+ /** Represents a Clash of Clans Location. */
5
+ class Location {
6
+ constructor(data) {
7
+ this.id = data.id;
8
+ this.name = data.name;
9
+ this.localizedName = data.localizedName ?? null;
10
+ this.isCountry = data.isCountry;
11
+ this.countryCode = data.countryCode ?? null;
12
+ }
13
+ }
14
+ exports.Location = Location;
@@ -0,0 +1,78 @@
1
+ import { OverrideOptions } from '../rest/RequestHandler';
2
+ import { LegendStatistics } from './LegendStatistics';
3
+ import { Achievement } from './Achievement';
4
+ import { Hero, Spell, Troop } from './Unit';
5
+ import { PlayerClan } from './PlayerClan';
6
+ import { Client } from '../client/Client';
7
+ import { APIPlayer } from '../types';
8
+ import { League } from './League';
9
+ import { Label } from './Label';
10
+ /** Represents a Clash of Clans Player. */
11
+ export declare class Player {
12
+ client: Client;
13
+ /** The player's name. */
14
+ name: string;
15
+ /** The player's tag. */
16
+ tag: string;
17
+ /** The player's Town Hall level.. */
18
+ townHallLevel: number;
19
+ /** The player's Town Hall weapon level. */
20
+ townHallWeaponLevel: number | null;
21
+ /** The player's experience level. */
22
+ expLevel: number;
23
+ /** The player's trophy count. */
24
+ trophies: number;
25
+ /** The player's best trophies. */
26
+ bestTrophies: number;
27
+ /** The player's war stars. */
28
+ warStars: number;
29
+ /** The number of attacks the player has won this season. */
30
+ attackWins: number;
31
+ /** The number of defenses the player has won this season. */
32
+ defenseWins: number;
33
+ /** The player's builder hall level, or 0 if it hasn't been unlocked. */
34
+ builderHallLevel: number | null;
35
+ /** The player's versus trophy count. */
36
+ versusTrophies: number | null;
37
+ /** The player's best versus trophies. */
38
+ bestVersusTrophies: number | null;
39
+ /** The number of total versus attacks the player has won. */
40
+ versusBattleWins: number | null;
41
+ /** The player's donation count for this season. */
42
+ donations: number;
43
+ /** The player's donation received count for this season. */
44
+ received: number;
45
+ /** The player's role in the clan or `null` if not in a clan. */
46
+ role: 'member' | 'elder' | 'coLeader' | 'leader' | null;
47
+ /** Whether the player has selected that they are opted in. This will be `null` if the player is not in a clan. */
48
+ warOptedIn: boolean | null;
49
+ /** The player's clan. */
50
+ clan: PlayerClan | null;
51
+ /** The player's current League. */
52
+ league: League;
53
+ /** The player's legend statistics, or `null` if they have never been in the legend league. */
54
+ legendStatistics: LegendStatistics | null;
55
+ /** An array of the player's achievements. */
56
+ achievements: Achievement[];
57
+ /** An array of player's labels. */
58
+ labels: Label[];
59
+ /** An array of player's troops. */
60
+ troops: Troop[];
61
+ /** An array of player's spells. */
62
+ spells: Spell[];
63
+ /** An array of player's heroes. */
64
+ heroes: Hero[];
65
+ constructor(client: Client, data: APIPlayer);
66
+ /** Fetch detailed clan info for the player's clan. */
67
+ fetchClan(options?: OverrideOptions): Promise<import("./Clan").Clan | null>;
68
+ /** An array of the player's home base troops. */
69
+ get homeTroops(): Troop[];
70
+ /** An array of the player's builder base troops. */
71
+ get builderTroops(): Troop[];
72
+ /** An array of the player's super troops. */
73
+ get superTroops(): Troop[];
74
+ /** An array of the player's hero pets. */
75
+ get heroPets(): Troop[];
76
+ /** An array of the player's siege machines. */
77
+ get siegeMachines(): Troop[];
78
+ }
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Player = void 0;
4
+ const Constants_1 = require("../util/Constants");
5
+ const raw_json_1 = require("../util/raw.json");
6
+ const LegendStatistics_1 = require("./LegendStatistics");
7
+ const Achievement_1 = require("./Achievement");
8
+ const Unit_1 = require("./Unit");
9
+ const PlayerClan_1 = require("./PlayerClan");
10
+ const League_1 = require("./League");
11
+ const Label_1 = require("./Label");
12
+ const UNIT_NAMES = [...raw_json_1.RAW_UNITS.map((unit) => unit.name), ...raw_json_1.RAW_SUPER_UNITS.map((unit) => unit.name)];
13
+ /** Represents a Clash of Clans Player. */
14
+ class Player {
15
+ constructor(client, data) {
16
+ this.client = client;
17
+ this.name = data.name;
18
+ this.tag = data.tag;
19
+ this.townHallLevel = data.townHallLevel;
20
+ this.townHallWeaponLevel = data.townHallWeaponLevel ?? null;
21
+ this.expLevel = data.expLevel;
22
+ this.trophies = data.trophies;
23
+ this.bestTrophies = data.bestTrophies;
24
+ this.warStars = data.warStars;
25
+ this.attackWins = data.attackWins;
26
+ this.defenseWins = data.defenseWins;
27
+ this.builderHallLevel = data.builderHallLevel ?? null;
28
+ this.versusTrophies = data.versusTrophies ?? null;
29
+ this.bestVersusTrophies = data.bestVersusTrophies ?? null;
30
+ this.versusBattleWins = data.versusBattleWins ?? null;
31
+ this.donations = data.donations;
32
+ this.received = data.donationsReceived;
33
+ // @ts-expect-error
34
+ this.role = data.role?.replace('admin', 'elder') ?? null;
35
+ this.warOptedIn = data.warPreference ? data.warPreference === 'in' : null;
36
+ this.clan = data.clan ? new PlayerClan_1.PlayerClan(client, data.clan) : null;
37
+ this.league = new League_1.League(data.league ?? Constants_1.UNRANKED_LEAGUE_DATA);
38
+ this.legendStatistics = data.legendStatistics ? new LegendStatistics_1.LegendStatistics(data.legendStatistics) : null;
39
+ this.achievements = data.achievements.map((data) => new Achievement_1.Achievement(data));
40
+ this.labels = data.labels.map((data) => new Label_1.Label(data));
41
+ this.troops = data.troops.filter((unit) => UNIT_NAMES.includes(unit.name)).map((unit) => new Unit_1.Troop(data, unit));
42
+ this.spells = data.spells.filter((unit) => UNIT_NAMES.includes(unit.name)).map((unit) => new Unit_1.Spell(data, unit));
43
+ this.heroes = data.heroes.filter((unit) => UNIT_NAMES.includes(unit.name)).map((unit) => new Unit_1.Hero(data, unit));
44
+ }
45
+ /** Fetch detailed clan info for the player's clan. */
46
+ async fetchClan(options) {
47
+ if (!this.clan)
48
+ return null;
49
+ return this.client.getClan(this.clan.tag, options);
50
+ }
51
+ /** An array of the player's home base troops. */
52
+ get homeTroops() {
53
+ return this.troops.filter((entry) => entry.isHomeBase);
54
+ }
55
+ /** An array of the player's builder base troops. */
56
+ get builderTroops() {
57
+ return this.troops.filter((entry) => entry.isBuilderBase);
58
+ }
59
+ /** An array of the player's super troops. */
60
+ get superTroops() {
61
+ return this.troops.filter((entry) => entry.isSuperTroop);
62
+ }
63
+ /** An array of the player's hero pets. */
64
+ get heroPets() {
65
+ return this.troops.filter((entry) => entry.isHomeBase && Constants_1.HERO_PETS.includes(entry.name));
66
+ }
67
+ /** An array of the player's siege machines. */
68
+ get siegeMachines() {
69
+ return this.troops.filter((entry) => entry.isHomeBase && Constants_1.SIEGE_MACHINES.includes(entry.name));
70
+ }
71
+ }
72
+ exports.Player = Player;
@@ -0,0 +1,19 @@
1
+ import { OverrideOptions } from '../rest/RequestHandler';
2
+ import { Client } from '../client/Client';
3
+ import { APIPlayerClan } from '../types';
4
+ import { Badge } from './Badge';
5
+ /** Represents a player's clan. */
6
+ export declare class PlayerClan {
7
+ private readonly _client;
8
+ /** Name of the clan. */
9
+ name: string;
10
+ /** Tag of the clan. */
11
+ tag: string;
12
+ /** Level of this clan. */
13
+ level: number;
14
+ /** Badge of this clan. */
15
+ badge: Badge;
16
+ constructor(_client: Client, data: APIPlayerClan);
17
+ /** Fetch detailed clan info for the player's clan. */
18
+ fetch(options?: OverrideOptions): Promise<import("./Clan").Clan>;
19
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PlayerClan = void 0;
4
+ const Badge_1 = require("./Badge");
5
+ /** Represents a player's clan. */
6
+ class PlayerClan {
7
+ constructor(_client, data) {
8
+ this._client = _client;
9
+ this.name = data.name;
10
+ this.tag = data.tag;
11
+ this.level = data.clanLevel;
12
+ this.badge = new Badge_1.Badge(data.badgeUrls);
13
+ }
14
+ /** Fetch detailed clan info for the player's clan. */
15
+ fetch(options) {
16
+ return this._client.getClan(this.tag, options);
17
+ }
18
+ }
19
+ exports.PlayerClan = PlayerClan;
@@ -0,0 +1,58 @@
1
+ import { APIClanRanking, APIClanVersusRanking, APIPlayerRanking, APIPlayerVersusRanking } from '../types';
2
+ import { PlayerClan } from './PlayerClan';
3
+ import { Client } from '../client/Client';
4
+ import { Location } from './Location';
5
+ import { League } from './League';
6
+ import { Badge } from './Badge';
7
+ /** Represents the player of leader-board ranking. */
8
+ export declare class RankedPlayer {
9
+ /** The player's name. */
10
+ name: string;
11
+ /** The player's tag. */
12
+ tag: string;
13
+ /** The player's experience level. */
14
+ expLevel: number;
15
+ /** The player's trophy count. If retrieving info for versus leader-boards, this will be `null`. */
16
+ trophies: number | null;
17
+ /** The player's attack wins. If retrieving info for versus leader-boards, this will be `null`. */
18
+ attackWins: number | null;
19
+ /** The player's defense wins. If retrieving info for versus leader-boards, this will be `null`. */
20
+ defenseWins: number | null;
21
+ /** The player's versus trophy count. If retrieving info for regular leader-boards, this will be `null`. */
22
+ versusTrophies: number | null;
23
+ /** The number of total versus attacks the player has won. If retrieving info for regular leader-boards, this will be `null`. */
24
+ versusBattleWins: number | null;
25
+ /** The player's rank in the clan leader-board. */
26
+ rank: number;
27
+ /** The player's rank before the last leader-board change. */
28
+ previousRank: number;
29
+ /** The player's clan. */
30
+ clan: PlayerClan;
31
+ /** The player's league. If retrieving info for versus leader-boards, this will be `null`. */
32
+ league: League | null;
33
+ constructor(client: Client, data: APIPlayerRanking | APIPlayerVersusRanking);
34
+ }
35
+ /** Represents the clan of leader-board ranking. */
36
+ export declare class RankedClan {
37
+ /** The clan's name. */
38
+ name: string;
39
+ /** The clan's tag. */
40
+ tag: string;
41
+ /** The clan's level. */
42
+ level: number;
43
+ /** The clan's trophy count. If retrieving info for versus leader-boards, this will be `null`. */
44
+ points: number | null;
45
+ /** The clan's versus trophy count. If retrieving info for regular leader boards, this will be `null`. */
46
+ versusPoints: number | null;
47
+ /** The clan's location. */
48
+ location: Location;
49
+ /** The number of members in the clan. */
50
+ memberCount: number;
51
+ /** The clan's rank in the leader board. */
52
+ rank: number;
53
+ /** The clan's rank in the previous season's leader-board. */
54
+ previousRank: number;
55
+ /** The clan's badge. */
56
+ badge: Badge;
57
+ constructor(data: APIClanRanking | APIClanVersusRanking);
58
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RankedClan = exports.RankedPlayer = void 0;
4
+ const Constants_1 = require("../util/Constants");
5
+ const PlayerClan_1 = require("./PlayerClan");
6
+ const Location_1 = require("./Location");
7
+ const League_1 = require("./League");
8
+ const Badge_1 = require("./Badge");
9
+ /** Represents the player of leader-board ranking. */
10
+ class RankedPlayer {
11
+ constructor(client, data) {
12
+ this.name = data.name;
13
+ this.tag = data.tag;
14
+ this.expLevel = data.expLevel;
15
+ // @ts-expect-error
16
+ this.trophies = data.trophies ?? null;
17
+ // @ts-expect-error
18
+ this.attackWins = data.attackWins ?? null;
19
+ // @ts-expect-error
20
+ this.defenseWins = data.defenseWins ?? null;
21
+ // @ts-expect-error
22
+ this.versusTrophies = data.versusTrophies ?? null;
23
+ // @ts-expect-error
24
+ this.versusBattleWins = data.versusBattleWins ?? null;
25
+ this.rank = data.rank;
26
+ this.previousRank = data.previousRank;
27
+ this.clan = new PlayerClan_1.PlayerClan(client, data.clan);
28
+ // @ts-expect-error
29
+ this.league = data.trophies ? new League_1.League(data.league ?? Constants_1.UNRANKED_LEAGUE_DATA) : null; // eslint-disable-line
30
+ }
31
+ }
32
+ exports.RankedPlayer = RankedPlayer;
33
+ /** Represents the clan of leader-board ranking. */
34
+ class RankedClan {
35
+ constructor(data) {
36
+ this.name = data.name;
37
+ this.tag = data.tag;
38
+ this.level = data.clanLevel;
39
+ // @ts-expect-error
40
+ this.points = data.clanPoints ?? null;
41
+ // @ts-expect-error
42
+ this.versusPoints = data.clanVersusPoints ?? null;
43
+ this.location = new Location_1.Location(data.location);
44
+ this.memberCount = data.members;
45
+ this.rank = data.rank;
46
+ this.previousRank = data.previousRank;
47
+ this.badge = new Badge_1.Badge(data.badgeUrls);
48
+ }
49
+ }
50
+ exports.RankedClan = RankedClan;
@@ -0,0 +1,19 @@
1
+ import { APIGoldPassSeason, APISeason } from '../types';
2
+ /** Represents a player's trophy season. */
3
+ export declare class Season {
4
+ /** The season's Id. */
5
+ id: string;
6
+ /** The player's rank. */
7
+ rank: number;
8
+ /** The player's trophy count. */
9
+ trophies: number;
10
+ constructor(data: APISeason);
11
+ }
12
+ /** Represents a gold pass season. */
13
+ export declare class GoldPassSeason {
14
+ /** The start time of the gold pass season. */
15
+ startTime: Date;
16
+ /** The end time of this gold pass season. */
17
+ endTime: Date;
18
+ constructor(data: APIGoldPassSeason);
19
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GoldPassSeason = exports.Season = void 0;
4
+ const Util_1 = require("../util/Util");
5
+ /** Represents a player's trophy season. */
6
+ class Season {
7
+ constructor(data) {
8
+ this.id = data.id || Util_1.Util.getSeasonId();
9
+ this.rank = data.rank;
10
+ this.trophies = data.trophies;
11
+ }
12
+ }
13
+ exports.Season = Season;
14
+ /** Represents a gold pass season. */
15
+ class GoldPassSeason {
16
+ constructor(data) {
17
+ this.startTime = Util_1.Util.parseDate(data.startTime);
18
+ this.endTime = Util_1.Util.parseDate(data.endTime);
19
+ }
20
+ }
21
+ exports.GoldPassSeason = GoldPassSeason;
@@ -0,0 +1,68 @@
1
+ import { APIPlayerItem, APIPlayer } from '../types';
2
+ /** Represents a player's unit. */
3
+ export declare class Unit {
4
+ /** The name of this unit. */
5
+ name: string;
6
+ /** The level of this unit. */
7
+ level: number;
8
+ /** The max level of this unit. */
9
+ maxLevel: number;
10
+ /** The village type of this unit. */
11
+ village: 'home' | 'builderBase';
12
+ /** Id of this unit. */
13
+ id: number;
14
+ /** Housing space of this unit. */
15
+ housingSpace: number;
16
+ /** Town/Builder hall's max level of this unit. */
17
+ hallMaxLevel: number;
18
+ /** Unlock Town/Builder Hall level of this unit. */
19
+ unlockHallLevel: number;
20
+ /** Unlock cost of this unit. */
21
+ unlockCost: number;
22
+ /** Unlock time of this unit. */
23
+ unlockTime: number;
24
+ /** Unlock resource of this unit. */
25
+ unlockResource: string;
26
+ /** Unlock building of this unit. */
27
+ unlockBuilding: string;
28
+ /** Unlock building level of this unit. */
29
+ unlockBuildingLevel: number;
30
+ /** Upgrade cost of this unit. */
31
+ upgradeCost: number;
32
+ /** Upgrade resource of this unit. */
33
+ upgradeResource: string;
34
+ /** Upgrade time of this unit. */
35
+ upgradeTime: number;
36
+ /** @internal */
37
+ minOriginalLevel: number | null;
38
+ /** @internal */
39
+ originalName: string | null;
40
+ constructor(data: APIPlayer, unit: APIPlayerItem);
41
+ /** Whether the unit belongs to the home base. */
42
+ get isHomeBase(): boolean;
43
+ /** Whether the unit belongs to the builder base. */
44
+ get isBuilderBase(): boolean;
45
+ /** Whether the unit is at max level. */
46
+ get isMax(): boolean;
47
+ /** Icon of this unit. */
48
+ get iconURL(): string;
49
+ }
50
+ /** Represents a player's troop. */
51
+ export declare class Troop extends Unit {
52
+ name: string;
53
+ /** Whether this troop is currently active of boosted. */
54
+ isActive: boolean;
55
+ /** Origin troop's minimum level of this super troop. */
56
+ minOriginalLevel: number | null;
57
+ /** Origin troop's name of this super troop. */
58
+ originalName: string | null;
59
+ constructor(data: APIPlayer, unit: APIPlayerItem);
60
+ /** Whether this troop is a Super Troop. */
61
+ get isSuperTroop(): boolean;
62
+ }
63
+ /** Represents a player's spell. */
64
+ export declare class Spell extends Unit {
65
+ }
66
+ /** Represents a player's hero. */
67
+ export declare class Hero extends Unit {
68
+ }