@hizollo/osu-api 1.2.0 → 1.2.2
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/index.cjs +991 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +703 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +703 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +846 -822
- package/dist/index.mjs.map +1 -1
- package/package.json +20 -12
- package/dist/index.d.ts +0 -728
- package/dist/index.js +0 -973
- package/dist/index.js.map +0 -1
package/dist/index.js
DELETED
|
@@ -1,973 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use strict";
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
-
mod
|
|
24
|
-
));
|
|
25
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
26
|
-
|
|
27
|
-
// index.ts
|
|
28
|
-
var osu_api_exports = {};
|
|
29
|
-
__export(osu_api_exports, {
|
|
30
|
-
AccuracyCalculator: () => AccuracyCalculator,
|
|
31
|
-
BaseManager: () => BaseManager,
|
|
32
|
-
BaseScore: () => BaseScore,
|
|
33
|
-
Beatmap: () => Beatmap,
|
|
34
|
-
BeatmapApprovedState: () => BeatmapApprovedState,
|
|
35
|
-
BeatmapGenre: () => BeatmapGenre,
|
|
36
|
-
BeatmapLanguage: () => BeatmapLanguage,
|
|
37
|
-
BeatmapManager: () => BeatmapManager,
|
|
38
|
-
BeatmapScore: () => BeatmapScore,
|
|
39
|
-
Beatmapset: () => Beatmapset,
|
|
40
|
-
Client: () => Client,
|
|
41
|
-
GameMode: () => GameMode,
|
|
42
|
-
Match: () => Match,
|
|
43
|
-
MatchGame: () => MatchGame,
|
|
44
|
-
MatchManager: () => MatchManager,
|
|
45
|
-
MatchScore: () => MatchScore,
|
|
46
|
-
MatchScoringType: () => MatchScoringType,
|
|
47
|
-
MatchTeamType: () => MatchTeamType,
|
|
48
|
-
Mods: () => Mods,
|
|
49
|
-
ModsAbbreviation: () => ModsAbbreviation,
|
|
50
|
-
ModsBitField: () => ModsBitField,
|
|
51
|
-
Replay: () => Replay,
|
|
52
|
-
ReplayManager: () => ReplayManager,
|
|
53
|
-
ScoreManager: () => ScoreManager,
|
|
54
|
-
ScoreRank: () => ScoreRank,
|
|
55
|
-
Team: () => Team,
|
|
56
|
-
URLBuilder: () => URLBuilder,
|
|
57
|
-
User: () => User,
|
|
58
|
-
UserEvent: () => UserEvent,
|
|
59
|
-
UserManager: () => UserManager,
|
|
60
|
-
UserRequestType: () => UserRequestType
|
|
61
|
-
});
|
|
62
|
-
module.exports = __toCommonJS(osu_api_exports);
|
|
63
|
-
|
|
64
|
-
// src/Client.ts
|
|
65
|
-
var import_superagent2 = __toESM(require("superagent"));
|
|
66
|
-
|
|
67
|
-
// src/managers/UserManager.ts
|
|
68
|
-
var import_superagent = __toESM(require("superagent"));
|
|
69
|
-
|
|
70
|
-
// src/types/enums.ts
|
|
71
|
-
var GameMode = /* @__PURE__ */ ((GameMode3) => {
|
|
72
|
-
GameMode3[GameMode3["Standard"] = 0] = "Standard";
|
|
73
|
-
GameMode3[GameMode3["Taiko"] = 1] = "Taiko";
|
|
74
|
-
GameMode3[GameMode3["Catch"] = 2] = "Catch";
|
|
75
|
-
GameMode3[GameMode3["Mania"] = 3] = "Mania";
|
|
76
|
-
return GameMode3;
|
|
77
|
-
})(GameMode || {});
|
|
78
|
-
var UserRequestType = /* @__PURE__ */ ((UserRequestType2) => {
|
|
79
|
-
UserRequestType2["String"] = "string";
|
|
80
|
-
UserRequestType2["Id"] = "id";
|
|
81
|
-
return UserRequestType2;
|
|
82
|
-
})(UserRequestType || {});
|
|
83
|
-
var Mods = {
|
|
84
|
-
None: 0n,
|
|
85
|
-
NoFail: 1n << 0n,
|
|
86
|
-
Easy: 1n << 1n,
|
|
87
|
-
TouchDevice: 1n << 2n,
|
|
88
|
-
Hidden: 1n << 3n,
|
|
89
|
-
HardRock: 1n << 4n,
|
|
90
|
-
SuddenDeath: 1n << 5n,
|
|
91
|
-
DoubleTime: 1n << 6n,
|
|
92
|
-
Relax: 1n << 7n,
|
|
93
|
-
HalfTime: 1n << 8n,
|
|
94
|
-
Nightcore: 1n << 9n,
|
|
95
|
-
Flashlight: 1n << 10n,
|
|
96
|
-
Autoplay: 1n << 11n,
|
|
97
|
-
SpunOut: 1n << 12n,
|
|
98
|
-
AutoPilot: 1n << 13n,
|
|
99
|
-
Perfect: 1n << 14n,
|
|
100
|
-
Key4: 1n << 15n,
|
|
101
|
-
Key5: 1n << 16n,
|
|
102
|
-
Key6: 1n << 17n,
|
|
103
|
-
Key7: 1n << 18n,
|
|
104
|
-
Key8: 1n << 19n,
|
|
105
|
-
FadeIn: 1n << 20n,
|
|
106
|
-
Random: 1n << 21n,
|
|
107
|
-
Cinema: 1n << 22n,
|
|
108
|
-
Target: 1n << 23n,
|
|
109
|
-
Key9: 1n << 24n,
|
|
110
|
-
KeyCoop: 1n << 25n,
|
|
111
|
-
Key1: 1n << 26n,
|
|
112
|
-
Key3: 1n << 27n,
|
|
113
|
-
Key2: 1n << 28n,
|
|
114
|
-
ScoreV2: 1n << 29n,
|
|
115
|
-
Mirror: 1n << 30n
|
|
116
|
-
};
|
|
117
|
-
var ModsAbbreviation = {
|
|
118
|
-
NoFail: "NF",
|
|
119
|
-
Easy: "EZ",
|
|
120
|
-
TouchDevice: "TD",
|
|
121
|
-
Hidden: "HD",
|
|
122
|
-
HardRock: "HR",
|
|
123
|
-
SuddenDeath: "SD",
|
|
124
|
-
DoubleTime: "DT",
|
|
125
|
-
Relax: "RX",
|
|
126
|
-
HalfTime: "HT",
|
|
127
|
-
Nightcore: "NC",
|
|
128
|
-
Flashlight: "FL",
|
|
129
|
-
Autoplay: "AT",
|
|
130
|
-
SpunOut: "SO",
|
|
131
|
-
AutoPilot: "AP",
|
|
132
|
-
Perfect: "PF",
|
|
133
|
-
Key4: "4K",
|
|
134
|
-
Key5: "5K",
|
|
135
|
-
Key6: "6K",
|
|
136
|
-
Key7: "7K",
|
|
137
|
-
Key8: "8K",
|
|
138
|
-
FadeIn: "FI",
|
|
139
|
-
Random: "RD",
|
|
140
|
-
Cinema: "CM",
|
|
141
|
-
Target: "TP",
|
|
142
|
-
Key9: "9K",
|
|
143
|
-
KeyCoop: "CP",
|
|
144
|
-
Key1: "1K",
|
|
145
|
-
Key3: "3K",
|
|
146
|
-
Key2: "2K",
|
|
147
|
-
ScoreV2: "SV2",
|
|
148
|
-
Mirror: "MR"
|
|
149
|
-
};
|
|
150
|
-
var BeatmapApprovedState = /* @__PURE__ */ ((BeatmapApprovedState3) => {
|
|
151
|
-
BeatmapApprovedState3[BeatmapApprovedState3["Graveyard"] = -2] = "Graveyard";
|
|
152
|
-
BeatmapApprovedState3[BeatmapApprovedState3["WIP"] = -1] = "WIP";
|
|
153
|
-
BeatmapApprovedState3[BeatmapApprovedState3["Pending"] = 0] = "Pending";
|
|
154
|
-
BeatmapApprovedState3[BeatmapApprovedState3["Ranked"] = 1] = "Ranked";
|
|
155
|
-
BeatmapApprovedState3[BeatmapApprovedState3["Approved"] = 2] = "Approved";
|
|
156
|
-
BeatmapApprovedState3[BeatmapApprovedState3["Qualified"] = 3] = "Qualified";
|
|
157
|
-
BeatmapApprovedState3[BeatmapApprovedState3["Loved"] = 4] = "Loved";
|
|
158
|
-
return BeatmapApprovedState3;
|
|
159
|
-
})(BeatmapApprovedState || {});
|
|
160
|
-
var BeatmapGenre = /* @__PURE__ */ ((BeatmapGenre3) => {
|
|
161
|
-
BeatmapGenre3[BeatmapGenre3["Any"] = 0] = "Any";
|
|
162
|
-
BeatmapGenre3[BeatmapGenre3["Unspecified"] = 1] = "Unspecified";
|
|
163
|
-
BeatmapGenre3[BeatmapGenre3["VideoGame"] = 2] = "VideoGame";
|
|
164
|
-
BeatmapGenre3[BeatmapGenre3["Anime"] = 3] = "Anime";
|
|
165
|
-
BeatmapGenre3[BeatmapGenre3["Rock"] = 4] = "Rock";
|
|
166
|
-
BeatmapGenre3[BeatmapGenre3["Pop"] = 5] = "Pop";
|
|
167
|
-
BeatmapGenre3[BeatmapGenre3["Other"] = 6] = "Other";
|
|
168
|
-
BeatmapGenre3[BeatmapGenre3["Novelty"] = 7] = "Novelty";
|
|
169
|
-
BeatmapGenre3[BeatmapGenre3["HipHop"] = 9] = "HipHop";
|
|
170
|
-
BeatmapGenre3[BeatmapGenre3["Electronic"] = 10] = "Electronic";
|
|
171
|
-
BeatmapGenre3[BeatmapGenre3["Metal"] = 11] = "Metal";
|
|
172
|
-
BeatmapGenre3[BeatmapGenre3["Classic"] = 12] = "Classic";
|
|
173
|
-
BeatmapGenre3[BeatmapGenre3["Folk"] = 13] = "Folk";
|
|
174
|
-
BeatmapGenre3[BeatmapGenre3["Jazz"] = 14] = "Jazz";
|
|
175
|
-
return BeatmapGenre3;
|
|
176
|
-
})(BeatmapGenre || {});
|
|
177
|
-
var BeatmapLanguage = /* @__PURE__ */ ((BeatmapLanguage3) => {
|
|
178
|
-
BeatmapLanguage3[BeatmapLanguage3["Any"] = 0] = "Any";
|
|
179
|
-
BeatmapLanguage3[BeatmapLanguage3["Unspecified"] = 1] = "Unspecified";
|
|
180
|
-
BeatmapLanguage3[BeatmapLanguage3["English"] = 2] = "English";
|
|
181
|
-
BeatmapLanguage3[BeatmapLanguage3["Japanese"] = 3] = "Japanese";
|
|
182
|
-
BeatmapLanguage3[BeatmapLanguage3["Chinese"] = 4] = "Chinese";
|
|
183
|
-
BeatmapLanguage3[BeatmapLanguage3["Instrumental"] = 5] = "Instrumental";
|
|
184
|
-
BeatmapLanguage3[BeatmapLanguage3["Korean"] = 6] = "Korean";
|
|
185
|
-
BeatmapLanguage3[BeatmapLanguage3["French"] = 7] = "French";
|
|
186
|
-
BeatmapLanguage3[BeatmapLanguage3["German"] = 8] = "German";
|
|
187
|
-
BeatmapLanguage3[BeatmapLanguage3["Swedish"] = 9] = "Swedish";
|
|
188
|
-
BeatmapLanguage3[BeatmapLanguage3["Spanish"] = 10] = "Spanish";
|
|
189
|
-
BeatmapLanguage3[BeatmapLanguage3["Italian"] = 11] = "Italian";
|
|
190
|
-
BeatmapLanguage3[BeatmapLanguage3["Russian"] = 12] = "Russian";
|
|
191
|
-
BeatmapLanguage3[BeatmapLanguage3["Polish"] = 13] = "Polish";
|
|
192
|
-
BeatmapLanguage3[BeatmapLanguage3["Other"] = 14] = "Other";
|
|
193
|
-
return BeatmapLanguage3;
|
|
194
|
-
})(BeatmapLanguage || {});
|
|
195
|
-
var ScoreRank = /* @__PURE__ */ ((ScoreRank2) => {
|
|
196
|
-
ScoreRank2[ScoreRank2["XH"] = 0] = "XH";
|
|
197
|
-
ScoreRank2[ScoreRank2["X"] = 1] = "X";
|
|
198
|
-
ScoreRank2[ScoreRank2["SH"] = 2] = "SH";
|
|
199
|
-
ScoreRank2[ScoreRank2["S"] = 3] = "S";
|
|
200
|
-
ScoreRank2[ScoreRank2["A"] = 4] = "A";
|
|
201
|
-
ScoreRank2[ScoreRank2["B"] = 5] = "B";
|
|
202
|
-
ScoreRank2[ScoreRank2["C"] = 6] = "C";
|
|
203
|
-
ScoreRank2[ScoreRank2["D"] = 7] = "D";
|
|
204
|
-
ScoreRank2[ScoreRank2["F"] = 8] = "F";
|
|
205
|
-
return ScoreRank2;
|
|
206
|
-
})(ScoreRank || {});
|
|
207
|
-
var MatchScoringType = /* @__PURE__ */ ((MatchScoringType2) => {
|
|
208
|
-
MatchScoringType2[MatchScoringType2["Score"] = 0] = "Score";
|
|
209
|
-
MatchScoringType2[MatchScoringType2["Accuracy"] = 1] = "Accuracy";
|
|
210
|
-
MatchScoringType2[MatchScoringType2["Combo"] = 2] = "Combo";
|
|
211
|
-
MatchScoringType2[MatchScoringType2["ScoreV2"] = 3] = "ScoreV2";
|
|
212
|
-
return MatchScoringType2;
|
|
213
|
-
})(MatchScoringType || {});
|
|
214
|
-
var MatchTeamType = /* @__PURE__ */ ((MatchTeamType2) => {
|
|
215
|
-
MatchTeamType2[MatchTeamType2["HeadToHead"] = 0] = "HeadToHead";
|
|
216
|
-
MatchTeamType2[MatchTeamType2["TagCoop"] = 1] = "TagCoop";
|
|
217
|
-
MatchTeamType2[MatchTeamType2["TeamVs"] = 2] = "TeamVs";
|
|
218
|
-
MatchTeamType2[MatchTeamType2["TagTeamVs"] = 3] = "TagTeamVs";
|
|
219
|
-
return MatchTeamType2;
|
|
220
|
-
})(MatchTeamType || {});
|
|
221
|
-
var Team = /* @__PURE__ */ ((Team2) => {
|
|
222
|
-
Team2[Team2["None"] = 0] = "None";
|
|
223
|
-
Team2[Team2["Blue"] = 1] = "Blue";
|
|
224
|
-
Team2[Team2["Red"] = 2] = "Red";
|
|
225
|
-
return Team2;
|
|
226
|
-
})(Team || {});
|
|
227
|
-
|
|
228
|
-
// src/utils/URLBuilder.ts
|
|
229
|
-
var URLBuilder = class {
|
|
230
|
-
static gameModeToURLPattern(mode) {
|
|
231
|
-
switch (mode) {
|
|
232
|
-
case 0 /* Standard */:
|
|
233
|
-
return "osu";
|
|
234
|
-
case 1 /* Taiko */:
|
|
235
|
-
return "taiko";
|
|
236
|
-
case 2 /* Catch */:
|
|
237
|
-
return "fruits";
|
|
238
|
-
case 3 /* Mania */:
|
|
239
|
-
return "mania";
|
|
240
|
-
default:
|
|
241
|
-
throw new Error("INVALID_GAMEMODE");
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
static avatar(id) {
|
|
245
|
-
return `https://a.ppy.sh/${id}`;
|
|
246
|
-
}
|
|
247
|
-
static profile(idOrName) {
|
|
248
|
-
return `https://osu.ppy.sh/users/${idOrName}`;
|
|
249
|
-
}
|
|
250
|
-
static banner(userId, hash, ext) {
|
|
251
|
-
return `https://assets.ppy.sh/user-profile-covers/${userId}/${hash}.${ext}`;
|
|
252
|
-
}
|
|
253
|
-
static defaultBanner(id, ext) {
|
|
254
|
-
return `https://osu.ppy.sh/images/headers/profile-covers/c${id}.${ext}`;
|
|
255
|
-
}
|
|
256
|
-
static beatmapsetURL(beatmapsetId) {
|
|
257
|
-
return `https://osu.ppy.sh/beatmapsets/${beatmapsetId}`;
|
|
258
|
-
}
|
|
259
|
-
static beatmapURL(beatmapsetId, beatmapId, mode) {
|
|
260
|
-
const m = URLBuilder.gameModeToURLPattern(mode);
|
|
261
|
-
return `https://osu.ppy.sh/beatmapsets/${beatmapsetId}#${m}/${beatmapId}`;
|
|
262
|
-
}
|
|
263
|
-
static beatmapCoverImage(beatmapsetId) {
|
|
264
|
-
return `https://assets.ppy.sh/beatmaps/${beatmapsetId}/covers/cover.jpg`;
|
|
265
|
-
}
|
|
266
|
-
static beatmapCoverThumbnail(beatmapsetId) {
|
|
267
|
-
return `https://b.ppy.sh/thumb/${beatmapsetId}l.jpg`;
|
|
268
|
-
}
|
|
269
|
-
static scoreURL(mode, scoreId) {
|
|
270
|
-
const m = URLBuilder.gameModeToURLPattern(mode);
|
|
271
|
-
return `https://osu.ppy.sh/scores/${m}/${scoreId}`;
|
|
272
|
-
}
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
// src/structures/ModsBitField.ts
|
|
276
|
-
var _ModsBitField = class {
|
|
277
|
-
constructor(bits = 0n) {
|
|
278
|
-
this.bitfield = _ModsBitField.resolve(bits);
|
|
279
|
-
}
|
|
280
|
-
any(bit) {
|
|
281
|
-
return (this.bitfield & _ModsBitField.resolve(bit)) !== 0n;
|
|
282
|
-
}
|
|
283
|
-
equals(bit) {
|
|
284
|
-
return this.bitfield === _ModsBitField.resolve(bit);
|
|
285
|
-
}
|
|
286
|
-
has(bit) {
|
|
287
|
-
bit = _ModsBitField.resolve(bit);
|
|
288
|
-
return (this.bitfield & bit) === bit;
|
|
289
|
-
}
|
|
290
|
-
add(...bits) {
|
|
291
|
-
let total = 0n;
|
|
292
|
-
for (const bit of bits) {
|
|
293
|
-
total |= _ModsBitField.resolve(bit);
|
|
294
|
-
}
|
|
295
|
-
this.bitfield |= total;
|
|
296
|
-
return this;
|
|
297
|
-
}
|
|
298
|
-
remove(...bits) {
|
|
299
|
-
let total = 0n;
|
|
300
|
-
for (const bit of bits) {
|
|
301
|
-
total |= _ModsBitField.resolve(bit);
|
|
302
|
-
}
|
|
303
|
-
this.bitfield &= ~total;
|
|
304
|
-
return this;
|
|
305
|
-
}
|
|
306
|
-
toArray() {
|
|
307
|
-
return Object.keys(_ModsBitField.Flags).filter((bit) => this.has(bit));
|
|
308
|
-
}
|
|
309
|
-
serialize() {
|
|
310
|
-
const serialized = {};
|
|
311
|
-
for (const [flag, bit] of Object.entries(_ModsBitField.Flags)) {
|
|
312
|
-
serialized[flag] = this.has(bit);
|
|
313
|
-
}
|
|
314
|
-
return serialized;
|
|
315
|
-
}
|
|
316
|
-
isNone() {
|
|
317
|
-
return this.bitfield === 0n;
|
|
318
|
-
}
|
|
319
|
-
valueOf() {
|
|
320
|
-
return this.bitfield;
|
|
321
|
-
}
|
|
322
|
-
static resolve(bit) {
|
|
323
|
-
if (Array.isArray(bit)) {
|
|
324
|
-
return bit.map(_ModsBitField.resolve).reduce((acc, now) => acc | now, 0n);
|
|
325
|
-
}
|
|
326
|
-
if (bit instanceof _ModsBitField) {
|
|
327
|
-
return bit.bitfield;
|
|
328
|
-
}
|
|
329
|
-
if (typeof bit === "number")
|
|
330
|
-
return BigInt(bit);
|
|
331
|
-
if (typeof bit === "string") {
|
|
332
|
-
if (!isNaN(+bit))
|
|
333
|
-
return BigInt(bit);
|
|
334
|
-
const a = _ModsBitField.Flags[bit];
|
|
335
|
-
if (typeof a === "undefined")
|
|
336
|
-
throw new Error("INVALID_BITFIELD");
|
|
337
|
-
return a;
|
|
338
|
-
}
|
|
339
|
-
return bit;
|
|
340
|
-
}
|
|
341
|
-
};
|
|
342
|
-
var ModsBitField = _ModsBitField;
|
|
343
|
-
ModsBitField.Flags = Mods;
|
|
344
|
-
ModsBitField.KeyMod = Mods.Key1 | Mods.Key2 | Mods.Key3 | Mods.Key4 | Mods.Key5 | Mods.Key6 | Mods.Key7 | Mods.Key8 | Mods.Key9 | Mods.KeyCoop;
|
|
345
|
-
ModsBitField.FreeModAllowed = Mods.NoFail | Mods.Easy | Mods.Hidden | Mods.HardRock | Mods.SuddenDeath | Mods.Flashlight | Mods.FadeIn | Mods.Relax | Mods.AutoPilot | Mods.SpunOut | _ModsBitField.KeyMod;
|
|
346
|
-
ModsBitField.ScoreIncreaseMods = Mods.Hidden | Mods.HardRock | Mods.DoubleTime | Mods.Flashlight | Mods.FadeIn;
|
|
347
|
-
|
|
348
|
-
// src/utils/AccuracyCalculator.ts
|
|
349
|
-
var AccuracyCalculator = class {
|
|
350
|
-
static standard(count300, count100, count50, countMiss) {
|
|
351
|
-
const max = count300 + count100 + count50 + countMiss;
|
|
352
|
-
if (!max)
|
|
353
|
-
return 0;
|
|
354
|
-
return (count300 * 300 + count100 * 100 + count50 * 50) / (max * 300);
|
|
355
|
-
}
|
|
356
|
-
static taiko(count300, count100, countMiss) {
|
|
357
|
-
const max = count300 + count100 + countMiss;
|
|
358
|
-
if (!max)
|
|
359
|
-
return 0;
|
|
360
|
-
return (count300 + count100 * 0.5) / max;
|
|
361
|
-
}
|
|
362
|
-
static catch(count300, count100, count50, countKatu, countMiss) {
|
|
363
|
-
const max = count300 + count100 + count50 + countKatu + countMiss;
|
|
364
|
-
if (!max)
|
|
365
|
-
return 0;
|
|
366
|
-
return (count300 + count100 + count50) / max;
|
|
367
|
-
}
|
|
368
|
-
static mania(count300, count100, count50, countKatu, countGeki, countMiss) {
|
|
369
|
-
const max = count300 + count100 + count50 + countKatu + countGeki + countMiss;
|
|
370
|
-
if (!max)
|
|
371
|
-
return 0;
|
|
372
|
-
return (300 * countGeki + 300 * count300 + 200 * countKatu + 100 * count100 + 50 * count50) / (max * 300);
|
|
373
|
-
}
|
|
374
|
-
static maniaV2(count300, count100, count50, countKatu, countGeki, countMiss) {
|
|
375
|
-
const max = count300 + count100 + count50 + countKatu + countGeki + countMiss;
|
|
376
|
-
if (!max)
|
|
377
|
-
return 0;
|
|
378
|
-
return (305 * countGeki + 300 * count300 + 200 * countKatu + 100 * count100 + 50 * count50) / (max * 305);
|
|
379
|
-
}
|
|
380
|
-
static calculate(score, v2 = false) {
|
|
381
|
-
const { statistics } = score;
|
|
382
|
-
switch (score.mode) {
|
|
383
|
-
case 0 /* Standard */:
|
|
384
|
-
return AccuracyCalculator.standard(
|
|
385
|
-
statistics.count300,
|
|
386
|
-
statistics.count100,
|
|
387
|
-
statistics.count50,
|
|
388
|
-
statistics.countMiss
|
|
389
|
-
);
|
|
390
|
-
case 1 /* Taiko */:
|
|
391
|
-
return AccuracyCalculator.taiko(
|
|
392
|
-
statistics.count300,
|
|
393
|
-
statistics.count100,
|
|
394
|
-
statistics.countMiss
|
|
395
|
-
);
|
|
396
|
-
case 2 /* Catch */:
|
|
397
|
-
return AccuracyCalculator.catch(
|
|
398
|
-
statistics.count300,
|
|
399
|
-
statistics.count100,
|
|
400
|
-
statistics.count50,
|
|
401
|
-
statistics.countKatu,
|
|
402
|
-
statistics.countMiss
|
|
403
|
-
);
|
|
404
|
-
case 3 /* Mania */:
|
|
405
|
-
return v2 ? AccuracyCalculator.maniaV2(
|
|
406
|
-
statistics.count300,
|
|
407
|
-
statistics.count100,
|
|
408
|
-
statistics.count50,
|
|
409
|
-
statistics.countKatu,
|
|
410
|
-
statistics.countGeki,
|
|
411
|
-
statistics.countMiss
|
|
412
|
-
) : AccuracyCalculator.mania(
|
|
413
|
-
statistics.count300,
|
|
414
|
-
statistics.count100,
|
|
415
|
-
statistics.count50,
|
|
416
|
-
statistics.countKatu,
|
|
417
|
-
statistics.countGeki,
|
|
418
|
-
statistics.countMiss
|
|
419
|
-
);
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
};
|
|
423
|
-
|
|
424
|
-
// src/structures/BaseScore.ts
|
|
425
|
-
var BaseScore = class {
|
|
426
|
-
constructor(client, data, other) {
|
|
427
|
-
this.client = client;
|
|
428
|
-
this.score = +data.score;
|
|
429
|
-
this.maxCombo = +data.maxcombo;
|
|
430
|
-
this.statistics = {
|
|
431
|
-
count50: +data.count50,
|
|
432
|
-
count100: +data.count100,
|
|
433
|
-
count300: +data.count300,
|
|
434
|
-
countMiss: +data.countmiss,
|
|
435
|
-
countKatu: +data.countkatu,
|
|
436
|
-
countGeki: +data.countgeki
|
|
437
|
-
};
|
|
438
|
-
this.perfect = !!+data.perfect;
|
|
439
|
-
this.enabledMods = new ModsBitField(data.enabled_mods);
|
|
440
|
-
this.userId = data.user_id;
|
|
441
|
-
this.rank = ScoreRank[data.rank];
|
|
442
|
-
this.mode = other.mode ?? 0 /* Standard */;
|
|
443
|
-
if ("beatmap_id" in data) {
|
|
444
|
-
this.beatmapId = data.beatmap_id;
|
|
445
|
-
} else {
|
|
446
|
-
this.beatmapId = other.mapId;
|
|
447
|
-
}
|
|
448
|
-
this.accuracy = AccuracyCalculator.calculate(this);
|
|
449
|
-
}
|
|
450
|
-
async getPlayer(options = {}) {
|
|
451
|
-
const candidates = await this.client.users.getUser({
|
|
452
|
-
user: this.userId,
|
|
453
|
-
type: "id" /* Id */,
|
|
454
|
-
...options
|
|
455
|
-
});
|
|
456
|
-
return candidates[0];
|
|
457
|
-
}
|
|
458
|
-
async getBeatmap() {
|
|
459
|
-
const candidates = await this.client.beatmaps.getBeatmaps({
|
|
460
|
-
beatmapId: this.beatmapId,
|
|
461
|
-
mode: this.mode
|
|
462
|
-
});
|
|
463
|
-
return candidates[0];
|
|
464
|
-
}
|
|
465
|
-
getReplay() {
|
|
466
|
-
return this.client.replays.getReplay({
|
|
467
|
-
beatmapId: this.beatmapId,
|
|
468
|
-
user: this.userId,
|
|
469
|
-
type: "id" /* Id */
|
|
470
|
-
});
|
|
471
|
-
}
|
|
472
|
-
};
|
|
473
|
-
|
|
474
|
-
// src/structures/BeatmapScore.ts
|
|
475
|
-
var BeatmapScore = class extends BaseScore {
|
|
476
|
-
constructor(client, data, other) {
|
|
477
|
-
super(client, data, other);
|
|
478
|
-
this.scoreId = null;
|
|
479
|
-
this.username = null;
|
|
480
|
-
this.pp = null;
|
|
481
|
-
this.replayAvailable = null;
|
|
482
|
-
this.date = new Date(data.date);
|
|
483
|
-
if ("score_id" in data) {
|
|
484
|
-
this.scoreId = data.score_id;
|
|
485
|
-
}
|
|
486
|
-
if ("username" in data) {
|
|
487
|
-
this.username = data.username;
|
|
488
|
-
}
|
|
489
|
-
if ("pp" in data) {
|
|
490
|
-
this.pp = +data.pp;
|
|
491
|
-
}
|
|
492
|
-
if ("replay_available" in data) {
|
|
493
|
-
this.replayAvailable = !!+data.replay_available;
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
scoreURL() {
|
|
497
|
-
if (!this.scoreId)
|
|
498
|
-
return null;
|
|
499
|
-
return URLBuilder.scoreURL(this.mode, this.scoreId);
|
|
500
|
-
}
|
|
501
|
-
};
|
|
502
|
-
|
|
503
|
-
// src/structures/UserEvent.ts
|
|
504
|
-
var UserEvent = class {
|
|
505
|
-
constructor(user, data) {
|
|
506
|
-
this.user = user;
|
|
507
|
-
this.displayHtml = data.display_html;
|
|
508
|
-
this.beatmapId = data.beatmap_id;
|
|
509
|
-
this.beatmapsetId = data.beatmapset_id;
|
|
510
|
-
this.date = new Date(data.date);
|
|
511
|
-
this.epicfactor = +data.epicfactor;
|
|
512
|
-
}
|
|
513
|
-
async getBeatmap() {
|
|
514
|
-
const candidates = await this.user.client.beatmaps.getBeatmaps({
|
|
515
|
-
beatmapId: this.beatmapId,
|
|
516
|
-
beatmapsetId: this.beatmapsetId
|
|
517
|
-
});
|
|
518
|
-
return candidates[0];
|
|
519
|
-
}
|
|
520
|
-
async getBeatmapset() {
|
|
521
|
-
const beatmap = await this.getBeatmap();
|
|
522
|
-
return beatmap?.getBeatmapset();
|
|
523
|
-
}
|
|
524
|
-
};
|
|
525
|
-
|
|
526
|
-
// src/structures/User.ts
|
|
527
|
-
var User = class {
|
|
528
|
-
constructor(client, data) {
|
|
529
|
-
this.client = client;
|
|
530
|
-
this.id = data.user_id;
|
|
531
|
-
this.username = data.username;
|
|
532
|
-
this.joinDate = new Date(data.join_date);
|
|
533
|
-
this.count300 = +data.count300;
|
|
534
|
-
this.count100 = +data.count100;
|
|
535
|
-
this.count50 = +data.count50;
|
|
536
|
-
this.playcount = +data.playcount;
|
|
537
|
-
this.playtime = +data.total_seconds_played;
|
|
538
|
-
this.rankedScore = +data.ranked_score;
|
|
539
|
-
this.totalScore = +data.total_score;
|
|
540
|
-
this.rank = +data.pp_rank;
|
|
541
|
-
this.level = +data.level;
|
|
542
|
-
this.pp = +data.pp_raw;
|
|
543
|
-
this.accuracy = +data.accuracy;
|
|
544
|
-
this.scoreRankCount = {
|
|
545
|
-
ss: +data.count_rank_ss,
|
|
546
|
-
ssh: +data.count_rank_ssh,
|
|
547
|
-
s: +data.count_rank_s,
|
|
548
|
-
sh: +data.count_rank_sh,
|
|
549
|
-
a: +data.count_rank_a
|
|
550
|
-
};
|
|
551
|
-
this.country = data.country;
|
|
552
|
-
this.countryRank = +data.pp_country_rank;
|
|
553
|
-
this.events = data.events.map((v) => new UserEvent(this, v));
|
|
554
|
-
this.banner = null;
|
|
555
|
-
}
|
|
556
|
-
avatarURL() {
|
|
557
|
-
return URLBuilder.avatar(this.id);
|
|
558
|
-
}
|
|
559
|
-
profileURL() {
|
|
560
|
-
return URLBuilder.profile(this.id);
|
|
561
|
-
}
|
|
562
|
-
async fetchBanner(force = false) {
|
|
563
|
-
if (!force && this.banner)
|
|
564
|
-
return this.banner;
|
|
565
|
-
const url = await this.client.users.fetchBanner({ id: this.id });
|
|
566
|
-
return this.banner = url;
|
|
567
|
-
}
|
|
568
|
-
getBest(options = {}) {
|
|
569
|
-
return this.client.users.getUserBest({
|
|
570
|
-
user: this.id,
|
|
571
|
-
type: "id" /* Id */,
|
|
572
|
-
...options
|
|
573
|
-
});
|
|
574
|
-
}
|
|
575
|
-
getRecent(options = {}) {
|
|
576
|
-
return this.client.users.getUserRecent({
|
|
577
|
-
user: this.id,
|
|
578
|
-
type: "id" /* Id */,
|
|
579
|
-
...options
|
|
580
|
-
});
|
|
581
|
-
}
|
|
582
|
-
};
|
|
583
|
-
|
|
584
|
-
// src/managers/BaseManager.ts
|
|
585
|
-
var BaseManager = class {
|
|
586
|
-
constructor(client) {
|
|
587
|
-
this.client = client;
|
|
588
|
-
}
|
|
589
|
-
};
|
|
590
|
-
|
|
591
|
-
// src/managers/UserManager.ts
|
|
592
|
-
var UserManager = class extends BaseManager {
|
|
593
|
-
async getUser(options) {
|
|
594
|
-
const queries = {
|
|
595
|
-
u: options.user,
|
|
596
|
-
m: options.gameMode,
|
|
597
|
-
type: options.type,
|
|
598
|
-
event_days: options.eventDays
|
|
599
|
-
};
|
|
600
|
-
const res = await this.client.request({
|
|
601
|
-
path: "get_user",
|
|
602
|
-
queries
|
|
603
|
-
});
|
|
604
|
-
return res.map((v) => new User(this.client, v));
|
|
605
|
-
}
|
|
606
|
-
async fetchBanner({ id }) {
|
|
607
|
-
const context = await import_superagent.default.get(`https://osu.ppy.sh/users/${id}`);
|
|
608
|
-
const banner_regex = new RegExp(`https:\\\\\\/\\\\\\/assets\\.ppy\\.sh\\\\\\/user-profile-covers\\\\\\/${id}\\\\\\/(?<hash>[0-9a-z]*?)\\.(?<ext>.*?)&`, "gm");
|
|
609
|
-
const banner = banner_regex.exec(context.text);
|
|
610
|
-
if (banner) {
|
|
611
|
-
const url2 = URLBuilder.banner(id, banner?.groups?.hash, banner?.groups?.ext);
|
|
612
|
-
return url2;
|
|
613
|
-
}
|
|
614
|
-
const default_banner_regex = new RegExp("https:\\\\\\/\\\\\\/osu\\.ppy\\.sh\\\\\\/images\\\\\\/headers\\\\\\/profile-covers\\\\\\/c(?<id>\\d)\\.(?<ext>.*?)&", "gm");
|
|
615
|
-
const defaultBanner = default_banner_regex.exec(context.text);
|
|
616
|
-
const url = URLBuilder.defaultBanner(defaultBanner?.groups?.id, defaultBanner?.groups?.ext);
|
|
617
|
-
return url;
|
|
618
|
-
}
|
|
619
|
-
async getUserBest(options) {
|
|
620
|
-
const queries = {
|
|
621
|
-
u: options.user,
|
|
622
|
-
m: options.mode,
|
|
623
|
-
type: options.type,
|
|
624
|
-
limit: options.limit
|
|
625
|
-
};
|
|
626
|
-
const res = await this.client.request({
|
|
627
|
-
path: "get_user_best",
|
|
628
|
-
queries
|
|
629
|
-
});
|
|
630
|
-
return res.map((v) => new BeatmapScore(this.client, v, { mode: options.mode }));
|
|
631
|
-
}
|
|
632
|
-
async getUserRecent(options) {
|
|
633
|
-
const queries = {
|
|
634
|
-
u: options.user,
|
|
635
|
-
m: options.mode,
|
|
636
|
-
type: options.type,
|
|
637
|
-
limit: options.limit
|
|
638
|
-
};
|
|
639
|
-
const res = await this.client.request({
|
|
640
|
-
path: "get_user_recent",
|
|
641
|
-
queries
|
|
642
|
-
});
|
|
643
|
-
return res.map((v) => new BeatmapScore(this.client, v, { mode: options.mode }));
|
|
644
|
-
}
|
|
645
|
-
};
|
|
646
|
-
|
|
647
|
-
// src/utils/toSqlDate.ts
|
|
648
|
-
function toSqlDate(date) {
|
|
649
|
-
return date.toISOString().slice(0, 19).replace("T", " ");
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
// src/structures/Beatmapset.ts
|
|
653
|
-
var Beatmapset = class {
|
|
654
|
-
constructor(client, data, maps) {
|
|
655
|
-
this.client = client;
|
|
656
|
-
this.beatmaps = maps;
|
|
657
|
-
this.id = data.beatmapsetId;
|
|
658
|
-
this.approvedState = data.approvedState;
|
|
659
|
-
this.length = data.totalLength;
|
|
660
|
-
this.submitDate = data.submitDate;
|
|
661
|
-
this.approvedDate = data.approvedDate;
|
|
662
|
-
this.lastUpdate = data.lastUpdate;
|
|
663
|
-
this.artist = data.artist;
|
|
664
|
-
this.title = data.title;
|
|
665
|
-
this.creator = data.creator;
|
|
666
|
-
this.creatorId = data.creatorId;
|
|
667
|
-
this.source = data.source;
|
|
668
|
-
this.tags = data.tags.slice();
|
|
669
|
-
this.genre = data.genre;
|
|
670
|
-
this.language = data.language;
|
|
671
|
-
this.favoriteCount = data.favoriteCount;
|
|
672
|
-
this.rating = data.rating;
|
|
673
|
-
this.downloadUnavailable = data.downloadUnavailable;
|
|
674
|
-
this.audioUnavailable = data.audioUnavailable;
|
|
675
|
-
}
|
|
676
|
-
beatmapsetURL() {
|
|
677
|
-
return URLBuilder.beatmapsetURL(this.id);
|
|
678
|
-
}
|
|
679
|
-
coverImageURL() {
|
|
680
|
-
return URLBuilder.beatmapCoverImage(this.id);
|
|
681
|
-
}
|
|
682
|
-
coverThumbnailURL() {
|
|
683
|
-
return URLBuilder.beatmapCoverThumbnail(this.id);
|
|
684
|
-
}
|
|
685
|
-
async getCreator() {
|
|
686
|
-
const candidates = await this.client.users.getUser({
|
|
687
|
-
user: this.creatorId,
|
|
688
|
-
type: "id" /* Id */
|
|
689
|
-
});
|
|
690
|
-
return candidates[0];
|
|
691
|
-
}
|
|
692
|
-
};
|
|
693
|
-
|
|
694
|
-
// src/structures/Beatmap.ts
|
|
695
|
-
var Beatmap = class {
|
|
696
|
-
constructor(client, data) {
|
|
697
|
-
this.client = client;
|
|
698
|
-
this.id = data.beatmap_id;
|
|
699
|
-
this.beatmapsetId = data.beatmapset_id;
|
|
700
|
-
this.approvedState = +data.approved;
|
|
701
|
-
this.totalLength = +data.total_length;
|
|
702
|
-
this.hitLength = +data.hit_length;
|
|
703
|
-
this.diffcultyName = data.version;
|
|
704
|
-
this.hash = data.file_md5;
|
|
705
|
-
this.difficulty = {
|
|
706
|
-
ApproachRate: +data.diff_approach,
|
|
707
|
-
CircleSize: +data.diff_size,
|
|
708
|
-
OverallDifficulty: +data.diff_overall,
|
|
709
|
-
HPDrainRate: +data.diff_drain,
|
|
710
|
-
aim: +(data.diff_aim ?? 0),
|
|
711
|
-
speed: +(data.diff_speed ?? 0),
|
|
712
|
-
rating: +(data.difficultyrating ?? 0)
|
|
713
|
-
};
|
|
714
|
-
this.mode = +data.mode;
|
|
715
|
-
this.objectCount = {
|
|
716
|
-
circle: +data.count_normal,
|
|
717
|
-
slider: +data.count_slider,
|
|
718
|
-
spinner: +data.count_spinner
|
|
719
|
-
};
|
|
720
|
-
this.submitDate = new Date(data.submit_date);
|
|
721
|
-
if (!data.approved_date) {
|
|
722
|
-
this.approvedDate = null;
|
|
723
|
-
} else {
|
|
724
|
-
this.approvedDate = new Date(data.approved_date);
|
|
725
|
-
}
|
|
726
|
-
this.lastUpdate = new Date(data.last_update);
|
|
727
|
-
this.artist = data.artist;
|
|
728
|
-
this.title = data.title;
|
|
729
|
-
this.creator = data.creator;
|
|
730
|
-
this.creatorId = data.creator_id;
|
|
731
|
-
this.bpm = +data.bpm;
|
|
732
|
-
this.source = data.source;
|
|
733
|
-
this.tags = data.tags.split(" ");
|
|
734
|
-
this.genre = +data.genre_id;
|
|
735
|
-
this.language = +data.language_id;
|
|
736
|
-
this.favoriteCount = +data.favourite_count;
|
|
737
|
-
this.rating = +data.rating;
|
|
738
|
-
this.downloadUnavailable = !!+data.download_unavailable;
|
|
739
|
-
this.audioUnavailable = !!+data.audio_unavailable;
|
|
740
|
-
this.playcount = +data.playcount;
|
|
741
|
-
this.passcount = +data.passcount;
|
|
742
|
-
if (data.max_combo) {
|
|
743
|
-
this.maxCombo = +data.max_combo;
|
|
744
|
-
} else {
|
|
745
|
-
this.maxCombo = null;
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
beatmapsetURL() {
|
|
749
|
-
return URLBuilder.beatmapsetURL(this.beatmapsetId);
|
|
750
|
-
}
|
|
751
|
-
beatmapURL() {
|
|
752
|
-
return URLBuilder.beatmapURL(this.beatmapsetId, this.id, this.mode);
|
|
753
|
-
}
|
|
754
|
-
coverImageURL() {
|
|
755
|
-
return URLBuilder.beatmapCoverImage(this.beatmapsetId);
|
|
756
|
-
}
|
|
757
|
-
coverThumbnailURL() {
|
|
758
|
-
return URLBuilder.beatmapCoverThumbnail(this.beatmapsetId);
|
|
759
|
-
}
|
|
760
|
-
async getCreator() {
|
|
761
|
-
const candidates = await this.client.users.getUser({
|
|
762
|
-
user: this.creatorId,
|
|
763
|
-
type: "id" /* Id */
|
|
764
|
-
});
|
|
765
|
-
return candidates[0];
|
|
766
|
-
}
|
|
767
|
-
async getBeatmapset() {
|
|
768
|
-
const set = await this.client.beatmaps.getBeatmaps({
|
|
769
|
-
beatmapsetId: this.beatmapsetId
|
|
770
|
-
});
|
|
771
|
-
return new Beatmapset(this.client, this, set);
|
|
772
|
-
}
|
|
773
|
-
};
|
|
774
|
-
|
|
775
|
-
// src/managers/BeatmapManager.ts
|
|
776
|
-
var BeatmapManager = class extends BaseManager {
|
|
777
|
-
async getBeatmaps(options = {}) {
|
|
778
|
-
const queries = {
|
|
779
|
-
since: options.since && toSqlDate(options.since),
|
|
780
|
-
s: options.beatmapsetId,
|
|
781
|
-
b: options.beatmapId,
|
|
782
|
-
u: options.user,
|
|
783
|
-
type: options.type,
|
|
784
|
-
m: options.mode,
|
|
785
|
-
a: options.showConverted,
|
|
786
|
-
h: options.hash,
|
|
787
|
-
limit: options.limit,
|
|
788
|
-
mods: ModsBitField.resolve(options.mods ?? 0)
|
|
789
|
-
};
|
|
790
|
-
const res = await this.client.request({
|
|
791
|
-
path: "get_beatmaps",
|
|
792
|
-
queries
|
|
793
|
-
});
|
|
794
|
-
return res.map((v) => new Beatmap(this.client, v));
|
|
795
|
-
}
|
|
796
|
-
};
|
|
797
|
-
|
|
798
|
-
// src/managers/ScoreManager.ts
|
|
799
|
-
var ScoreManager = class extends BaseManager {
|
|
800
|
-
async getScores(options) {
|
|
801
|
-
const mods = options.mods == void 0 ? void 0 : ModsBitField.resolve(options.mods);
|
|
802
|
-
const queries = {
|
|
803
|
-
b: options.beatmapId,
|
|
804
|
-
u: options.user,
|
|
805
|
-
m: options.mode,
|
|
806
|
-
mods,
|
|
807
|
-
type: options.type,
|
|
808
|
-
limit: options.limit
|
|
809
|
-
};
|
|
810
|
-
const res = await this.client.request({
|
|
811
|
-
path: "get_scores",
|
|
812
|
-
queries
|
|
813
|
-
});
|
|
814
|
-
return res.map((v) => new BeatmapScore(this.client, v, { mapId: options.beatmapId, mode: options.mode }));
|
|
815
|
-
}
|
|
816
|
-
};
|
|
817
|
-
|
|
818
|
-
// src/structures/Replay.ts
|
|
819
|
-
var import_node_buffer = require("buffer");
|
|
820
|
-
var Replay = class {
|
|
821
|
-
constructor(client, data) {
|
|
822
|
-
this.client = client;
|
|
823
|
-
this.content = data.content;
|
|
824
|
-
this.stream = import_node_buffer.Buffer.from(this.content, "base64");
|
|
825
|
-
}
|
|
826
|
-
};
|
|
827
|
-
|
|
828
|
-
// src/managers/ReplayManager.ts
|
|
829
|
-
var ReplayManager = class extends BaseManager {
|
|
830
|
-
async getReplay(options) {
|
|
831
|
-
if ((!options.beatmapId || !options.user) && !options.scoreId) {
|
|
832
|
-
throw new Error("You should provide either beatmapId and user or scordId to get replay");
|
|
833
|
-
}
|
|
834
|
-
const mods = options.mods == void 0 ? void 0 : ModsBitField.resolve(options.mods);
|
|
835
|
-
const queries = {
|
|
836
|
-
b: options.beatmapId,
|
|
837
|
-
u: options.user,
|
|
838
|
-
m: options.mode,
|
|
839
|
-
s: options.scoreId,
|
|
840
|
-
type: options.type,
|
|
841
|
-
mods
|
|
842
|
-
};
|
|
843
|
-
const res = await this.client.request({
|
|
844
|
-
path: "get_replay",
|
|
845
|
-
queries
|
|
846
|
-
});
|
|
847
|
-
return new Replay(this.client, res);
|
|
848
|
-
}
|
|
849
|
-
};
|
|
850
|
-
|
|
851
|
-
// src/structures/MatchScore.ts
|
|
852
|
-
var MatchScore = class extends BaseScore {
|
|
853
|
-
constructor(client, data, other) {
|
|
854
|
-
super(client, data, other);
|
|
855
|
-
this.slot = +data.slot;
|
|
856
|
-
this.team = +data.team;
|
|
857
|
-
this.pass = !!+data.pass;
|
|
858
|
-
}
|
|
859
|
-
};
|
|
860
|
-
|
|
861
|
-
// src/structures/MatchGame.ts
|
|
862
|
-
var MatchGame = class {
|
|
863
|
-
constructor(match, data) {
|
|
864
|
-
this.client = match.client;
|
|
865
|
-
this.match = match;
|
|
866
|
-
this.id = data.game_id;
|
|
867
|
-
this.startAt = new Date(data.start_time);
|
|
868
|
-
this.endAt = new Date(data.end_time);
|
|
869
|
-
this.beatmapId = data.beatmap_id;
|
|
870
|
-
this.mode = +data.play_mode;
|
|
871
|
-
this.matchType = +data.match_type;
|
|
872
|
-
this.scoringType = +data.scoring_type;
|
|
873
|
-
this.teamType = +data.team_type;
|
|
874
|
-
this.mods = new ModsBitField(data.mods);
|
|
875
|
-
this.scores = data.scores.map((score) => new MatchScore(this.client, score, {
|
|
876
|
-
mode: +data.play_mode,
|
|
877
|
-
mapId: data.beatmap_id
|
|
878
|
-
}));
|
|
879
|
-
}
|
|
880
|
-
async getBeatmap() {
|
|
881
|
-
const candidates = await this.client.beatmaps.getBeatmaps({
|
|
882
|
-
beatmapId: this.beatmapId
|
|
883
|
-
});
|
|
884
|
-
return candidates[0];
|
|
885
|
-
}
|
|
886
|
-
};
|
|
887
|
-
|
|
888
|
-
// src/structures/Match.ts
|
|
889
|
-
var Match = class {
|
|
890
|
-
constructor(client, data) {
|
|
891
|
-
this.client = client;
|
|
892
|
-
const { match, games } = data;
|
|
893
|
-
this.id = match.match_id;
|
|
894
|
-
this.name = match.name;
|
|
895
|
-
this.startAt = new Date(match.start_time);
|
|
896
|
-
if (match.end_time) {
|
|
897
|
-
this.endAt = new Date(match.end_time);
|
|
898
|
-
} else {
|
|
899
|
-
this.endAt = null;
|
|
900
|
-
}
|
|
901
|
-
this.games = games.map((data2) => new MatchGame(this, data2));
|
|
902
|
-
}
|
|
903
|
-
};
|
|
904
|
-
|
|
905
|
-
// src/managers/MatchManager.ts
|
|
906
|
-
var MatchManager = class extends BaseManager {
|
|
907
|
-
async getMatch(options) {
|
|
908
|
-
const queries = {
|
|
909
|
-
mp: options.matchId
|
|
910
|
-
};
|
|
911
|
-
const res = await this.client.request({
|
|
912
|
-
path: "get_match",
|
|
913
|
-
queries
|
|
914
|
-
});
|
|
915
|
-
if (res.match === 0) {
|
|
916
|
-
return null;
|
|
917
|
-
}
|
|
918
|
-
return new Match(this.client, res);
|
|
919
|
-
}
|
|
920
|
-
};
|
|
921
|
-
|
|
922
|
-
// src/Client.ts
|
|
923
|
-
var Client = class {
|
|
924
|
-
constructor(options) {
|
|
925
|
-
this.apiKey = options.apiKey;
|
|
926
|
-
this.users = new UserManager(this);
|
|
927
|
-
this.beatmaps = new BeatmapManager(this);
|
|
928
|
-
this.scores = new ScoreManager(this);
|
|
929
|
-
this.replays = new ReplayManager(this);
|
|
930
|
-
this.matches = new MatchManager(this);
|
|
931
|
-
}
|
|
932
|
-
async request(options) {
|
|
933
|
-
if (!options?.path)
|
|
934
|
-
throw new Error("MISSING_PATH");
|
|
935
|
-
const response = await import_superagent2.default.get(`https://osu.ppy.sh/api/${options.path}`).query({ k: this.apiKey }).query(options.queries);
|
|
936
|
-
return response.body;
|
|
937
|
-
}
|
|
938
|
-
};
|
|
939
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
940
|
-
0 && (module.exports = {
|
|
941
|
-
AccuracyCalculator,
|
|
942
|
-
BaseManager,
|
|
943
|
-
BaseScore,
|
|
944
|
-
Beatmap,
|
|
945
|
-
BeatmapApprovedState,
|
|
946
|
-
BeatmapGenre,
|
|
947
|
-
BeatmapLanguage,
|
|
948
|
-
BeatmapManager,
|
|
949
|
-
BeatmapScore,
|
|
950
|
-
Beatmapset,
|
|
951
|
-
Client,
|
|
952
|
-
GameMode,
|
|
953
|
-
Match,
|
|
954
|
-
MatchGame,
|
|
955
|
-
MatchManager,
|
|
956
|
-
MatchScore,
|
|
957
|
-
MatchScoringType,
|
|
958
|
-
MatchTeamType,
|
|
959
|
-
Mods,
|
|
960
|
-
ModsAbbreviation,
|
|
961
|
-
ModsBitField,
|
|
962
|
-
Replay,
|
|
963
|
-
ReplayManager,
|
|
964
|
-
ScoreManager,
|
|
965
|
-
ScoreRank,
|
|
966
|
-
Team,
|
|
967
|
-
URLBuilder,
|
|
968
|
-
User,
|
|
969
|
-
UserEvent,
|
|
970
|
-
UserManager,
|
|
971
|
-
UserRequestType
|
|
972
|
-
});
|
|
973
|
-
//# sourceMappingURL=index.js.map
|