rhythia-api 155.0.0 → 157.0.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/api/getTimestamp.ts +23 -0
- package/api/submitScore.ts +11 -1
- package/index.ts +14 -0
- package/package.json +1 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { NextResponse } from "next/server";
|
|
2
|
+
import z from "zod";
|
|
3
|
+
import { protectedApi } from "../utils/requestUtils";
|
|
4
|
+
|
|
5
|
+
export const Schema = {
|
|
6
|
+
input: z.strictObject({}),
|
|
7
|
+
output: z.object({
|
|
8
|
+
time: z.number(),
|
|
9
|
+
}),
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export async function POST(request: Request) {
|
|
13
|
+
return protectedApi({
|
|
14
|
+
request,
|
|
15
|
+
schema: Schema,
|
|
16
|
+
authorization: () => {},
|
|
17
|
+
activity: handler,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export async function handler(data: (typeof Schema)["input"]["_type"]) {
|
|
22
|
+
return NextResponse.json({ time: Date.now() });
|
|
23
|
+
}
|
package/api/submitScore.ts
CHANGED
|
@@ -18,6 +18,7 @@ export const Schema = {
|
|
|
18
18
|
hits: z.number(),
|
|
19
19
|
mapHash: z.string(),
|
|
20
20
|
speed: z.number(),
|
|
21
|
+
mods: z.array(z.string()),
|
|
21
22
|
}),
|
|
22
23
|
}),
|
|
23
24
|
output: z.object({
|
|
@@ -155,9 +156,18 @@ export async function handler({
|
|
|
155
156
|
beatmaps.noteCount
|
|
156
157
|
);
|
|
157
158
|
|
|
159
|
+
let multiplierMod = 1;
|
|
160
|
+
if (data.mods.includes("mod_hardrock")) {
|
|
161
|
+
multiplierMod *= 1.075;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (data.mods.includes("mod_nofail")) {
|
|
165
|
+
multiplierMod *= 0.5;
|
|
166
|
+
}
|
|
167
|
+
|
|
158
168
|
if (beatmaps.starRating) {
|
|
159
169
|
awarded_sp = calculatePerformancePoints(
|
|
160
|
-
data.speed * beatmaps.starRating,
|
|
170
|
+
data.speed * beatmaps.starRating * multiplierMod,
|
|
161
171
|
accurracy
|
|
162
172
|
);
|
|
163
173
|
}
|
package/index.ts
CHANGED
|
@@ -494,6 +494,19 @@ import { Schema as GetScore } from "./api/getScore"
|
|
|
494
494
|
export { Schema as SchemaGetScore } from "./api/getScore"
|
|
495
495
|
export const getScore = handleApi({url:"/api/getScore",...GetScore})
|
|
496
496
|
|
|
497
|
+
// ./api/getTimestamp.ts API
|
|
498
|
+
|
|
499
|
+
/*
|
|
500
|
+
export const Schema = {
|
|
501
|
+
input: z.strictObject({}),
|
|
502
|
+
output: z.object({
|
|
503
|
+
time: z.number(),
|
|
504
|
+
}),
|
|
505
|
+
};*/
|
|
506
|
+
import { Schema as GetTimestamp } from "./api/getTimestamp"
|
|
507
|
+
export { Schema as SchemaGetTimestamp } from "./api/getTimestamp"
|
|
508
|
+
export const getTimestamp = handleApi({url:"/api/getTimestamp",...GetTimestamp})
|
|
509
|
+
|
|
497
510
|
// ./api/getUserScores.ts API
|
|
498
511
|
|
|
499
512
|
/*
|
|
@@ -651,6 +664,7 @@ export const Schema = {
|
|
|
651
664
|
hits: z.number(),
|
|
652
665
|
mapHash: z.string(),
|
|
653
666
|
speed: z.number(),
|
|
667
|
+
mods: z.array(z.string()),
|
|
654
668
|
}),
|
|
655
669
|
}),
|
|
656
670
|
output: z.object({
|