@rian8337/osu-droid-utilities 4.0.0-beta.103 → 4.0.0-beta.104

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.js DELETED
@@ -1,237 +0,0 @@
1
- 'use strict';
2
-
3
- var osuBase = require('@rian8337/osu-base');
4
-
5
- /******************************************************************************
6
- Copyright (c) Microsoft Corporation.
7
-
8
- Permission to use, copy, modify, and/or distribute this software for any
9
- purpose with or without fee is hereby granted.
10
-
11
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
- PERFORMANCE OF THIS SOFTWARE.
18
- ***************************************************************************** */
19
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
20
-
21
-
22
- function __awaiter(thisArg, _arguments, P, generator) {
23
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
24
- return new (P || (P = Promise))(function (resolve, reject) {
25
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
26
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
27
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
28
- step((generator = generator.apply(thisArg, _arguments || [])).next());
29
- });
30
- }
31
-
32
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
33
- var e = new Error(message);
34
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
35
- };
36
-
37
- /**
38
- * Represents an osu!droid score.
39
- */
40
- class Score {
41
- /**
42
- * The amount of 300s in the play.
43
- */
44
- get perfect() {
45
- return this.accuracy.n300;
46
- }
47
- /**
48
- * The amount of 100s in the play.
49
- */
50
- get good() {
51
- return this.accuracy.n100;
52
- }
53
- /**
54
- * The amount of 50s in the play.
55
- */
56
- get bad() {
57
- return this.accuracy.n50;
58
- }
59
- /**
60
- * The amount of misses in the play.
61
- */
62
- get miss() {
63
- return this.accuracy.nmiss;
64
- }
65
- /**
66
- * The complete mod string of this score.
67
- */
68
- get completeModString() {
69
- if (this.mods.isEmpty) {
70
- return `+No Mod`;
71
- }
72
- return `+${osuBase.ModUtil.modsToOrderedString(this.mods)}`;
73
- }
74
- constructor(apiScore) {
75
- this.id = apiScore.id;
76
- this.uid = apiScore.uid;
77
- this.username = apiScore.username;
78
- this.title = apiScore.filename;
79
- this.combo = apiScore.combo;
80
- this.score = apiScore.score;
81
- this.rank = apiScore.mark;
82
- this.date = new Date(apiScore.date * 1000);
83
- this.mods = osuBase.ModUtil.deserializeMods(apiScore.mods);
84
- this.accuracy = new osuBase.Accuracy({
85
- n300: apiScore.perfect,
86
- n100: apiScore.good,
87
- n50: apiScore.bad,
88
- nmiss: apiScore.miss,
89
- });
90
- this.sliderHeadHits = apiScore.sliderHeadHit;
91
- this.sliderTickHits = apiScore.sliderTickHit;
92
- this.sliderRepeatHits = apiScore.sliderRepeatHit;
93
- this.sliderEndHits = apiScore.sliderEndHit;
94
- this.hash = apiScore.hash;
95
- this.pp = apiScore.pp;
96
- this.ppMultiplier = apiScore.ppMultiplier;
97
- }
98
- /**
99
- * Retrieves score information on a beatmap from a player.
100
- *
101
- * @param uid The uid of the player.
102
- * @param hash The MD5 hash of the beatmap.
103
- * @param fetchBestPP Whether to retrieve the score in terms of the best performance points rather than best score. Defaults to `false`.
104
- * @returns The score, `null` if the score is not found.
105
- */
106
- static getFromHash(uid_1, hash_1) {
107
- return __awaiter(this, arguments, void 0, function* (uid, hash, fetchBestPP = false) {
108
- const apiRequestBuilder = new osuBase.DroidAPIRequestBuilder()
109
- .setEndpoint("scoresearchv2.php")
110
- .addParameter("uid", uid)
111
- .addParameter("hash", hash);
112
- if (fetchBestPP) {
113
- apiRequestBuilder.addParameter("order", "pp");
114
- }
115
- const result = yield apiRequestBuilder.sendRequest();
116
- if (result.statusCode !== 200) {
117
- throw new Error(`Error retrieving score data: ${result.describeFailure()}`);
118
- }
119
- let response;
120
- try {
121
- response = JSON.parse(result.data.toString("utf-8"));
122
- }
123
- catch (_a) {
124
- return null;
125
- }
126
- if (response.length === 0) {
127
- return null;
128
- }
129
- return new Score(response[0]);
130
- });
131
- }
132
- /**
133
- * Returns a string representative of the class.
134
- */
135
- toString() {
136
- return `Player: ${this.username}, uid: ${this.uid.toString()}, title: ${this.title}, score: ${this.score.toString()}, combo: ${this.combo.toString()}, rank: ${this.rank}, acc: ${(this.accuracy.value * 100).toFixed(2)}%, date: ${this.date.toString()}, mods: ${osuBase.ModUtil.modsToOrderedString(this.mods)}, hash: ${this.hash}`;
137
- }
138
- }
139
-
140
- /**
141
- * Represents an osu!droid player.
142
- */
143
- class Player {
144
- /**
145
- * The avatar URL of the player.
146
- */
147
- get avatarUrl() {
148
- return `https://osudroid.moe/user/avatar?id=${this.id.toString()}`;
149
- }
150
- constructor(apiPlayer) {
151
- /**
152
- * The user ID of the player.
153
- */
154
- this.id = 0;
155
- /**
156
- * The username of the player.
157
- */
158
- this.username = "";
159
- /**
160
- * The location of the player based on ISO 3166-1 country codes. See {@link https://en.wikipedia.org/wiki/ISO_3166-1 this} Wikipedia page for more information.
161
- */
162
- this.location = "";
163
- /**
164
- * The overall rank of the player.
165
- */
166
- this.rank = 0;
167
- /**
168
- * The total score of the player.
169
- */
170
- this.score = 0;
171
- /**
172
- * The total performance points of the player.
173
- */
174
- this.pp = 0;
175
- /**
176
- * The overall accuracy of the player.
177
- */
178
- this.accuracy = 0;
179
- /**
180
- * The amount of times the player has played.
181
- */
182
- this.playCount = 0;
183
- /**
184
- * Recent plays of the player.
185
- */
186
- this.recentPlays = [];
187
- this.id = apiPlayer.id;
188
- this.username = apiPlayer.username;
189
- this.score = apiPlayer.score;
190
- this.playCount = apiPlayer.playcount;
191
- this.accuracy = apiPlayer.accuracy * 100;
192
- this.location = apiPlayer.region;
193
- this.rank = apiPlayer.rank;
194
- this.pp = apiPlayer.pp;
195
- for (const score of apiPlayer.recent) {
196
- this.recentPlays.push(new Score(Object.assign(Object.assign({}, score), { uid: this.id, username: this.username })));
197
- }
198
- }
199
- /**
200
- * Retrieves a player's info based on their username.
201
- *
202
- * @param uidOrUsername The uid or username of the player.
203
- * @returns The player, `null` if the player is not found.
204
- */
205
- static getInformation(uidOrUsername) {
206
- return __awaiter(this, void 0, void 0, function* () {
207
- const apiRequestBuilder = new osuBase.DroidAPIRequestBuilder()
208
- .setEndpoint("getuserinfo.php")
209
- .addParameter(typeof uidOrUsername === "number" ? "uid" : "username", uidOrUsername);
210
- const result = yield apiRequestBuilder.sendRequest();
211
- if (result.statusCode !== 200) {
212
- throw new Error(`Error retrieving player data: ${result.describeFailure()}`);
213
- }
214
- let response;
215
- try {
216
- response = JSON.parse(result.data.toString("utf-8"));
217
- }
218
- catch (_a) {
219
- return null;
220
- }
221
- if (!response.id) {
222
- return null;
223
- }
224
- return new Player(response);
225
- });
226
- }
227
- /**
228
- * Returns a string representative of the class.
229
- */
230
- toString() {
231
- return `Username: ${this.username}\nUID: ${this.id.toString()}\nRank: ${this.rank.toString()}\nScore: ${this.score.toString()}\nPlay count: ${this.playCount.toString()}`;
232
- }
233
- }
234
-
235
- exports.Player = Player;
236
- exports.Score = Score;
237
- //# sourceMappingURL=index.js.map
@@ -1,210 +0,0 @@
1
- import { ScoreRank, SerializedMod, Accuracy, ModMap } from '@rian8337/osu-base';
2
-
3
- interface APIScore {
4
- readonly id: number;
5
- readonly uid: number;
6
- readonly username: string;
7
- readonly filename: string;
8
- readonly score: number;
9
- readonly combo: number;
10
- readonly mark: ScoreRank;
11
- readonly mods: SerializedMod[];
12
- readonly accuracy: number;
13
- readonly perfect: number;
14
- readonly good: number;
15
- readonly bad: number;
16
- readonly miss: number;
17
- readonly sliderHeadHit: number | null;
18
- readonly sliderTickHit: number | null;
19
- readonly sliderRepeatHit: number | null;
20
- readonly sliderEndHit: number | null;
21
- readonly date: number;
22
- readonly hash: string;
23
- readonly pp: number | null;
24
- readonly ppMultiplier: number | null;
25
- }
26
-
27
- interface APIPlayer {
28
- readonly id: number;
29
- readonly username: string;
30
- readonly score: number;
31
- readonly playcount: number;
32
- readonly accuracy: number;
33
- readonly region: string;
34
- readonly rank: number;
35
- readonly pp: number;
36
- readonly recent: Omit<APIScore, "uid" | "username">[];
37
- }
38
-
39
- /**
40
- * Represents an osu!droid score.
41
- */
42
- declare class Score {
43
- /**
44
- * The ID of the score.
45
- */
46
- id: number;
47
- /**
48
- * The uid of the player.
49
- */
50
- uid: number;
51
- /**
52
- * The player's name.
53
- */
54
- username: string;
55
- /**
56
- * The title of the beatmap.
57
- */
58
- title: string;
59
- /**
60
- * The maximum combo achieved in the play.
61
- */
62
- combo: number;
63
- /**
64
- * The score achieved in the play.
65
- */
66
- score: number;
67
- /**
68
- * The rank achieved in the play.
69
- */
70
- rank: ScoreRank;
71
- /**
72
- * The date of which the play was set.
73
- */
74
- date: Date;
75
- /**
76
- * The accuracy achieved in the play.
77
- */
78
- accuracy: Accuracy;
79
- /**
80
- * The amount of 300s in the play.
81
- */
82
- get perfect(): number;
83
- /**
84
- * The amount of 100s in the play.
85
- */
86
- get good(): number;
87
- /**
88
- * The amount of 50s in the play.
89
- */
90
- get bad(): number;
91
- /**
92
- * The amount of misses in the play.
93
- */
94
- get miss(): number;
95
- /**
96
- * Enabled modifications in the score.
97
- */
98
- mods: ModMap;
99
- /**
100
- * MD5 hash of the play.
101
- */
102
- hash: string;
103
- /**
104
- * The amount of slider heads hit in the play.
105
- */
106
- sliderHeadHits: number | null;
107
- /**
108
- * The amount of slider ticks hit in the play.
109
- */
110
- sliderTickHits: number | null;
111
- /**
112
- * The amount of slider repeats hit in the play.
113
- */
114
- sliderRepeatHits: number | null;
115
- /**
116
- * The amount of slider ends hit in the play.
117
- */
118
- sliderEndHits: number | null;
119
- /**
120
- * The performance points value of the play.
121
- *
122
- * This is the final value, affected by {@link ppMultiplier}. To get the raw pp value, divide by said multiplier.
123
- */
124
- pp: number | null;
125
- /**
126
- * The pp multiplier of the play.
127
- *
128
- * This is applied directly to {@link pp} during calculation.
129
- */
130
- ppMultiplier: number | null;
131
- /**
132
- * The complete mod string of this score.
133
- */
134
- get completeModString(): string;
135
- constructor(apiScore: APIScore);
136
- /**
137
- * Retrieves score information on a beatmap from a player.
138
- *
139
- * @param uid The uid of the player.
140
- * @param hash The MD5 hash of the beatmap.
141
- * @param fetchBestPP Whether to retrieve the score in terms of the best performance points rather than best score. Defaults to `false`.
142
- * @returns The score, `null` if the score is not found.
143
- */
144
- static getFromHash(uid: number, hash: string, fetchBestPP?: boolean): Promise<Score | null>;
145
- /**
146
- * Returns a string representative of the class.
147
- */
148
- toString(): string;
149
- }
150
-
151
- /**
152
- * Represents an osu!droid player.
153
- */
154
- declare class Player {
155
- /**
156
- * The user ID of the player.
157
- */
158
- id: number;
159
- /**
160
- * The username of the player.
161
- */
162
- username: string;
163
- /**
164
- * The avatar URL of the player.
165
- */
166
- get avatarUrl(): string;
167
- /**
168
- * The location of the player based on ISO 3166-1 country codes. See {@link https://en.wikipedia.org/wiki/ISO_3166-1 this} Wikipedia page for more information.
169
- */
170
- location: string;
171
- /**
172
- * The overall rank of the player.
173
- */
174
- rank: number;
175
- /**
176
- * The total score of the player.
177
- */
178
- score: number;
179
- /**
180
- * The total performance points of the player.
181
- */
182
- pp: number;
183
- /**
184
- * The overall accuracy of the player.
185
- */
186
- accuracy: number;
187
- /**
188
- * The amount of times the player has played.
189
- */
190
- playCount: number;
191
- /**
192
- * Recent plays of the player.
193
- */
194
- readonly recentPlays: Score[];
195
- constructor(apiPlayer: APIPlayer);
196
- /**
197
- * Retrieves a player's info based on their username.
198
- *
199
- * @param uidOrUsername The uid or username of the player.
200
- * @returns The player, `null` if the player is not found.
201
- */
202
- static getInformation(uidOrUsername: string | number): Promise<Player | null>;
203
- /**
204
- * Returns a string representative of the class.
205
- */
206
- toString(): string;
207
- }
208
-
209
- export { Player, Score };
210
- export type { APIPlayer, APIScore };