mirror of
https://github.com/laochan-eacnet/backend.git
synced 2026-10-03 20:17:58 +03:00
add kxml value helper
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { serviceKxml } from "../../decorators/to-kxml.js";
|
||||
import { Context } from "../../types.js";
|
||||
import { v } from "../../utils/kxml-value.js";
|
||||
|
||||
interface GetPCDataCall {
|
||||
ccode: string,
|
||||
@@ -35,14 +36,8 @@ export default class {
|
||||
cm_movie_info: {
|
||||
$type: 3,
|
||||
},
|
||||
monthly_mranking: {
|
||||
$__type: 'u16',
|
||||
__value: [],
|
||||
},
|
||||
total_mranking: {
|
||||
$__type: 'u16',
|
||||
__value: [],
|
||||
},
|
||||
monthly_mranking: v.u16([]),
|
||||
total_mranking: v.u16([]),
|
||||
hitchart: [{
|
||||
$kind: 0,
|
||||
$period: 0,
|
||||
@@ -62,98 +57,38 @@ export default class {
|
||||
pcdata: this.getPlayerPcData(cid),
|
||||
bind_eaappli: {},
|
||||
secret: {
|
||||
flg1: {
|
||||
$__type: 's64',
|
||||
__value: [-1, -1, 1048575],
|
||||
},
|
||||
flg2: {
|
||||
$__type: 's64',
|
||||
__value: [-1, -1, 0],
|
||||
},
|
||||
flg3: {
|
||||
$__type: 's64',
|
||||
__value: [-1, -1, 0],
|
||||
},
|
||||
flg4: {
|
||||
$__type: 's64',
|
||||
__value: [-1, -1, 0],
|
||||
},
|
||||
flg1: v.s64([-1, -1, 1048575]),
|
||||
flg2: v.s64([-1, -1, 0]),
|
||||
flg3: v.s64([-1, -1, 0]),
|
||||
flg4: v.s64([-1, -1, 0]),
|
||||
},
|
||||
favorite: {
|
||||
sp_mlist: {
|
||||
$__type: 'bin',
|
||||
__value: Buffer.alloc(1, 0),
|
||||
},
|
||||
sp_clist: {
|
||||
$__type: 'bin',
|
||||
__value: Buffer.alloc(1, 0),
|
||||
},
|
||||
dp_mlist: {
|
||||
$__type: 'bin',
|
||||
__value: Buffer.alloc(1, 0),
|
||||
},
|
||||
dp_clist: {
|
||||
$__type: 'bin',
|
||||
__value: Buffer.alloc(1, 0),
|
||||
},
|
||||
sp_mlist: v.bin(Buffer.alloc(1, 0)),
|
||||
sp_clist: v.bin(Buffer.alloc(1, 0)),
|
||||
dp_mlist: v.bin(Buffer.alloc(1, 0)),
|
||||
dp_clist: v.bin(Buffer.alloc(1, 0)),
|
||||
},
|
||||
extra_favorite: [{
|
||||
$folder_id: 0,
|
||||
sp_mlist: {
|
||||
$__type: 'bin',
|
||||
__value: Buffer.alloc(1, 0),
|
||||
},
|
||||
sp_clist: {
|
||||
$__type: 'bin',
|
||||
__value: Buffer.alloc(1, 0),
|
||||
},
|
||||
dp_mlist: {
|
||||
$__type: 'bin',
|
||||
__value: Buffer.alloc(1, 0),
|
||||
},
|
||||
dp_clist: {
|
||||
$__type: 'bin',
|
||||
__value: Buffer.alloc(1, 0),
|
||||
},
|
||||
sp_mlist: v.bin(Buffer.alloc(1, 0)),
|
||||
sp_clist: v.bin(Buffer.alloc(1, 0)),
|
||||
dp_mlist: v.bin(Buffer.alloc(1, 0)),
|
||||
dp_clist: v.bin(Buffer.alloc(1, 0)),
|
||||
}, {
|
||||
$folder_id: 0,
|
||||
sp_mlist: {
|
||||
$__type: 'bin',
|
||||
__value: Buffer.alloc(1, 0),
|
||||
},
|
||||
sp_clist: {
|
||||
$__type: 'bin',
|
||||
__value: Buffer.alloc(1, 0),
|
||||
},
|
||||
dp_mlist: {
|
||||
$__type: 'bin',
|
||||
__value: Buffer.alloc(1, 0),
|
||||
},
|
||||
dp_clist: {
|
||||
$__type: 'bin',
|
||||
__value: Buffer.alloc(1, 0),
|
||||
},
|
||||
sp_mlist: v.bin(Buffer.alloc(1, 0)),
|
||||
sp_clist: v.bin(Buffer.alloc(1, 0)),
|
||||
dp_mlist: v.bin(Buffer.alloc(1, 0)),
|
||||
dp_clist: v.bin(Buffer.alloc(1, 0)),
|
||||
}],
|
||||
grade: {
|
||||
$dgid: -1,
|
||||
$sgid: -1,
|
||||
g: {
|
||||
$__type: 'u8',
|
||||
__value: [0, 13, 3, 58],
|
||||
}
|
||||
},
|
||||
skin: {
|
||||
$__type: 's16',
|
||||
__value: new Array(20).fill(0),
|
||||
},
|
||||
tdjskin: {
|
||||
$__type: 's16',
|
||||
__value: [0, 0, 0, 0],
|
||||
},
|
||||
qprodata: {
|
||||
$__type: 'u32',
|
||||
__value: [0, 0, 0, 0, 0],
|
||||
g: v.u8([0, 13, 3, 58]),
|
||||
},
|
||||
skin: v.s16(new Array(20).fill(0)),
|
||||
tdjskin: v.s16([0, 0, 0, 0]),
|
||||
qprodata: v.s16([0, 0, 0, 0, 0]),
|
||||
spdp_rival: {
|
||||
$flg: 1,
|
||||
},
|
||||
|
||||
@@ -11,6 +11,11 @@ interface CardAuth {
|
||||
refid: string,
|
||||
}
|
||||
|
||||
interface GetRefId {
|
||||
cardid: string,
|
||||
passwd: string;
|
||||
}
|
||||
|
||||
const resp = serviceKxml('cardmng');
|
||||
|
||||
export default class {
|
||||
@@ -25,9 +30,13 @@ export default class {
|
||||
}
|
||||
|
||||
@resp('getrefid')
|
||||
getrefid() {
|
||||
return {
|
||||
getrefid(ctx: Context) {
|
||||
const { cardid, passwd } = ctx.body as GetRefId;
|
||||
ctx.logger.info('registering %s with passwd %s.', cardid, passwd);
|
||||
|
||||
return {
|
||||
$dataid: cardid,
|
||||
$refid: cardid,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import { serviceKxml } from "../../decorators/to-kxml.js";
|
||||
import { v } from "../../utils/kxml-value.js";
|
||||
|
||||
const resp = serviceKxml('eacoin');
|
||||
|
||||
export default class {
|
||||
@resp('checkin')
|
||||
checkin() {
|
||||
return {
|
||||
$status: 0,
|
||||
balance: v.s32(114514),
|
||||
sessid: v.str('0000000000000000'),
|
||||
acstatus: v.u8(0),
|
||||
sequence: v.s16(1),
|
||||
acid: v.str('0000000000000000'),
|
||||
acname: v.str('0000000000000000'),
|
||||
}
|
||||
}
|
||||
|
||||
@resp('consume')
|
||||
consume() {
|
||||
return {
|
||||
$status: 0,
|
||||
autocharge: v.u8(0),
|
||||
acstatus: v.u8(0),
|
||||
balance: v.u8(114514),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
export type ValueTypes = 's8' |
|
||||
'u8' |
|
||||
's16' |
|
||||
'u16' |
|
||||
's32' |
|
||||
'u32' |
|
||||
's64' |
|
||||
'u64' |
|
||||
'float' |
|
||||
'double' |
|
||||
'b' | 'bool' |
|
||||
'bin' | 'binary' |
|
||||
'ip4' |
|
||||
'str' | 'string' |
|
||||
'time';
|
||||
|
||||
function vg(type: ValueTypes) {
|
||||
return (value: unknown) => ({
|
||||
$__type: type,
|
||||
__value: value,
|
||||
});
|
||||
}
|
||||
|
||||
export const v: Record<ValueTypes, (value: unknown) => object> = {
|
||||
s8: vg('s8'),
|
||||
u8: vg('u8'),
|
||||
s16: vg('s16'),
|
||||
u16: vg('u16'),
|
||||
s32: vg('s32'),
|
||||
u32: vg('u32'),
|
||||
s64: vg('s64'),
|
||||
u64: vg('u64'),
|
||||
float: vg('float'),
|
||||
double: vg('double'),
|
||||
b: vg('b'),
|
||||
bool: vg('bool'),
|
||||
bin: vg('bin'),
|
||||
binary: vg('binary'),
|
||||
ip4: vg('ip4'),
|
||||
str: vg('str'),
|
||||
string: vg('string'),
|
||||
time: vg('time'),
|
||||
}
|
||||
Reference in New Issue
Block a user