clashofclans.js 2.7.0 → 2.8.0-dev.11ea070
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/CHANGELOG.md +9 -1
- package/dist/client/Client.d.ts +8 -74
- package/dist/client/Client.js +12 -18
- package/dist/client/EventManager.d.ts +18 -18
- package/dist/client/EventManager.js +55 -56
- package/dist/client/PollingClient.d.ts +83 -0
- package/dist/client/PollingClient.js +25 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +23 -21
- package/dist/rest/RESTManager.d.ts +1 -1
- package/dist/rest/RequestHandler.d.ts +2 -2
- package/dist/rest/RequestHandler.js +7 -12
- package/dist/rest/Throttler.d.ts +10 -12
- package/dist/rest/Throttler.js +27 -50
- package/dist/struct/Clan.d.ts +3 -0
- package/dist/struct/Clan.js +2 -0
- package/dist/struct/ClanCapital.d.ts +12 -0
- package/dist/struct/ClanCapital.js +10 -0
- package/dist/struct/ClanMember.js +1 -1
- package/dist/struct/ClanWar.js +1 -1
- package/dist/struct/ClanWarLeagueGroup.d.ts +2 -1
- package/dist/struct/ClanWarLeagueGroup.js +2 -1
- package/dist/struct/League.js +1 -1
- package/dist/struct/Player.d.ts +2 -0
- package/dist/struct/Player.js +12 -11
- package/dist/struct/Ranking.js +1 -1
- package/dist/struct/Unit.js +4 -5
- package/dist/struct/WarLeague.js +1 -1
- package/dist/types/api.d.ts +10 -0
- package/dist/types/lib.d.ts +8 -3
- package/dist/util/Constants.d.ts +75 -33
- package/dist/util/Constants.js +44 -35
- package/dist/util/Util.d.ts +13 -0
- package/dist/util/Util.js +30 -0
- package/dist/util/raw.json +1 -1
- package/package.json +1 -1
package/dist/struct/Unit.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Hero = exports.Spell = exports.Troop = exports.Unit = void 0;
|
|
4
|
-
const raw_json_1 = require("../util/raw.json");
|
|
5
4
|
const Constants_1 = require("../util/Constants");
|
|
6
5
|
/** Represents a Player's Unit. */
|
|
7
6
|
class Unit {
|
|
@@ -11,14 +10,14 @@ class Unit {
|
|
|
11
10
|
this.level = unit.level;
|
|
12
11
|
this.maxLevel = unit.maxLevel;
|
|
13
12
|
this.village = unit.village;
|
|
14
|
-
const rawSuperUnit =
|
|
15
|
-
const rawUnit =
|
|
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);
|
|
16
15
|
if (rawSuperUnit) {
|
|
17
16
|
this.id = rawSuperUnit.id;
|
|
18
17
|
this.housingSpace = rawSuperUnit.housingSpace;
|
|
19
18
|
this.originalName = rawSuperUnit.original;
|
|
20
19
|
this.minOriginalLevel = rawSuperUnit.minOriginalLevel;
|
|
21
|
-
const original =
|
|
20
|
+
const original = Constants_1.RawData.RawUnits.find((unit) => unit.village === 'home' && unit.name === rawSuperUnit.original);
|
|
22
21
|
this.unlockHallLevel = original.levels.findIndex((level) => level >= rawSuperUnit.minOriginalLevel) + 1;
|
|
23
22
|
this.unlockCost = original.unlock.cost;
|
|
24
23
|
this.unlockTime = original.unlock.time;
|
|
@@ -88,7 +87,7 @@ class Troop extends Unit {
|
|
|
88
87
|
}
|
|
89
88
|
/** Whether this troop is a Super Troop. */
|
|
90
89
|
get isSuperTroop() {
|
|
91
|
-
return this.isActive || (this.isHomeBase && Constants_1.
|
|
90
|
+
return this.isActive || (this.isHomeBase && Constants_1.SuperTroops.includes(this.name));
|
|
92
91
|
}
|
|
93
92
|
}
|
|
94
93
|
exports.Troop = Troop;
|
package/dist/struct/WarLeague.js
CHANGED
package/dist/types/api.d.ts
CHANGED
|
@@ -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;
|
package/dist/types/lib.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export interface Store<T = any> {
|
|
|
5
5
|
delete(key: string): boolean | Promise<boolean>;
|
|
6
6
|
clear(): void | Promise<void>;
|
|
7
7
|
}
|
|
8
|
-
/** Options for a Client
|
|
8
|
+
/** Options for a {@link Client} */
|
|
9
9
|
export interface ClientOptions {
|
|
10
10
|
/** Keys from Clash of Clans API developer site. */
|
|
11
11
|
keys?: string[];
|
|
@@ -36,13 +36,18 @@ export interface ClientOptions {
|
|
|
36
36
|
* const client = new Client({ throttler: new BatchThrottler(30) });
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
|
-
throttler?: QueueThrottler | BatchThrottler;
|
|
39
|
+
throttler?: QueueThrottler | BatchThrottler | null;
|
|
40
40
|
}
|
|
41
|
-
/** Options for a RESTManager
|
|
41
|
+
/** Options for a {@link RESTManager} */
|
|
42
42
|
export interface RESTOptions extends ClientOptions {
|
|
43
43
|
/** Set this `false` to use `res.ok` property. */
|
|
44
44
|
rejectIfNotValid?: boolean;
|
|
45
45
|
}
|
|
46
|
+
/** Options for a {@link RequestHandler} */
|
|
47
|
+
export interface RequestHandlerOptions extends ClientOptions {
|
|
48
|
+
/** Set this `false` to use `res.ok` property. */
|
|
49
|
+
rejectIfNotValid?: boolean;
|
|
50
|
+
}
|
|
46
51
|
/** Search options for request. */
|
|
47
52
|
export interface SearchOptions extends OverrideOptions {
|
|
48
53
|
/** Limit the number of items returned in the response. */
|
package/dist/util/Constants.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const
|
|
11
|
-
export declare const
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const
|
|
14
|
-
export declare const
|
|
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,24 +19,66 @@ export declare const UNRANKED_LEAGUE_DATA: {
|
|
|
19
19
|
tiny: string;
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
-
export declare const
|
|
23
|
-
export declare const
|
|
24
|
-
export declare const
|
|
25
|
-
export declare const
|
|
26
|
-
export declare const
|
|
27
|
-
readonly
|
|
28
|
-
readonly
|
|
29
|
-
readonly
|
|
30
|
-
readonly
|
|
31
|
-
readonly
|
|
32
|
-
readonly
|
|
33
|
-
readonly
|
|
34
|
-
readonly
|
|
35
|
-
readonly
|
|
36
|
-
readonly
|
|
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";
|
|
37
38
|
};
|
|
38
|
-
export declare const
|
|
39
|
-
readonly
|
|
40
|
-
readonly
|
|
41
|
-
readonly
|
|
39
|
+
export declare const CWLRounds: {
|
|
40
|
+
readonly PreviousRound: "warEnded";
|
|
41
|
+
readonly CurrentRound: "inWar";
|
|
42
|
+
readonly NextRound: "preparation";
|
|
43
|
+
};
|
|
44
|
+
export declare const RawData: {
|
|
45
|
+
RawUnits: {
|
|
46
|
+
id: number;
|
|
47
|
+
name: string;
|
|
48
|
+
housingSpace: number;
|
|
49
|
+
village: string;
|
|
50
|
+
category: string;
|
|
51
|
+
subCategory: string;
|
|
52
|
+
unlock: {
|
|
53
|
+
hall: number;
|
|
54
|
+
cost: number;
|
|
55
|
+
time: number;
|
|
56
|
+
resource: string;
|
|
57
|
+
building: string;
|
|
58
|
+
buildingLevel: number;
|
|
59
|
+
};
|
|
60
|
+
resourceType: string;
|
|
61
|
+
trainingTime: number;
|
|
62
|
+
regenerationTimes: number[];
|
|
63
|
+
dps: number[];
|
|
64
|
+
upgrade: {
|
|
65
|
+
cost: number[];
|
|
66
|
+
time: number[];
|
|
67
|
+
resource: string;
|
|
68
|
+
};
|
|
69
|
+
seasonal: boolean;
|
|
70
|
+
levels: number[];
|
|
71
|
+
}[];
|
|
72
|
+
RawSuperUnits: {
|
|
73
|
+
name: string;
|
|
74
|
+
id: number;
|
|
75
|
+
original: string;
|
|
76
|
+
minOriginalLevel: number;
|
|
77
|
+
village: string;
|
|
78
|
+
duration: number;
|
|
79
|
+
cooldown: number;
|
|
80
|
+
resource: string;
|
|
81
|
+
resourceCost: number;
|
|
82
|
+
housingSpace: number;
|
|
83
|
+
}[];
|
|
42
84
|
};
|
package/dist/util/Constants.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
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
|
+
const raw_json_1 = __importDefault(require("../util/raw.json"));
|
|
8
|
+
exports.APIBaseURL = 'https://api.clashofclans.com/v1';
|
|
9
|
+
exports.DevSiteAPIBaseURL = 'https://developer.clashofclans.com/api';
|
|
10
|
+
exports.ElixirTroops = [
|
|
7
11
|
'Barbarian',
|
|
8
12
|
'Archer',
|
|
9
13
|
'Giant',
|
|
@@ -20,10 +24,10 @@ exports.ELIXIR_TROOPS = [
|
|
|
20
24
|
'Yeti',
|
|
21
25
|
'Dragon Rider'
|
|
22
26
|
];
|
|
23
|
-
exports.
|
|
24
|
-
exports.
|
|
25
|
-
exports.
|
|
26
|
-
exports.
|
|
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 = [
|
|
27
31
|
'Super Barbarian',
|
|
28
32
|
'Super Archer',
|
|
29
33
|
'Super Giant',
|
|
@@ -39,7 +43,7 @@ exports.SUPER_TROOPS = [
|
|
|
39
43
|
'Ice Hound',
|
|
40
44
|
'Super Bowler'
|
|
41
45
|
];
|
|
42
|
-
exports.
|
|
46
|
+
exports.ElixirSpells = [
|
|
43
47
|
'Lightning Spell',
|
|
44
48
|
'Healing Spell',
|
|
45
49
|
'Rage Spell',
|
|
@@ -48,9 +52,9 @@ exports.ELIXIR_SPELLS = [
|
|
|
48
52
|
'Clone Spell',
|
|
49
53
|
'Invisibility Spell'
|
|
50
54
|
];
|
|
51
|
-
exports.
|
|
52
|
-
exports.
|
|
53
|
-
exports.
|
|
55
|
+
exports.DarkElixirSpells = ['Poison Spell', 'Earthquake Spell', 'Haste Spell', 'Skeleton Spell', 'Bat Spell'];
|
|
56
|
+
exports.Spells = [...exports.ElixirSpells, ...exports.DarkElixirSpells];
|
|
57
|
+
exports.BuilderTroops = [
|
|
54
58
|
'Raged Barbarian',
|
|
55
59
|
'Sneaky Archer',
|
|
56
60
|
'Boxer Giant',
|
|
@@ -63,9 +67,9 @@ exports.BUILDER_TROOPS = [
|
|
|
63
67
|
'Super P.E.K.K.A',
|
|
64
68
|
'Hog Glider'
|
|
65
69
|
];
|
|
66
|
-
exports.
|
|
67
|
-
exports.
|
|
68
|
-
exports.
|
|
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 = {
|
|
69
73
|
id: 29000000,
|
|
70
74
|
name: 'Unranked',
|
|
71
75
|
iconUrls: {
|
|
@@ -73,8 +77,8 @@ exports.UNRANKED_LEAGUE_DATA = {
|
|
|
73
77
|
tiny: 'https://api-assets.clashofclans.com/leagues/36/e--YMyIexEQQhE4imLoJcwhYn6Uy8KqlgyY3_kFV6t4.png'
|
|
74
78
|
}
|
|
75
79
|
};
|
|
76
|
-
exports.
|
|
77
|
-
exports.
|
|
80
|
+
exports.LegendLeagueId = 29000022;
|
|
81
|
+
exports.Leagues = [
|
|
78
82
|
29000000,
|
|
79
83
|
29000001,
|
|
80
84
|
29000002,
|
|
@@ -97,13 +101,13 @@ exports.LEAGUES = [
|
|
|
97
101
|
29000019,
|
|
98
102
|
29000020,
|
|
99
103
|
29000021,
|
|
100
|
-
exports.
|
|
104
|
+
exports.LegendLeagueId
|
|
101
105
|
];
|
|
102
|
-
exports.
|
|
106
|
+
exports.WarLeagues = [
|
|
103
107
|
48000000, 48000001, 48000002, 48000003, 48000004, 48000005, 48000006, 48000007, 48000008, 48000009, 48000010, 48000011, 48000012,
|
|
104
108
|
48000013, 48000014, 48000015, 48000016, 48000017, 48000018
|
|
105
109
|
];
|
|
106
|
-
exports.
|
|
110
|
+
exports.FriendlyWarPreparationTimes = [
|
|
107
111
|
1000 * 60 * 60 * 24,
|
|
108
112
|
1000 * 60 * 60 * 20,
|
|
109
113
|
1000 * 60 * 60 * 16,
|
|
@@ -117,20 +121,25 @@ exports.FRIENDLY_WAR_PREPARATION_TIMES = [
|
|
|
117
121
|
1000 * 60 * 15,
|
|
118
122
|
1000 * 60 * 5
|
|
119
123
|
];
|
|
120
|
-
exports.
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
+
};
|
|
137
|
+
exports.CWLRounds = {
|
|
138
|
+
PreviousRound: 'warEnded',
|
|
139
|
+
CurrentRound: 'inWar',
|
|
140
|
+
NextRound: 'preparation'
|
|
131
141
|
};
|
|
132
|
-
exports.
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
NEXT_ROUND: 'preparation'
|
|
142
|
+
exports.RawData = {
|
|
143
|
+
RawUnits: raw_json_1.default.RAW_UNITS,
|
|
144
|
+
RawSuperUnits: raw_json_1.default.RAW_SUPER_UNITS
|
|
136
145
|
};
|
package/dist/util/Util.d.ts
CHANGED
|
@@ -39,4 +39,17 @@ export declare class Util extends null {
|
|
|
39
39
|
static getSeasonEndTime(timestamp?: Date): Date;
|
|
40
40
|
static allSettled<T>(values: Promise<T>[]): Promise<T[]>;
|
|
41
41
|
static delay(ms: number): Promise<unknown>;
|
|
42
|
+
/** Parse in-game army link into troops and spells count with respective Id's. */
|
|
43
|
+
static parseArmyLink(link: string): {
|
|
44
|
+
units: {
|
|
45
|
+
name: string | null;
|
|
46
|
+
count: number;
|
|
47
|
+
id: number;
|
|
48
|
+
}[];
|
|
49
|
+
spells: {
|
|
50
|
+
name: string | null;
|
|
51
|
+
count: number;
|
|
52
|
+
id: number;
|
|
53
|
+
}[];
|
|
54
|
+
};
|
|
42
55
|
}
|
package/dist/util/Util.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Util = void 0;
|
|
4
|
+
const Constants_1 = require("../util/Constants");
|
|
4
5
|
const TAG_CHARACTERS = '0289PYLQGRJCUV';
|
|
5
6
|
const params = [
|
|
6
7
|
'name',
|
|
@@ -111,5 +112,34 @@ class Util extends null {
|
|
|
111
112
|
static async delay(ms) {
|
|
112
113
|
return new Promise((res) => setTimeout(res, ms));
|
|
113
114
|
}
|
|
115
|
+
/** Parse in-game army link into troops and spells count with respective Id's. */
|
|
116
|
+
static parseArmyLink(link) {
|
|
117
|
+
const unitsMatches = link.match(/u(?<units>[\d+x-]+)/);
|
|
118
|
+
const spellsMatches = link.match(/s(?<spells>[\d+x-]+)/);
|
|
119
|
+
const unitsPart = unitsMatches?.groups?.unit?.split('-') ?? [];
|
|
120
|
+
const spellParts = spellsMatches?.groups?.spells?.split('-') ?? [];
|
|
121
|
+
const units = unitsPart
|
|
122
|
+
.map((parts) => parts.split(/x/))
|
|
123
|
+
.map((parts) => ({
|
|
124
|
+
id: Number(parts[1]),
|
|
125
|
+
total: Number(parts[0])
|
|
126
|
+
}));
|
|
127
|
+
const spells = spellParts
|
|
128
|
+
.map((parts) => parts.split(/x/))
|
|
129
|
+
.map((parts) => ({
|
|
130
|
+
id: Number(parts[1]),
|
|
131
|
+
total: Number(parts[0])
|
|
132
|
+
}));
|
|
133
|
+
return {
|
|
134
|
+
units: units.map((unit) => {
|
|
135
|
+
const _unit = Constants_1.RawData.RawUnits.find((raw) => raw.category === 'troop' && raw.id === unit.id);
|
|
136
|
+
return { name: _unit?.name ?? null, count: unit.total, id: unit.id };
|
|
137
|
+
}),
|
|
138
|
+
spells: spells.map((spell) => {
|
|
139
|
+
const _spell = Constants_1.RawData.RawUnits.find((raw) => raw.category === 'spell' && raw.id === spell.id);
|
|
140
|
+
return { name: _spell?.name ?? null, count: spell.total, id: spell.id };
|
|
141
|
+
})
|
|
142
|
+
};
|
|
143
|
+
}
|
|
114
144
|
}
|
|
115
145
|
exports.Util = Util;
|