clashofclans.js 3.5.3-dev.96712e2 → 3.6.0-dev.04e52fc
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/util/Constants.d.ts +2 -2
- package/dist/util/Constants.js +5 -25
- package/dist/util/Util.d.ts +10 -0
- package/dist/util/Util.js +26 -0
- package/dist/util/raw.json +1 -1
- package/dist/util.spec.js +64 -0
- package/package.json +1 -1
package/dist/util/Constants.d.ts
CHANGED
|
@@ -20,8 +20,8 @@ export declare const UnrankedLeagueData: {
|
|
|
20
20
|
large: string;
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
|
-
export declare const UnrankedLeagueId =
|
|
24
|
-
export declare const LegendLeagueId =
|
|
23
|
+
export declare const UnrankedLeagueId = 105000000;
|
|
24
|
+
export declare const LegendLeagueId = 105000034;
|
|
25
25
|
export declare const UnrankedWarLeagueId = 48000000;
|
|
26
26
|
export declare const Leagues: number[];
|
|
27
27
|
export declare const WarLeagues: number[];
|
package/dist/util/Constants.js
CHANGED
|
@@ -27,33 +27,13 @@ exports.UnrankedLeagueData = {
|
|
|
27
27
|
large: 'https://api-assets.clashofclans.com/leaguetiers/326/yyYo5DUFeFBZvmMEQh0ZxvG-1sUOZ_S3kDMB7RllXX0.png'
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
|
-
exports.UnrankedLeagueId =
|
|
31
|
-
exports.LegendLeagueId =
|
|
30
|
+
exports.UnrankedLeagueId = 105000000;
|
|
31
|
+
exports.LegendLeagueId = 105000034;
|
|
32
32
|
exports.UnrankedWarLeagueId = 48000000;
|
|
33
33
|
exports.Leagues = [
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
29000003,
|
|
38
|
-
29000004,
|
|
39
|
-
29000005,
|
|
40
|
-
29000006,
|
|
41
|
-
29000007,
|
|
42
|
-
29000008,
|
|
43
|
-
29000009,
|
|
44
|
-
29000010,
|
|
45
|
-
29000011,
|
|
46
|
-
29000012,
|
|
47
|
-
29000013,
|
|
48
|
-
29000014,
|
|
49
|
-
29000015,
|
|
50
|
-
29000016,
|
|
51
|
-
29000017,
|
|
52
|
-
29000018,
|
|
53
|
-
29000019,
|
|
54
|
-
29000020,
|
|
55
|
-
29000021,
|
|
56
|
-
exports.LegendLeagueId
|
|
34
|
+
105000000, 105000001, 105000002, 105000003, 105000004, 105000005, 105000006, 105000007, 105000008, 105000009, 105000010, 105000011,
|
|
35
|
+
105000012, 105000013, 105000014, 105000015, 105000016, 105000017, 105000018, 105000019, 105000020, 105000021, 105000022, 105000023,
|
|
36
|
+
105000024, 105000025, 105000026, 105000027, 105000028, 105000029, 105000030, 105000031, 105000032, 105000033, 105000034
|
|
57
37
|
];
|
|
58
38
|
exports.WarLeagues = [
|
|
59
39
|
48000000, 48000001, 48000002, 48000003, 48000004, 48000005, 48000006, 48000007, 48000008, 48000009, 48000010, 48000011, 48000012,
|
package/dist/util/Util.d.ts
CHANGED
|
@@ -54,6 +54,16 @@ export declare class Util extends null {
|
|
|
54
54
|
endTime: Date;
|
|
55
55
|
seasonId: string;
|
|
56
56
|
};
|
|
57
|
+
static getTournamentWindow(timestamp?: Date): {
|
|
58
|
+
id: string;
|
|
59
|
+
startTime: Date;
|
|
60
|
+
endTime: Date;
|
|
61
|
+
};
|
|
62
|
+
static getTournamentWindowById(id: string): {
|
|
63
|
+
id: string;
|
|
64
|
+
startTime: Date;
|
|
65
|
+
endTime: Date;
|
|
66
|
+
};
|
|
57
67
|
static allSettled<T>(values: Promise<T>[]): Promise<T[]>;
|
|
58
68
|
static delay(ms: number): Promise<unknown>;
|
|
59
69
|
}
|
package/dist/util/Util.js
CHANGED
|
@@ -195,6 +195,32 @@ class Util extends null {
|
|
|
195
195
|
const endTime = new Date(startTime.getTime() + seasonDuration);
|
|
196
196
|
return { startTime, endTime, seasonId };
|
|
197
197
|
}
|
|
198
|
+
static getTournamentWindow(timestamp) {
|
|
199
|
+
const now = timestamp ?? new Date();
|
|
200
|
+
const day = now.getUTCDay(); // 0=Sun, 1=Mon, ..., 6=Sat
|
|
201
|
+
const hour = now.getUTCHours();
|
|
202
|
+
// Days since last Monday
|
|
203
|
+
let daysSinceMonday = (day + 6) % 7; // e.g., if Mon -> 0, Tue -> 1, etc.
|
|
204
|
+
// If today is Monday but before 5 AM, move back one full week
|
|
205
|
+
if (day === 1 && hour < 5) {
|
|
206
|
+
daysSinceMonday = 7;
|
|
207
|
+
}
|
|
208
|
+
// Last Monday 5:00 AM UTC
|
|
209
|
+
const lastMonday = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate() - daysSinceMonday, 5, 0, 0, 0));
|
|
210
|
+
// Next Monday 5:00 AM UTC (7 days after last Monday)
|
|
211
|
+
const nextMonday = new Date(Date.UTC(lastMonday.getUTCFullYear(), lastMonday.getUTCMonth(), lastMonday.getUTCDate() + 7, 5, 0, 0, 0));
|
|
212
|
+
const year = lastMonday.getUTCFullYear();
|
|
213
|
+
const month = String(lastMonday.getUTCMonth() + 1).padStart(2, '0');
|
|
214
|
+
const dayOfMonth = String(lastMonday.getUTCDate()).padStart(2, '0');
|
|
215
|
+
return {
|
|
216
|
+
id: `${year}-${month}-${dayOfMonth}`,
|
|
217
|
+
startTime: lastMonday,
|
|
218
|
+
endTime: nextMonday
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
static getTournamentWindowById(id) {
|
|
222
|
+
return this.getTournamentWindow(new Date(`${id}T05:00:00.000Z`));
|
|
223
|
+
}
|
|
198
224
|
static async allSettled(values) {
|
|
199
225
|
return (await Promise.allSettled(values))
|
|
200
226
|
.filter((res) => res.status === 'fulfilled')
|