@@ -2,100 +2,75 @@ import { generic } from "../../decorators/eacnet.js";
22import { Context } from "../../types.js" ;
33import { Serializable , v } from "../../utils/kxml-value.js" ;
44import * as data from '../../datas/sdvx.js' ;
5+ import { requestEa3 } from "../../utils/ea3.js" ;
6+ import { SDVX_AC_MODEL } from "./index.js" ;
7+ import { tokenToCardNumber } from '../../utils/laochan-id.js' ;
8+ import { cache } from '../../decorators/cache.js' ;
59
610export class AcRelay {
711 @generic ( )
8- async sv6_play_e ( ) : Promise < Serializable > {
12+ async acRelayCommon ( ctx : Context ) : Promise < Serializable > {
13+ const { status, response } = await requestEa3 ( ctx . acRelayInfo , SDVX_AC_MODEL , ctx . token ) ;
14+
915 return {
1016 status : v . s32 ( 0 ) ,
1117 error_code : v . s32 ( 0 ) ,
12- xrpc_status_code : v . s32 ( 0 ) ,
13- xrpc_fault_code : v . s32 ( 0 ) ,
14- response : {
15- game : {
16- $status : 0 ,
17- } ,
18- }
18+ xrpc_status_code : v . s32 ( status ) ,
19+ xrpc_fault_code : v . s32 ( status ) ,
20+ response,
1921 } ;
2022 }
2123
22- @generic ( )
23- async sv6_play_s ( ) : Promise < Serializable > {
24- return {
25- status : v . s32 ( 0 ) ,
26- error_code : v . s32 ( 0 ) ,
27- xrpc_status_code : v . s32 ( 0 ) ,
28- xrpc_fault_code : v . s32 ( 0 ) ,
29- response : {
30- game : {
31- $status : 0 ,
32- play_id : v . u32 ( Math . floor ( new Date ( ) . valueOf ( ) / 6e4 ) ) ,
33- } ,
34- }
35- } ;
24+ async sv6_play_e ( ctx : Context ) : Promise < Serializable > {
25+ return this . acRelayCommon ( ctx ) ;
3626 }
3727
38- @generic ( )
39- async sv6_hiscore ( ) {
40- return {
41- status : v . s32 ( 0 ) ,
42- error_code : v . s32 ( 0 ) ,
43- xrpc_status_code : v . s32 ( 0 ) ,
44- xrpc_fault_code : v . s32 ( 0 ) ,
45- response : {
46- game : {
47- $status : 0 ,
48- sc : { } ,
49- }
50- }
51- } ;
28+ async sv6_play_s ( ctx : Context ) : Promise < Serializable > {
29+ return this . acRelayCommon ( ctx ) ;
5230 }
5331
54- @generic ( )
55- async sv6_log ( ) : Promise < Serializable > {
56- return {
57- status : v . s32 ( 0 ) ,
58- error_code : v . s32 ( 0 ) ,
59- xrpc_status_code : v . s32 ( 0 ) ,
60- xrpc_fault_code : v . s32 ( 0 ) ,
61- response : {
62- game : {
63- $status : 0 ,
64- }
65- }
66- } ;
32+ async sv6_hiscore ( ctx : Context ) {
33+ return this . acRelayCommon ( ctx ) ;
6734 }
6835
69- @generic ( )
70- async sv6_common ( ) : Promise < Serializable > {
71- return {
72- status : v . s32 ( 0 ) ,
73- error_code : v . s32 ( 0 ) ,
74- xrpc_status_code : v . s32 ( 0 ) ,
75- xrpc_fault_code : v . s32 ( 0 ) ,
76- response : {
77- game : {
78- $status : 0 ,
79- music : { } ,
80- event : {
81- info : data . eventList . map ( id => ( {
82- event_id : v . str ( id ) ,
83- } ) )
84- } ,
85- extend : {
86- info : data . extendInfos ,
87- } ,
88- music_limited : {
89- info : data . musicInfos ,
90- } ,
91- skill_course : {
92- info : data . skillCourses ,
93- } ,
94- appealcard : { } ,
95- valgene : { } ,
96- }
97- }
98- }
36+ async sv6_log ( ctx : Context ) : Promise < Serializable > {
37+ return this . acRelayCommon ( ctx ) ;
38+ }
39+
40+ @cache ( 'sv6_common' )
41+ async sv6_common ( ctx : Context ) : Promise < Serializable > {
42+ return this . acRelayCommon ( ctx ) ;
43+ }
44+
45+ async sv6_save_m ( ctx : Context ) : Promise < Serializable > {
46+ return this . acRelayCommon ( ctx ) ;
47+ }
48+
49+ async sv6_load_r ( ctx : Context ) : Promise < Serializable > {
50+ return this . acRelayCommon ( ctx ) ;
51+ }
52+
53+ async sv6_load_m ( ctx : Context ) : Promise < Serializable > {
54+ return this . acRelayCommon ( ctx ) ;
55+ }
56+
57+ async sv6_save_c ( ctx : Context ) : Promise < Serializable > {
58+ return this . acRelayCommon ( ctx ) ;
59+ }
60+
61+ async sv6_save ( ctx : Context ) : Promise < Serializable > {
62+ return this . acRelayCommon ( ctx ) ;
63+ }
64+
65+ async sv6_new ( ctx : Context ) : Promise < Serializable > {
66+ return this . acRelayCommon ( ctx ) ;
67+ }
68+
69+ async sv6_load ( ctx : Context ) : Promise < Serializable > {
70+ // hack for maomani
71+ // chou xiang amao
72+ ctx . acRelayInfo . request [ 'cardid' ] = v . str ( tokenToCardNumber ( ctx . token ) ) ;
73+ return this . acRelayCommon ( ctx ) ;
9974 }
10075
10176 @generic ( )
0 commit comments