maidraw 0.11.15 → 0.12.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.
- package/dist/chu/index.d.ts +1 -5
- package/dist/chu/index.js +2 -38
- package/dist/chu/index.js.map +1 -1
- package/dist/chu/lib/adapter/index.d.ts +38 -24
- package/dist/chu/lib/adapter/index.js +4 -65
- package/dist/chu/lib/adapter/index.js.map +1 -1
- package/dist/chu/lib/adapter/kamaiTachi/index.d.ts +133 -26
- package/dist/chu/lib/adapter/kamaiTachi/index.js +265 -76
- package/dist/chu/lib/adapter/kamaiTachi/index.js.map +1 -1
- package/dist/chu/lib/adapter/lxns/index.d.ts +77 -17
- package/dist/chu/lib/adapter/lxns/index.js +71 -34
- package/dist/chu/lib/adapter/lxns/index.js.map +1 -1
- package/dist/chu/lib/database.d.ts +1 -0
- package/dist/chu/lib/database.js +10 -5
- package/dist/chu/lib/database.js.map +1 -1
- package/dist/chu/painter/best50/index.d.ts +36 -5
- package/dist/chu/painter/best50/index.js +41 -24
- package/dist/chu/painter/best50/index.js.map +1 -1
- package/dist/chu/painter/chart/index.d.ts +42 -5
- package/dist/chu/painter/chart/index.js +39 -20
- package/dist/chu/painter/chart/index.js.map +1 -1
- package/dist/chu/painter/index.d.ts +2 -2
- package/dist/chu/painter/index.js.map +1 -1
- package/dist/geki/index.d.ts +1 -5
- package/dist/geki/index.js +2 -38
- package/dist/geki/index.js.map +1 -1
- package/dist/geki/lib/adapter/index.d.ts +40 -26
- package/dist/geki/lib/adapter/index.js +4 -65
- package/dist/geki/lib/adapter/index.js.map +1 -1
- package/dist/geki/lib/adapter/kamaiTachi/index.d.ts +137 -30
- package/dist/geki/lib/adapter/kamaiTachi/index.js +281 -87
- package/dist/geki/lib/adapter/kamaiTachi/index.js.map +1 -1
- package/dist/geki/lib/database.d.ts +1 -0
- package/dist/geki/lib/database.js +12 -7
- package/dist/geki/lib/database.js.map +1 -1
- package/dist/geki/lib/util.d.ts +1 -1
- package/dist/geki/painter/best50/index.d.ts +36 -5
- package/dist/geki/painter/best50/index.js +43 -26
- package/dist/geki/painter/best50/index.js.map +1 -1
- package/dist/geki/painter/chart/index.d.ts +42 -5
- package/dist/geki/painter/chart/index.js +38 -19
- package/dist/geki/painter/chart/index.js.map +1 -1
- package/dist/geki/painter/index.d.ts +2 -2
- package/dist/geki/painter/index.js.map +1 -1
- package/dist/lib/adapter.d.ts +19 -0
- package/dist/lib/adapter.js +71 -0
- package/dist/lib/adapter.js.map +1 -0
- package/dist/lib/logger.d.ts +4 -0
- package/dist/lib/logger.js +49 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/painter.d.ts +15 -3
- package/dist/lib/painter.js.map +1 -1
- package/dist/lib/util.d.ts +10 -0
- package/dist/lib/util.js.map +1 -1
- package/dist/mai/index.d.ts +1 -5
- package/dist/mai/index.js +2 -38
- package/dist/mai/index.js.map +1 -1
- package/dist/mai/lib/adapter/divingFish/index.d.ts +80 -32
- package/dist/mai/lib/adapter/divingFish/index.js +51 -19
- package/dist/mai/lib/adapter/divingFish/index.js.map +1 -1
- package/dist/mai/lib/adapter/index.d.ts +37 -24
- package/dist/mai/lib/adapter/index.js +4 -65
- package/dist/mai/lib/adapter/index.js.map +1 -1
- package/dist/mai/lib/adapter/kamaiTachi/index.d.ts +124 -27
- package/dist/mai/lib/adapter/kamaiTachi/index.js +211 -61
- package/dist/mai/lib/adapter/kamaiTachi/index.js.map +1 -1
- package/dist/mai/lib/adapter/lxns/index.d.ts +121 -25
- package/dist/mai/lib/adapter/lxns/index.js +140 -45
- package/dist/mai/lib/adapter/lxns/index.js.map +1 -1
- package/dist/mai/lib/adapter/maishift/index.d.ts +83 -16
- package/dist/mai/lib/adapter/maishift/index.js +75 -26
- package/dist/mai/lib/adapter/maishift/index.js.map +1 -1
- package/dist/mai/lib/database.d.ts +1 -0
- package/dist/mai/lib/database.js +11 -6
- package/dist/mai/lib/database.js.map +1 -1
- package/dist/mai/painter/best50/index.d.ts +28 -6
- package/dist/mai/painter/best50/index.js +27 -14
- package/dist/mai/painter/best50/index.js.map +1 -1
- package/dist/mai/painter/chart/index.d.ts +42 -5
- package/dist/mai/painter/chart/index.js +39 -20
- package/dist/mai/painter/chart/index.js.map +1 -1
- package/dist/mai/painter/index.d.ts +2 -2
- package/dist/mai/painter/index.js.map +1 -1
- package/dist/mai/painter/level50/index.d.ts +28 -6
- package/dist/mai/painter/level50/index.js +26 -13
- package/dist/mai/painter/level50/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,17 +1,51 @@
|
|
|
1
1
|
import { IScore } from "../../../type";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { OngekiScoreAdapter } from "..";
|
|
3
|
+
type IBest55ResponseData = {
|
|
4
|
+
"invalid-user": {
|
|
5
|
+
username: string;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
type IBest60ResponseData = IBest55ResponseData & {};
|
|
9
|
+
type IProfileResponseData = IBest55ResponseData & {
|
|
10
|
+
"invalid-type": {
|
|
11
|
+
type: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
type IProfilePictureResponseData = IBest55ResponseData & {};
|
|
15
|
+
type IScoreResponseData = IBest55ResponseData & {};
|
|
16
|
+
type IResponseData = {
|
|
17
|
+
best55: IBest55ResponseData;
|
|
18
|
+
best60: IBest60ResponseData;
|
|
19
|
+
profile: IProfileResponseData;
|
|
20
|
+
profilePicture: IProfilePictureResponseData;
|
|
21
|
+
score: IScoreResponseData;
|
|
22
|
+
};
|
|
23
|
+
export declare class KamaiTachi extends OngekiScoreAdapter<IResponseData> {
|
|
4
24
|
private readonly CURRENT_VERSION;
|
|
5
25
|
constructor({ baseURL, currentVersion, }?: {
|
|
6
26
|
baseURL?: string;
|
|
7
27
|
currentVersion?: KamaiTachi.EGameVersions;
|
|
8
28
|
});
|
|
9
29
|
getPlayerScore(username: string, chartId: number): Promise<{
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
30
|
+
readonly status: "invalid-user";
|
|
31
|
+
readonly message: string;
|
|
32
|
+
readonly data: {
|
|
33
|
+
readonly username: string;
|
|
34
|
+
};
|
|
35
|
+
} | {
|
|
36
|
+
readonly status: "unknown";
|
|
37
|
+
readonly message: string;
|
|
38
|
+
readonly data: null;
|
|
39
|
+
} | {
|
|
40
|
+
readonly status: "success";
|
|
41
|
+
readonly message: "";
|
|
42
|
+
readonly data: {
|
|
43
|
+
readonly basic: IScore | null;
|
|
44
|
+
readonly advanced: IScore | null;
|
|
45
|
+
readonly expert: IScore | null;
|
|
46
|
+
readonly master: IScore | null;
|
|
47
|
+
readonly lunatic: IScore | null;
|
|
48
|
+
};
|
|
15
49
|
}>;
|
|
16
50
|
getPlatinumScore(score: KamaiTachi.IScore | KamaiTachi.IPb): number;
|
|
17
51
|
getPlatinumScoreRatio(chart: KamaiTachi.IChart, score: KamaiTachi.IScore | KamaiTachi.IPb): number;
|
|
@@ -27,24 +61,86 @@ export declare class KamaiTachi extends ScoreTrackerAdapter {
|
|
|
27
61
|
}> | undefined>;
|
|
28
62
|
private getDatabaseDifficulty;
|
|
29
63
|
private toMaiDrawScore;
|
|
30
|
-
getPlayerBest60(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
64
|
+
getPlayerBest60(username: string, currentVersion?: KamaiTachi.EGameVersions): Promise<{
|
|
65
|
+
readonly status: "invalid-user";
|
|
66
|
+
readonly message: string;
|
|
67
|
+
readonly data: {
|
|
68
|
+
readonly username: string;
|
|
69
|
+
};
|
|
70
|
+
} | {
|
|
71
|
+
readonly status: "unknown";
|
|
72
|
+
readonly message: string;
|
|
73
|
+
readonly data: null;
|
|
74
|
+
} | {
|
|
75
|
+
readonly status: "success";
|
|
76
|
+
readonly message: "";
|
|
77
|
+
readonly data: {
|
|
78
|
+
readonly new: IScore[];
|
|
79
|
+
readonly old: IScore[];
|
|
80
|
+
readonly plat: IScore[];
|
|
81
|
+
readonly best: IScore[];
|
|
82
|
+
};
|
|
83
|
+
}>;
|
|
84
|
+
getPlayerBest55(username: string, currentVersion?: KamaiTachi.EGameVersions): Promise<{
|
|
85
|
+
readonly status: "invalid-user";
|
|
86
|
+
readonly message: string;
|
|
87
|
+
readonly data: {
|
|
88
|
+
readonly username: string;
|
|
89
|
+
};
|
|
90
|
+
} | {
|
|
91
|
+
readonly status: "unknown";
|
|
92
|
+
readonly message: string;
|
|
93
|
+
readonly data: null;
|
|
94
|
+
} | {
|
|
95
|
+
readonly status: "success";
|
|
96
|
+
readonly message: "";
|
|
97
|
+
readonly data: {
|
|
98
|
+
readonly recent: IScore[];
|
|
99
|
+
readonly new: IScore[];
|
|
100
|
+
readonly old: IScore[];
|
|
101
|
+
readonly best: IScore[];
|
|
102
|
+
};
|
|
103
|
+
}>;
|
|
42
104
|
getPlayerInfo(userId: string, type: "refresh" | "classic"): Promise<{
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
105
|
+
readonly status: "invalid-user";
|
|
106
|
+
readonly message: string;
|
|
107
|
+
readonly data: {
|
|
108
|
+
readonly username: string;
|
|
109
|
+
};
|
|
110
|
+
} | {
|
|
111
|
+
readonly status: "unknown";
|
|
112
|
+
readonly message: string;
|
|
113
|
+
readonly data: null;
|
|
114
|
+
} | {
|
|
115
|
+
readonly status: "success";
|
|
116
|
+
readonly message: "";
|
|
117
|
+
readonly data: {
|
|
118
|
+
readonly name: string;
|
|
119
|
+
readonly rating: number;
|
|
120
|
+
};
|
|
121
|
+
} | {
|
|
122
|
+
readonly status: "invalid-type";
|
|
123
|
+
readonly message: string;
|
|
124
|
+
readonly data: {
|
|
125
|
+
readonly type: string;
|
|
126
|
+
};
|
|
127
|
+
}>;
|
|
46
128
|
private getPlayerProfileRaw;
|
|
47
|
-
getPlayerProfilePicture(userId: string): Promise<
|
|
129
|
+
getPlayerProfilePicture(userId: string): Promise<{
|
|
130
|
+
readonly status: "invalid-user";
|
|
131
|
+
readonly message: string;
|
|
132
|
+
readonly data: {
|
|
133
|
+
readonly username: string;
|
|
134
|
+
};
|
|
135
|
+
} | {
|
|
136
|
+
readonly status: "unknown";
|
|
137
|
+
readonly message: string;
|
|
138
|
+
readonly data: null;
|
|
139
|
+
} | {
|
|
140
|
+
readonly status: "success";
|
|
141
|
+
readonly message: "";
|
|
142
|
+
readonly data: Buffer;
|
|
143
|
+
}>;
|
|
48
144
|
ongeki(): KamaiTachi;
|
|
49
145
|
plus(): KamaiTachi;
|
|
50
146
|
summer(): KamaiTachi;
|
|
@@ -58,12 +154,21 @@ export declare class KamaiTachi extends ScoreTrackerAdapter {
|
|
|
58
154
|
refresh(): KamaiTachi;
|
|
59
155
|
}
|
|
60
156
|
export declare namespace KamaiTachi {
|
|
61
|
-
interface
|
|
157
|
+
interface IBaseResponse {
|
|
62
158
|
success: boolean;
|
|
63
159
|
description: string;
|
|
160
|
+
}
|
|
161
|
+
export interface ISuccessResponse<T> extends IBaseResponse {
|
|
162
|
+
success: true;
|
|
163
|
+
description: string;
|
|
64
164
|
body: T;
|
|
65
165
|
}
|
|
66
|
-
interface
|
|
166
|
+
export interface IFailureResponse extends IBaseResponse {
|
|
167
|
+
success: false;
|
|
168
|
+
description: string;
|
|
169
|
+
}
|
|
170
|
+
export type IResponse<T> = ISuccessResponse<T> | IFailureResponse;
|
|
171
|
+
export interface IChart {
|
|
67
172
|
chartID: string;
|
|
68
173
|
data: {
|
|
69
174
|
inGameID: number;
|
|
@@ -79,7 +184,7 @@ export declare namespace KamaiTachi {
|
|
|
79
184
|
songID: number;
|
|
80
185
|
versions: string[];
|
|
81
186
|
}
|
|
82
|
-
interface ISong {
|
|
187
|
+
export interface ISong {
|
|
83
188
|
altTitles: string[];
|
|
84
189
|
artist: string;
|
|
85
190
|
data: {
|
|
@@ -89,7 +194,7 @@ export declare namespace KamaiTachi {
|
|
|
89
194
|
searchTerms: string[];
|
|
90
195
|
title: string;
|
|
91
196
|
}
|
|
92
|
-
interface IScore {
|
|
197
|
+
export interface IScore {
|
|
93
198
|
chartID: string;
|
|
94
199
|
userID: number;
|
|
95
200
|
comment: string | null;
|
|
@@ -144,7 +249,7 @@ export declare namespace KamaiTachi {
|
|
|
144
249
|
timeAchieved: number;
|
|
145
250
|
service: string;
|
|
146
251
|
}
|
|
147
|
-
interface IPb {
|
|
252
|
+
export interface IPb {
|
|
148
253
|
chartID: string;
|
|
149
254
|
userID: number;
|
|
150
255
|
calculatedData: {
|
|
@@ -199,7 +304,7 @@ export declare namespace KamaiTachi {
|
|
|
199
304
|
scoreID: string;
|
|
200
305
|
}[];
|
|
201
306
|
}
|
|
202
|
-
enum EGameVersions {
|
|
307
|
+
export enum EGameVersions {
|
|
203
308
|
REFRESH = "\u30AA\u30F3\u30B2\u30AD Re:Fresh",
|
|
204
309
|
BRIGHT_MEMORY_ACT_3 = "\u30AA\u30F3\u30B2\u30AD bright MEMORY Act.3",
|
|
205
310
|
BRIGHT_MEMORY_ACT_2 = "\u30AA\u30F3\u30B2\u30AD bright MEMORY Act.2",
|
|
@@ -219,5 +324,7 @@ export declare namespace KamaiTachi {
|
|
|
219
324
|
* @param b Game version.
|
|
220
325
|
* @returns positive if a is newer, negative if b is newer, 0 if they are the same.
|
|
221
326
|
*/
|
|
222
|
-
function compareGameVersions(a: EGameVersions, b: EGameVersions): number;
|
|
327
|
+
export function compareGameVersions(a: EGameVersions, b: EGameVersions): number;
|
|
328
|
+
export {};
|
|
223
329
|
}
|
|
330
|
+
export {};
|
|
@@ -6,7 +6,7 @@ const __1 = require("..");
|
|
|
6
6
|
const util_1 = require("../../../../lib/util");
|
|
7
7
|
const util_2 = require("../../util");
|
|
8
8
|
const database_1 = require("../../database");
|
|
9
|
-
class KamaiTachi extends __1.
|
|
9
|
+
class KamaiTachi extends __1.OngekiScoreAdapter {
|
|
10
10
|
CURRENT_VERSION;
|
|
11
11
|
constructor({ baseURL = "https://kamai.tachi.ac/", currentVersion = KamaiTachi.EGameVersions.REFRESH, } = {}) {
|
|
12
12
|
super({ baseURL });
|
|
@@ -14,14 +14,33 @@ class KamaiTachi extends __1.ScoreTrackerAdapter {
|
|
|
14
14
|
}
|
|
15
15
|
async getPlayerScore(username, chartId) {
|
|
16
16
|
const rawPBs = await this.getPlayerPB(username);
|
|
17
|
-
if (!rawPBs
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
master: null,
|
|
23
|
-
lunatic: null,
|
|
17
|
+
if (!rawPBs) {
|
|
18
|
+
const res = {
|
|
19
|
+
status: "unknown",
|
|
20
|
+
message: "An unknown error occurred.",
|
|
21
|
+
data: null,
|
|
24
22
|
};
|
|
23
|
+
return res;
|
|
24
|
+
}
|
|
25
|
+
if (!rawPBs.success) {
|
|
26
|
+
if (rawPBs.description.includes("does not exist")) {
|
|
27
|
+
const res = {
|
|
28
|
+
status: "invalid-user",
|
|
29
|
+
message: rawPBs.description ||
|
|
30
|
+
`${username} is not a valid user.`,
|
|
31
|
+
data: { username },
|
|
32
|
+
};
|
|
33
|
+
return res;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
const res = {
|
|
37
|
+
status: "unknown",
|
|
38
|
+
message: "An unknown error occurred: " + rawPBs.description,
|
|
39
|
+
data: null,
|
|
40
|
+
};
|
|
41
|
+
return res;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
25
44
|
const pbs = [];
|
|
26
45
|
for (const pb of rawPBs.body.pbs) {
|
|
27
46
|
let chart = rawPBs.body.charts.find((v) => v.chartID == pb.chartID);
|
|
@@ -43,23 +62,28 @@ class KamaiTachi extends __1.ScoreTrackerAdapter {
|
|
|
43
62
|
v.chart.data.inGameID == chartId);
|
|
44
63
|
const lunatic = pbs.find((v) => difficultyCompare(v.chart, "Lunatic") &&
|
|
45
64
|
v.chart.data.inGameID == chartId);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
65
|
+
const res = {
|
|
66
|
+
status: "success",
|
|
67
|
+
message: "",
|
|
68
|
+
data: {
|
|
69
|
+
basic: basic
|
|
70
|
+
? this.toMaiDrawScore(basic.pb, basic.chart, basic.song)
|
|
71
|
+
: null,
|
|
72
|
+
advanced: advanced
|
|
73
|
+
? this.toMaiDrawScore(advanced.pb, advanced.chart, advanced.song)
|
|
74
|
+
: null,
|
|
75
|
+
expert: expert
|
|
76
|
+
? this.toMaiDrawScore(expert.pb, expert.chart, expert.song)
|
|
77
|
+
: null,
|
|
78
|
+
master: master
|
|
79
|
+
? this.toMaiDrawScore(master.pb, master.chart, master.song)
|
|
80
|
+
: null,
|
|
81
|
+
lunatic: lunatic
|
|
82
|
+
? this.toMaiDrawScore(lunatic.pb, lunatic.chart, lunatic.song)
|
|
83
|
+
: null,
|
|
84
|
+
},
|
|
62
85
|
};
|
|
86
|
+
return res;
|
|
63
87
|
}
|
|
64
88
|
getPlatinumScore(score) {
|
|
65
89
|
const ASSUMED_PLAT_SCORE_RATE = 0;
|
|
@@ -204,10 +228,35 @@ class KamaiTachi extends __1.ScoreTrackerAdapter {
|
|
|
204
228
|
})(),
|
|
205
229
|
};
|
|
206
230
|
}
|
|
207
|
-
async getPlayerBest60(
|
|
208
|
-
const rawPBs = await this.getPlayerPB(
|
|
209
|
-
if (!rawPBs
|
|
210
|
-
|
|
231
|
+
async getPlayerBest60(username, currentVersion = this.CURRENT_VERSION) {
|
|
232
|
+
const rawPBs = await this.getPlayerPB(username);
|
|
233
|
+
if (!rawPBs) {
|
|
234
|
+
const res = {
|
|
235
|
+
status: "unknown",
|
|
236
|
+
message: "An unknown error occurred.",
|
|
237
|
+
data: null,
|
|
238
|
+
};
|
|
239
|
+
return res;
|
|
240
|
+
}
|
|
241
|
+
if (!rawPBs.success) {
|
|
242
|
+
if (rawPBs.description.includes("does not exist")) {
|
|
243
|
+
const res = {
|
|
244
|
+
status: "invalid-user",
|
|
245
|
+
message: rawPBs.description ||
|
|
246
|
+
`${username} is not a valid user.`,
|
|
247
|
+
data: { username },
|
|
248
|
+
};
|
|
249
|
+
return res;
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
const res = {
|
|
253
|
+
status: "unknown",
|
|
254
|
+
message: "An unknown error occurred: " + rawPBs.description,
|
|
255
|
+
data: null,
|
|
256
|
+
};
|
|
257
|
+
return res;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
211
260
|
const pbs = [];
|
|
212
261
|
for (const pb of rawPBs.body.pbs) {
|
|
213
262
|
let chart = rawPBs.body.charts.find((v) => v.chartID == pb.chartID);
|
|
@@ -221,31 +270,88 @@ class KamaiTachi extends __1.ScoreTrackerAdapter {
|
|
|
221
270
|
KamaiTachi.compareGameVersions(currentVersion, v.chart.data.displayVersion) > 0);
|
|
222
271
|
const bestScores = pbs.filter((v) => v.chart &&
|
|
223
272
|
KamaiTachi.compareGameVersions(currentVersion, v.chart.data.displayVersion) >= 0);
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
273
|
+
const res = {
|
|
274
|
+
status: "success",
|
|
275
|
+
message: "",
|
|
276
|
+
data: {
|
|
277
|
+
new: newScores
|
|
278
|
+
.map((v) => this.toMaiDrawScore(v.pb, v.chart, v.song))
|
|
279
|
+
.sort((a, b) => b.rating - a.rating || b.score - a.score)
|
|
280
|
+
.slice(0, 10),
|
|
281
|
+
old: oldScores
|
|
282
|
+
.map((v) => this.toMaiDrawScore(v.pb, v.chart, v.song))
|
|
283
|
+
.sort((a, b) => b.rating - a.rating || b.score - a.score)
|
|
284
|
+
.slice(0, 50),
|
|
285
|
+
plat: bestScores
|
|
286
|
+
.map((v) => this.toMaiDrawScore(v.pb, v.chart, v.song))
|
|
287
|
+
.sort((a, b) => b.starRating - a.starRating || b.score - a.score)
|
|
288
|
+
.filter((v) => v.starRating > 0)
|
|
289
|
+
.slice(0, 50),
|
|
290
|
+
best: bestScores
|
|
291
|
+
.map((v) => this.toMaiDrawScore(v.pb, v.chart, v.song))
|
|
292
|
+
.sort((a, b) => b.rating - a.rating || b.score - a.score)
|
|
293
|
+
.slice(0, 60),
|
|
294
|
+
},
|
|
242
295
|
};
|
|
296
|
+
return res;
|
|
243
297
|
}
|
|
244
|
-
async getPlayerBest55(
|
|
245
|
-
const rawPBs = await this.getPlayerPB(
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
298
|
+
async getPlayerBest55(username, currentVersion = this.CURRENT_VERSION) {
|
|
299
|
+
const rawPBs = await this.getPlayerPB(username);
|
|
300
|
+
if (!rawPBs) {
|
|
301
|
+
const res = {
|
|
302
|
+
status: "unknown",
|
|
303
|
+
message: "An unknown error occurred.",
|
|
304
|
+
data: null,
|
|
305
|
+
};
|
|
306
|
+
return res;
|
|
307
|
+
}
|
|
308
|
+
if (!rawPBs.success) {
|
|
309
|
+
if (rawPBs.description.includes("does not exist")) {
|
|
310
|
+
const res = {
|
|
311
|
+
status: "invalid-user",
|
|
312
|
+
message: rawPBs.description ||
|
|
313
|
+
`${username} is not a valid user.`,
|
|
314
|
+
data: { username },
|
|
315
|
+
};
|
|
316
|
+
return res;
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
const res = {
|
|
320
|
+
status: "unknown",
|
|
321
|
+
message: "An unknown error occurred: " + rawPBs.description,
|
|
322
|
+
data: null,
|
|
323
|
+
};
|
|
324
|
+
return res;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
const rawRecents = await this.getPlayerRecentScores(username);
|
|
328
|
+
if (!rawRecents) {
|
|
329
|
+
const res = {
|
|
330
|
+
status: "unknown",
|
|
331
|
+
message: "An unknown error occurred.",
|
|
332
|
+
data: null,
|
|
333
|
+
};
|
|
334
|
+
return res;
|
|
335
|
+
}
|
|
336
|
+
if (!rawRecents.success) {
|
|
337
|
+
if (rawRecents.description.includes("does not exist")) {
|
|
338
|
+
const res = {
|
|
339
|
+
status: "invalid-user",
|
|
340
|
+
message: rawRecents.description ||
|
|
341
|
+
`${username} is not a valid user.`,
|
|
342
|
+
data: { username },
|
|
343
|
+
};
|
|
344
|
+
return res;
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
const res = {
|
|
348
|
+
status: "unknown",
|
|
349
|
+
message: "An unknown error occurred: " + rawRecents.description,
|
|
350
|
+
data: null,
|
|
351
|
+
};
|
|
352
|
+
return res;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
249
355
|
const pbs = [];
|
|
250
356
|
const recents = [];
|
|
251
357
|
for (const pb of rawPBs.body.pbs) {
|
|
@@ -324,66 +430,154 @@ class KamaiTachi extends __1.ScoreTrackerAdapter {
|
|
|
324
430
|
.slice(0, 10)
|
|
325
431
|
.map((v) => v.score);
|
|
326
432
|
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
433
|
+
const res = {
|
|
434
|
+
status: "success",
|
|
435
|
+
message: "",
|
|
436
|
+
data: {
|
|
437
|
+
recent: ratingGuardSimulation(recentScores
|
|
438
|
+
.reverse()
|
|
439
|
+
.map((v) => this.toMaiDrawScore(v.scores, v.chart, v.song, "classic"))
|
|
440
|
+
.filter((v) => v.chart.difficulty != type_1.EDifficulty.LUNATIC)),
|
|
441
|
+
new: newScores
|
|
442
|
+
.map((v) => this.toMaiDrawScore(v.pb, v.chart, v.song, "classic"))
|
|
443
|
+
.sort((a, b) => b.rating - a.rating || b.score - a.score)
|
|
444
|
+
.slice(0, 15),
|
|
445
|
+
old: oldScores
|
|
446
|
+
.map((v) => this.toMaiDrawScore(v.pb, v.chart, v.song, "classic"))
|
|
447
|
+
.sort((a, b) => b.rating - a.rating || b.score - a.score)
|
|
448
|
+
.slice(0, 30),
|
|
449
|
+
best: pbs
|
|
450
|
+
.map((v) => this.toMaiDrawScore(v.pb, v.chart, v.song, "classic"))
|
|
451
|
+
.sort((a, b) => b.rating - a.rating || b.score - a.score)
|
|
452
|
+
.slice(0, 45),
|
|
453
|
+
},
|
|
344
454
|
};
|
|
455
|
+
return res;
|
|
345
456
|
}
|
|
346
457
|
async getPlayerInfo(userId, type) {
|
|
347
458
|
const profile = await this.getPlayerProfileRaw(userId);
|
|
459
|
+
if (!profile) {
|
|
460
|
+
const res = {
|
|
461
|
+
status: "unknown",
|
|
462
|
+
message: "An unknown error occurred.",
|
|
463
|
+
data: null,
|
|
464
|
+
};
|
|
465
|
+
return res;
|
|
466
|
+
}
|
|
467
|
+
if (!profile.success) {
|
|
468
|
+
if (profile.description.includes("does not exist")) {
|
|
469
|
+
const res = {
|
|
470
|
+
status: "invalid-user",
|
|
471
|
+
message: profile.description || `${userId} is not a valid user.`,
|
|
472
|
+
data: { username: userId },
|
|
473
|
+
};
|
|
474
|
+
return res;
|
|
475
|
+
}
|
|
476
|
+
else {
|
|
477
|
+
const res = {
|
|
478
|
+
status: "unknown",
|
|
479
|
+
message: "An unknown error occurred: " + profile.description,
|
|
480
|
+
data: null,
|
|
481
|
+
};
|
|
482
|
+
return res;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
348
485
|
if (type == "refresh") {
|
|
349
486
|
const scores = await this.getPlayerBest60(userId);
|
|
350
|
-
if (!
|
|
351
|
-
return
|
|
352
|
-
const newRating = scores.new
|
|
487
|
+
if (!(scores.status == "success"))
|
|
488
|
+
return scores;
|
|
489
|
+
const newRating = scores.data.new
|
|
353
490
|
.map((v) => util_1.Util.truncateNumber(v.rating / 5, 3))
|
|
354
491
|
.reduce((sum, v) => sum + v, 0);
|
|
355
|
-
const oldRating = scores.old
|
|
492
|
+
const oldRating = scores.data.old
|
|
356
493
|
.map((v) => v.rating)
|
|
357
494
|
.reduce((sum, v) => sum + v, 0);
|
|
358
|
-
const platRating = scores.plat
|
|
495
|
+
const platRating = scores.data.plat
|
|
359
496
|
.map((v) => v.starRating)
|
|
360
497
|
.reduce((sum, v) => sum + v, 0);
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
498
|
+
const res = {
|
|
499
|
+
status: "success",
|
|
500
|
+
message: "",
|
|
501
|
+
data: {
|
|
502
|
+
name: profile?.body.username,
|
|
503
|
+
rating: util_1.Util.truncateNumber(newRating / 10, 3) +
|
|
504
|
+
util_1.Util.truncateNumber(oldRating / 50, 3) +
|
|
505
|
+
util_1.Util.truncateNumber(platRating / 50, 3),
|
|
506
|
+
},
|
|
366
507
|
};
|
|
508
|
+
return res;
|
|
367
509
|
}
|
|
368
510
|
else if (type == "classic") {
|
|
369
511
|
const scores = await this.getPlayerBest55(userId);
|
|
370
|
-
if (!
|
|
371
|
-
return
|
|
512
|
+
if (!(scores.status == "success"))
|
|
513
|
+
return scores;
|
|
372
514
|
let rating = 0;
|
|
373
|
-
[
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
515
|
+
[
|
|
516
|
+
...scores.data.recent,
|
|
517
|
+
...scores.data.new,
|
|
518
|
+
...scores.data.old,
|
|
519
|
+
].forEach((v) => (rating += v.rating));
|
|
520
|
+
const res = {
|
|
521
|
+
status: "success",
|
|
522
|
+
message: "",
|
|
523
|
+
data: {
|
|
524
|
+
name: profile?.body.username,
|
|
525
|
+
rating: util_1.Util.truncateNumber(rating / 55, 2),
|
|
526
|
+
},
|
|
377
527
|
};
|
|
528
|
+
return res;
|
|
529
|
+
}
|
|
530
|
+
else {
|
|
531
|
+
const res = {
|
|
532
|
+
status: "invalid-type",
|
|
533
|
+
message: `${type} is not a valid type.`,
|
|
534
|
+
data: { type: type },
|
|
535
|
+
};
|
|
536
|
+
return res;
|
|
378
537
|
}
|
|
379
|
-
else
|
|
380
|
-
return null;
|
|
381
538
|
}
|
|
382
539
|
async getPlayerProfileRaw(userId) {
|
|
383
540
|
return this.get(`/api/v1/users/${userId}`);
|
|
384
541
|
}
|
|
385
542
|
async getPlayerProfilePicture(userId) {
|
|
386
|
-
|
|
543
|
+
const pfp = (await this.get(`/api/v1/users/${userId}/pfp`, undefined, 2 * 60 * 60 * 1000, { responseType: "arraybuffer" })) || null;
|
|
544
|
+
if (!pfp) {
|
|
545
|
+
const res = {
|
|
546
|
+
status: "unknown",
|
|
547
|
+
message: "An unknown error occurred.",
|
|
548
|
+
data: null,
|
|
549
|
+
};
|
|
550
|
+
return res;
|
|
551
|
+
}
|
|
552
|
+
function isFailureResponse(payload) {
|
|
553
|
+
return (typeof payload.success === "boolean" &&
|
|
554
|
+
payload.success === false &&
|
|
555
|
+
typeof payload.description === "string");
|
|
556
|
+
}
|
|
557
|
+
if (isFailureResponse(pfp)) {
|
|
558
|
+
if (pfp.description.includes("does not exist")) {
|
|
559
|
+
const res = {
|
|
560
|
+
status: "invalid-user",
|
|
561
|
+
message: pfp.description || `${userId} is not a valid user.`,
|
|
562
|
+
data: { username: userId },
|
|
563
|
+
};
|
|
564
|
+
return res;
|
|
565
|
+
}
|
|
566
|
+
else {
|
|
567
|
+
const res = {
|
|
568
|
+
status: "unknown",
|
|
569
|
+
message: "An unknown error occurred: " + pfp.description,
|
|
570
|
+
data: null,
|
|
571
|
+
};
|
|
572
|
+
return res;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
const res = {
|
|
576
|
+
status: "success",
|
|
577
|
+
message: "",
|
|
578
|
+
data: pfp,
|
|
579
|
+
};
|
|
580
|
+
return res;
|
|
387
581
|
}
|
|
388
582
|
ongeki() {
|
|
389
583
|
return new KamaiTachi({
|