mirror of
https://github.com/laochan-eacnet/backend.git
synced 2026-09-22 22:28:11 +03:00
fix sdvx crash beacuse updating hiscore
This commit is contained in:
@@ -4,6 +4,69 @@ import { Serializable, v } from "../../utils/kxml-value.js";
|
||||
import * as data from '../../datas/sdvx.js';
|
||||
|
||||
export class AcRelay {
|
||||
@sdvx()
|
||||
async sv6_hiscore() {
|
||||
return {
|
||||
status: v.s32(0),
|
||||
error_code: v.s32(0),
|
||||
xrpc_status_code: v.s32(0),
|
||||
xrpc_fault_code: v.s32(0),
|
||||
response: {
|
||||
game: {
|
||||
$status: 0,
|
||||
sc: {},
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@sdvx()
|
||||
async sv6_log(): Promise<Serializable> {
|
||||
return {
|
||||
status: v.s32(0),
|
||||
error_code: v.s32(0),
|
||||
xrpc_status_code: v.s32(0),
|
||||
xrpc_fault_code: v.s32(0),
|
||||
response: {
|
||||
game: {
|
||||
$status: 0,
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@sdvx()
|
||||
async sv6_common(): Promise<Serializable> {
|
||||
return {
|
||||
status: v.s32(0),
|
||||
error_code: v.s32(0),
|
||||
xrpc_status_code: v.s32(0),
|
||||
xrpc_fault_code: v.s32(0),
|
||||
response: {
|
||||
game: {
|
||||
$status: 0,
|
||||
music: {},
|
||||
event: {
|
||||
info: data.eventList.map(id => ({
|
||||
event_id: v.str(id),
|
||||
}))
|
||||
},
|
||||
extend: {
|
||||
info: data.extendInfos,
|
||||
},
|
||||
music_limited: {
|
||||
info: data.musicInfos,
|
||||
},
|
||||
skill_course: {
|
||||
info: data.skillCourses,
|
||||
},
|
||||
appealcard: {},
|
||||
valgene: {},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@sdvx()
|
||||
async sv6_music_url(ctx: Context): Promise<Serializable> {
|
||||
let { music_id } = ctx.body as { music_id: number | number[] };
|
||||
|
||||
@@ -6,9 +6,10 @@ import { AcRelay } from "./ac-relay.js";
|
||||
import { UserService } from "../../services/sdvx/user.js";
|
||||
import { inject, singleton } from "tsyringe";
|
||||
import { User } from "./user.js";
|
||||
import { Music } from "./music.js";
|
||||
|
||||
@singleton()
|
||||
export default class extends Combine(AcRelay, User) {
|
||||
export default class extends Combine(AcRelay, User, Music) {
|
||||
constructor(
|
||||
@inject(UserService) private readonly userService: UserService,
|
||||
) {
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import { sdvx } from "../../decorators/eacnet.js";
|
||||
import { UserService } from "../../services/sdvx/user.js";
|
||||
import { Serializable, v } from "../../utils/kxml-value.js";
|
||||
|
||||
export class Music {
|
||||
userService: UserService;
|
||||
|
||||
@sdvx()
|
||||
async sv6_load_r(): Promise<Serializable> {
|
||||
return {
|
||||
status: v.s32(0),
|
||||
error_code: v.s32(0),
|
||||
xrpc_status_code: v.s32(0),
|
||||
xrpc_fault_code: v.s32(0),
|
||||
response: {
|
||||
game: {
|
||||
$status: 0,
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@sdvx()
|
||||
async sv6_load_m(): Promise<Serializable> {
|
||||
return {
|
||||
status: v.s32(0),
|
||||
error_code: v.s32(0),
|
||||
xrpc_status_code: v.s32(0),
|
||||
xrpc_fault_code: v.s32(0),
|
||||
response: {
|
||||
game: {
|
||||
$status: 0,
|
||||
music: {
|
||||
info: []
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,22 @@ function tryAdd(kvalue: KValueG<ValueTypes, number>, value: number) {
|
||||
export class User {
|
||||
userService: UserService;
|
||||
|
||||
@sdvx()
|
||||
async sv6_play_s(): Promise<Serializable> {
|
||||
return {
|
||||
status: v.s32(0),
|
||||
error_code: v.s32(0),
|
||||
xrpc_status_code: v.s32(0),
|
||||
xrpc_fault_code: v.s32(0),
|
||||
response: {
|
||||
game: {
|
||||
$status: 0,
|
||||
play_id: v.u32(Math.floor(new Date().valueOf() / 6e4)),
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@sdvx()
|
||||
async sv6_save(ctx: Context): Promise<Serializable> {
|
||||
const playData = await this.userService.getPlayerData(ctx.token);
|
||||
@@ -144,8 +160,13 @@ export class User {
|
||||
}
|
||||
}
|
||||
|
||||
// update blaster pass date
|
||||
// blaster pass
|
||||
playData.ea_shop.blaster_pass_enable = v.bool(true);
|
||||
playData.ea_shop.blaster_pass_limit_date = v.u64(new Date().valueOf() + (30 * 60 * 60 * 1000));
|
||||
playData.item.info = [
|
||||
...(playData.item.info ?? []),
|
||||
...data.charaItems,
|
||||
];
|
||||
|
||||
return {
|
||||
status: v.s32(0),
|
||||
@@ -155,6 +176,7 @@ export class User {
|
||||
response: {
|
||||
game: {
|
||||
$status: 0,
|
||||
result: v.u8(0),
|
||||
...playData,
|
||||
}
|
||||
}
|
||||
|
||||
+2258
-2
File diff suppressed because it is too large
Load Diff
@@ -1,10 +1,9 @@
|
||||
import { Binary, Db, FindOptions } from "mongodb";
|
||||
import { inject, injectable } from "tsyringe";
|
||||
import { PlayerPlayData } from "../../types/sdvx/index.js";
|
||||
import { tokenToCardNumber, tokenToSdvxId } from "../../utils/laochan-id.js";
|
||||
import { tokenToCode, tokenToSdvxId } from "../../utils/laochan-id.js";
|
||||
import { v } from "../../utils/kxml-value.js";
|
||||
import { dateToString } from "../../utils/time.js";
|
||||
import * as data from '../../datas/sdvx.js'
|
||||
import { brotliCompress, brotliDecompress } from "zlib";
|
||||
import { promisify } from "util";
|
||||
import { SaveData } from "../../types/sdvx/savedata.js";
|
||||
@@ -47,8 +46,8 @@ export class UserService {
|
||||
}
|
||||
|
||||
async createEmptyPlayerData(token: string, name: string) {
|
||||
const save_data: SaveData = {
|
||||
code: v.str(tokenToCardNumber(token)),
|
||||
const save_data = {
|
||||
code: v.str(tokenToCode(token)),
|
||||
name: v.str(name),
|
||||
sdvx_id: v.str(tokenToSdvxId(token)),
|
||||
creator_id: v.u32(0),
|
||||
@@ -69,7 +68,7 @@ export class UserService {
|
||||
early_late_disp: v.u8(0),
|
||||
draw_adjust: v.s32(0),
|
||||
eff_c_left: v.u8(0),
|
||||
eff_c_right: v.u8(0),
|
||||
eff_c_right: v.u8(1),
|
||||
last_music_id: v.s32(0),
|
||||
last_music_type: v.u8(0),
|
||||
sort_type: v.u8(0),
|
||||
@@ -89,25 +88,19 @@ export class UserService {
|
||||
last_date: v.str(dateToString(new Date())),
|
||||
start_date: v.str(dateToString(new Date())),
|
||||
|
||||
item: {
|
||||
info: [
|
||||
...data.charaItems,
|
||||
]
|
||||
},
|
||||
item: {},
|
||||
item_cloud: {},
|
||||
item_infinite: {},
|
||||
skill: {},
|
||||
param: {},
|
||||
present: {},
|
||||
cloud: {
|
||||
relation: v.s8(1),
|
||||
relation: v.s8(0),
|
||||
},
|
||||
ea_shop: {
|
||||
blaster_pass_enable: v.bool(true),
|
||||
blaster_pass_limit_date: v.u64(0),
|
||||
shop_item: {},
|
||||
},
|
||||
};
|
||||
} as SaveData;
|
||||
|
||||
return this.savePlayerData(token, save_data, name);
|
||||
}
|
||||
|
||||
@@ -14,10 +14,16 @@ export type ValueTypes = 's8' |
|
||||
'str' | 'string' |
|
||||
'time';
|
||||
|
||||
type AttributeProperty<T> = {
|
||||
[K in keyof T as K extends string ? `$${K}` : never]: T[K]
|
||||
}
|
||||
|
||||
export type KValueG<T extends ValueTypes, VT = unknown> = {
|
||||
$__type: T;
|
||||
__value: VT | VT[];
|
||||
} & Record<string, unknown>;
|
||||
} & AttributeProperty<{
|
||||
[key: string]: string | number;
|
||||
}>;
|
||||
|
||||
export type KS8 = KValueG<'s8', number>;
|
||||
export type KU8 = KValueG<'u8', number>;
|
||||
@@ -36,12 +42,8 @@ export type KIPv4 = KValueG<'ip4', string>;
|
||||
export type KTime = KValueG<'time', Date | number>;
|
||||
export type KValue = KS8 | KU8 | KS16 | KU16 | KS32 | KS64 | KU64 | KFloat | KDouble | KBoolean | KBinary | KString | KIPv4 | KTime;
|
||||
|
||||
type AttributeProperty<T> = {
|
||||
[K in keyof T as K extends string ? `$${K}` : never]: T[K]
|
||||
}
|
||||
|
||||
export type Serializable = {
|
||||
[key: string]: KValue | Serializable
|
||||
[key: string]: KValue | Serializable | Serializable[]
|
||||
} | AttributeProperty<{
|
||||
[key: string]: string | number;
|
||||
}>;
|
||||
|
||||
@@ -21,6 +21,11 @@ export function tokenToCardNumber(token: string) {
|
||||
return ('LCHAN' + hash.toUpperCase()).slice(0, 16);
|
||||
}
|
||||
|
||||
export function tokenToCode(token: string) {
|
||||
const key = highwayHash.asUInt32Low(HIGHWAY_KEY, Buffer.from(token));
|
||||
return 'MOAI' + key.toString().padStart(9, '0').slice(0, 9);
|
||||
}
|
||||
|
||||
export function tokenToSnsId(token: string) {
|
||||
const key = highwayHash.asUInt32Low(HIGHWAY_KEY, Buffer.from(token));
|
||||
return key.toString().padStart(8, '0');
|
||||
|
||||
Reference in New Issue
Block a user