mirror of
https://github.com/asphyxia-core/plugins.git
synced 2026-04-25 16:21:44 -05:00
Fix compile error
This commit is contained in:
parent
81630a86a2
commit
09301ebada
|
|
@ -1,84 +1,101 @@
|
||||||
import Profile from "../models/profile";
|
import Profile from '../models/profile';
|
||||||
import { Score } from "../models/score";
|
import { Score } from '../models/score';
|
||||||
|
|
||||||
export const getProfile = async (info: EamuseInfo, data: any, send: EamuseSend) => {
|
export const getProfile = async (
|
||||||
console.log("gametop.regist");
|
info: EamuseInfo,
|
||||||
let refId = $(data).str("data.player.refid");
|
data: any,
|
||||||
const name = $(data).str("data.player.name");
|
send: EamuseSend
|
||||||
|
) => {
|
||||||
|
console.log('gametop.regist');
|
||||||
|
let refId = $(data).str('data.player.refid');
|
||||||
|
const name = $(data).str('data.player.name');
|
||||||
|
|
||||||
console.log(data, {depth:null});
|
console.log(data, { depth: null });
|
||||||
if (!refId) return send.deny();
|
if (!refId) return send.deny();
|
||||||
|
|
||||||
let profile = await DB.FindOne<Profile>(refId, { collection: "profile" });
|
let profile = await DB.FindOne<Profile>(refId, { collection: 'profile' });
|
||||||
|
|
||||||
if (!profile && name) {
|
|
||||||
const newProfile: Profile = {
|
|
||||||
collection: "profile",
|
|
||||||
jubeatId: Math.round(Math.random() * 99999999),
|
|
||||||
eventFlag: 0,
|
|
||||||
name: name,
|
|
||||||
isFirstplay: true,
|
|
||||||
emo: [],
|
|
||||||
lastShopname: "",
|
|
||||||
lastAreaname: ""
|
|
||||||
};
|
|
||||||
|
|
||||||
await DB.Upsert<Profile>(refId, { collection: "profile" }, newProfile);
|
|
||||||
|
|
||||||
profile = newProfile;
|
|
||||||
}else if (!profile && !name) {
|
|
||||||
return send.deny();
|
|
||||||
}
|
|
||||||
|
|
||||||
return send.object({
|
if (!profile && name) {
|
||||||
data: {
|
const newProfile: Profile = {
|
||||||
...require("../templates/gameInfos.ts")(),
|
collection: 'profile',
|
||||||
|
jubeatId: Math.round(Math.random() * 99999999),
|
||||||
|
eventFlag: 0,
|
||||||
|
name: name,
|
||||||
|
isFirstplay: true,
|
||||||
|
emo: [],
|
||||||
|
lastShopname: '',
|
||||||
|
lastAreaname: '',
|
||||||
|
};
|
||||||
|
|
||||||
player: {
|
await DB.Upsert<Profile>(refId, { collection: 'profile' }, newProfile);
|
||||||
|
|
||||||
jid: K.ITEM("s32", profile.jubeatId),
|
|
||||||
session_id: K.ITEM("s32", 1),
|
|
||||||
name: K.ITEM("str", profile.name),
|
|
||||||
event_flag: K.ITEM("u64", BigInt(profile.eventFlag || 0)),
|
|
||||||
|
|
||||||
...await require("../templates/profiles.ts")(profile),
|
profile = newProfile;
|
||||||
|
} else if (!profile && !name) {
|
||||||
|
return send.deny();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
return send.object(
|
||||||
}
|
{
|
||||||
}, {compress: true}
|
data: {
|
||||||
);
|
...require('../templates/gameInfos.ts')(),
|
||||||
|
|
||||||
|
player: {
|
||||||
|
jid: K.ITEM('s32', profile.jubeatId),
|
||||||
|
session_id: K.ITEM('s32', 1),
|
||||||
|
name: K.ITEM('str', profile.name),
|
||||||
|
event_flag: K.ITEM('u64', BigInt(profile.eventFlag || 0)),
|
||||||
|
|
||||||
|
...(await require('../templates/profiles.ts')(profile)),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ compress: true }
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Getinfo = (info: EamuseInfo, data: any, send: EamuseSend) =>{
|
export const Getinfo = (info: EamuseInfo, data: any, send: EamuseSend) => {
|
||||||
console.log(data, {depth:null});
|
console.log(data, { depth: null });
|
||||||
return send.object({ data: require("../templates/gameInfos")() }, { compress: true });
|
return send.object(
|
||||||
}
|
{ data: require('../templates/gameInfos')() },
|
||||||
|
{ compress: true }
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export const loadScore = async (info, data, send) => {
|
export const loadScore = async (info, data, send) => {
|
||||||
console.log("gametop.get_mdata");
|
console.log('gametop.get_mdata');
|
||||||
console.log(data,{depth:null});
|
console.log(data, { depth: null });
|
||||||
const mdata_ver = $(data).number("data.player.mdata_ver");
|
const mdata_ver = $(data).number('data.player.mdata_ver');
|
||||||
const jubeatId = $(data).number("data.player.jid");
|
const jubeatId = $(data).number('data.player.jid');
|
||||||
if (!jubeatId) return send.deny();
|
if (!jubeatId) return send.deny();
|
||||||
|
|
||||||
const profile = await DB.FindOne<Profile>(null, { collection: "profile", jubeatId });
|
const profile = await DB.FindOne<Profile>(null, {
|
||||||
|
collection: 'profile',
|
||||||
|
jubeatId,
|
||||||
|
});
|
||||||
if (!profile) return send.deny();
|
if (!profile) return send.deny();
|
||||||
|
|
||||||
const scores = await DB.Find<Score>(profile.__refid, { collection: "score" });
|
const scores = await DB.Find<Score>(profile.__refid, { collection: 'score' });
|
||||||
const scoreData: {
|
const scoreData: {
|
||||||
[musicId: number]: {
|
[musicId: number]: {
|
||||||
[isHardMode: number]: {
|
[isHardMode: number]: {
|
||||||
musicRate: number[], score: number[], clear: number[], playCnt: number[], clearCnt: number[], fcCnt: number[], exCnt: number[], bar: number[][]
|
musicRate: number[];
|
||||||
}
|
score: number[];
|
||||||
}
|
clear: number[];
|
||||||
|
playCnt: number[];
|
||||||
|
clearCnt: number[];
|
||||||
|
fcCnt: number[];
|
||||||
|
exCnt: number[];
|
||||||
|
bar: number[][];
|
||||||
|
};
|
||||||
|
};
|
||||||
} = {};
|
} = {};
|
||||||
|
|
||||||
for (const score of scores) {
|
for (const score of scores) {
|
||||||
if (!scoreData[score.musicId]) {
|
if (!scoreData[score.musicId]) {
|
||||||
scoreData[score.musicId] = {};
|
scoreData[score.musicId] = {};
|
||||||
}
|
}
|
||||||
if(!scoreData[score.musicId][score.isHardMode & 1]) {
|
if (!scoreData[score.musicId][score.isHardMode ? 1 : 0]) {
|
||||||
scoreData[score.musicId][score.isHardMode & 1] = {
|
scoreData[score.musicId][score.isHardMode ? 1 : 0] = {
|
||||||
musicRate: [0, 0, 0],
|
musicRate: [0, 0, 0],
|
||||||
playCnt: [0, 0, 0],
|
playCnt: [0, 0, 0],
|
||||||
clearCnt: [0, 0, 0],
|
clearCnt: [0, 0, 0],
|
||||||
|
|
@ -89,9 +106,8 @@ export const loadScore = async (info, data, send) => {
|
||||||
bar: [Array(30).fill(0), Array(30).fill(0), Array(30).fill(0)],
|
bar: [Array(30).fill(0), Array(30).fill(0), Array(30).fill(0)],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const data = scoreData[score.musicId][score.isHardMode & 1];
|
const data = scoreData[score.musicId][score.isHardMode ? 1 : 0];
|
||||||
data.musicRate[score.seq] = score.musicRate;
|
data.musicRate[score.seq] = score.musicRate;
|
||||||
data.playCnt[score.seq] = score.playCount;
|
data.playCnt[score.seq] = score.playCount;
|
||||||
data.clearCnt[score.seq] = score.clearCount;
|
data.clearCnt[score.seq] = score.clearCount;
|
||||||
|
|
@ -105,62 +121,91 @@ export const loadScore = async (info, data, send) => {
|
||||||
var sendobj = {
|
var sendobj = {
|
||||||
data: {
|
data: {
|
||||||
player: {
|
player: {
|
||||||
jid: K.ITEM("s32", jubeatId),
|
jid: K.ITEM('s32', jubeatId),
|
||||||
|
|
||||||
mdata_list: {
|
mdata_list: {
|
||||||
music: (() => {
|
music: (() => {
|
||||||
var musicArray = [];
|
var musicArray = [];
|
||||||
Object.keys(scoreData).forEach(musicId =>
|
Object.keys(scoreData).forEach(musicId =>
|
||||||
Object.keys(scoreData[musicId]).forEach(isHardMode => {
|
Object.keys(scoreData[musicId]).forEach(isHardMode => {
|
||||||
musicArray.push(
|
musicArray.push(
|
||||||
K.ATTR({ music_id: String(musicId) }, {
|
K.ATTR(
|
||||||
[isHardMode === "1" ? "hard" : "normal"]:
|
{ music_id: String(musicId) },
|
||||||
{
|
{
|
||||||
score: K.ARRAY("s32", scoreData[musicId][isHardMode].score),
|
[isHardMode === '1' ? 'hard' : 'normal']: {
|
||||||
clear: K.ARRAY("s8", scoreData[musicId][isHardMode].clear),
|
score: K.ARRAY(
|
||||||
music_rate: K.ARRAY("s32", scoreData[musicId][isHardMode].musicRate),
|
's32',
|
||||||
play_cnt: K.ARRAY("s32", scoreData[musicId][isHardMode].playCnt),
|
scoreData[musicId][isHardMode].score
|
||||||
clear_cnt: K.ARRAY("s32", scoreData[musicId][isHardMode].clearCnt),
|
),
|
||||||
fc_cnt: K.ARRAY("s32", scoreData[musicId][isHardMode].fcCnt),
|
clear: K.ARRAY(
|
||||||
ex_cnt: K.ARRAY("s32", scoreData[musicId][isHardMode].exCnt),
|
's8',
|
||||||
bar: scoreData[musicId][isHardMode].bar.map((bar, seq) => K.ARRAY("u8", bar, { seq: String(seq) }))
|
scoreData[musicId][isHardMode].clear
|
||||||
|
),
|
||||||
|
music_rate: K.ARRAY(
|
||||||
|
's32',
|
||||||
|
scoreData[musicId][isHardMode].musicRate
|
||||||
|
),
|
||||||
|
play_cnt: K.ARRAY(
|
||||||
|
's32',
|
||||||
|
scoreData[musicId][isHardMode].playCnt
|
||||||
|
),
|
||||||
|
clear_cnt: K.ARRAY(
|
||||||
|
's32',
|
||||||
|
scoreData[musicId][isHardMode].clearCnt
|
||||||
|
),
|
||||||
|
fc_cnt: K.ARRAY(
|
||||||
|
's32',
|
||||||
|
scoreData[musicId][isHardMode].fcCnt
|
||||||
|
),
|
||||||
|
ex_cnt: K.ARRAY(
|
||||||
|
's32',
|
||||||
|
scoreData[musicId][isHardMode].exCnt
|
||||||
|
),
|
||||||
|
bar: scoreData[musicId][isHardMode].bar.map(
|
||||||
|
(bar, seq) => K.ARRAY('u8', bar, { seq: String(seq) })
|
||||||
|
),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
})
|
)
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
)
|
);
|
||||||
return musicArray;
|
return musicArray;
|
||||||
})()
|
})(),
|
||||||
}
|
},
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if(mdata_ver!=1){
|
|
||||||
sendobj = {
|
|
||||||
data:{
|
|
||||||
player:{
|
|
||||||
jid: K.ITEM("s32", jubeatId),
|
|
||||||
mdata_list: []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
console.log(sendobj, {depth:null});
|
|
||||||
return send.object(sendobj, {compress:true});
|
|
||||||
}
|
|
||||||
|
|
||||||
export const Meeting = (req: EamuseInfo, data: any, send: EamuseSend) => {
|
|
||||||
return send.object({
|
|
||||||
data: {
|
|
||||||
meeting: {
|
|
||||||
single: K.ATTR({ count: "0" }),
|
|
||||||
},
|
|
||||||
reward: {
|
|
||||||
total: K.ITEM("s32", 0),
|
|
||||||
point: K.ITEM("s32", 0),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, {compress:true});
|
};
|
||||||
|
|
||||||
|
if (mdata_ver != 1) {
|
||||||
|
sendobj = {
|
||||||
|
data: {
|
||||||
|
player: {
|
||||||
|
jid: K.ITEM('s32', jubeatId),
|
||||||
|
mdata_list: {
|
||||||
|
music: [],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
console.log(sendobj, { depth: null });
|
||||||
|
return send.object(sendobj, { compress: true });
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Meeting = (req: EamuseInfo, data: any, send: EamuseSend) => {
|
||||||
|
return send.object(
|
||||||
|
{
|
||||||
|
data: {
|
||||||
|
meeting: {
|
||||||
|
single: K.ATTR({ count: '0' }),
|
||||||
|
},
|
||||||
|
reward: {
|
||||||
|
total: K.ITEM('s32', 0),
|
||||||
|
point: K.ITEM('s32', 0),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ compress: true }
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user