IIDX: Added ranking responses

IIDX: Added EXPERT/TUTORIAL records support on SIRIUS
This commit is contained in:
duel0213 2024-02-23 18:48:43 +09:00
parent 927030100a
commit 50f54ee2bb
7 changed files with 284 additions and 33 deletions

View File

@ -2,6 +2,7 @@ import { IDtoRef, Base64toBuffer, GetVersion, OldMidToNewMid, NewMidToOldMid, Re
import { score, score_top } from "../models/score";
import { profile } from "../models/profile";
import { shop_data } from "../models/shop";
import { tutorial } from "../models/tutorial";
export const musicgetrank: EPR = async (info, data, send) => {
const version = GetVersion(info);
@ -21,20 +22,17 @@ export const musicgetrank: EPR = async (info, data, send) => {
[parseInt($(data).attr().iidxid4), await IDtoRef(parseInt($(data).attr().iidxid4))],
];
let m = [], top = [], b = [];
let m = [], top = [], b = [], t = [];
let score_data: number[];
let indices, temp_mid = 0;
if (version < 20) {
indices = cltype === 0 ? [1, 2, 3] : [6, 7, 8];
music_data.forEach((res: score) => {
temp_mid = NewMidToOldMid(res.mid);
if (temp_mid > 1999) return;
let mVersion = Math.floor(temp_mid / 100);
if (mVersion > version) return;
if (cltype == 0) {
score_data = [-1, temp_mid, ...indices.map(i => res.cArray[i]), ...indices.map(i => res.esArray[i]), ...indices.map(i => res.mArray[i])];
} else {
score_data = [-1, temp_mid, ...indices.map(i => res.cArray[i]), ...indices.map(i => res.esArray[i]), ...indices.map(i => res.mArray[i])];
}
score_data = [-1, temp_mid, ...indices.map(i => res.cArray[i]), ...indices.map(i => res.esArray[i]), ...indices.map(i => res.mArray[i])];
m.push(K.ARRAY("s16", score_data));
if (res.cArray[0] != 0) b.push(K.ARRAY("u16", [temp_mid, res.cArray[0]]));
@ -49,28 +47,34 @@ export const musicgetrank: EPR = async (info, data, send) => {
rival_score.forEach((res: score) => {
temp_mid = NewMidToOldMid(res.mid);
if (temp_mid > 1999) return;
let mVersion = Math.floor(temp_mid / 100);
if (mVersion > version) return;
if (cltype == 0) {
score_data = [i, temp_mid, ...indices.map(i => res.cArray[i]), ...indices.map(i => res.esArray[i]), ...indices.map(i => res.mArray[i])];
} else {
score_data = [i, temp_mid, ...indices.map(i => res.cArray[i]), ...indices.map(i => res.esArray[i]), ...indices.map(i => res.mArray[i])];
}
score_data = [i, temp_mid, ...indices.map(i => res.cArray[i]), ...indices.map(i => res.esArray[i]), ...indices.map(i => res.mArray[i])];
m.push(K.ARRAY("s16", score_data));
});
}
// tutorial //
const tutorial = await DB.Find<tutorial>(refid, {
collection: "tutorial",
version: version
});
tutorial.sort((a: tutorial, b: tutorial) => a.tid - b.tid);
tutorial.forEach((res) => {
t.push(K.ARRAY("u16", [res.tid, res.clr]));
});
}
else if (version >= 20) {
if (version >= 27) indices = cltype === 0 ? [0, 1, 2, 3, 4] : [5, 6, 7, 8, 9];
else indices = cltype === 0 ? [1, 2, 3] : [6, 7, 8];
music_data.forEach((res: score) => {
if (cltype == 0) {
score_data = [-1, res.mid, ...indices.map(i => res.cArray[i]), ...indices.map(i => res.esArray[i]), ...indices.map(i => res.mArray[i])];
} else {
score_data = [-1, res.mid, ...indices.map(i => res.cArray[i]), ...indices.map(i => res.esArray[i]), ...indices.map(i => res.mArray[i])];
}
let mVersion = Math.floor(res.mid / 1000);
if (mVersion > version) return;
score_data = [-1, res.mid, ...indices.map(i => res.cArray[i]), ...indices.map(i => res.esArray[i]), ...indices.map(i => res.mArray[i])];
m.push(K.ARRAY("s16", score_data));
if (res.cArray[0] != 0) b.push(K.ARRAY("u16", [res.mid, res.cArray[0]]));
@ -84,11 +88,10 @@ export const musicgetrank: EPR = async (info, data, send) => {
);
rival_score.forEach((res: score) => { // rival score //
if (cltype == 0) {
score_data = [i, res.mid, ...indices.map(i => res.cArray[i]), ...indices.map(i => res.esArray[i]), ...indices.map(i => res.mArray[i])];
} else {
score_data = [i, res.mid, ...indices.map(i => res.cArray[i]), ...indices.map(i => res.esArray[i]), ...indices.map(i => res.mArray[i])];
}
let mVersion = Math.floor(res.mid / 1000);
if (mVersion > version) return;
score_data = [i, res.mid, ...indices.map(i => res.cArray[i]), ...indices.map(i => res.esArray[i]), ...indices.map(i => res.mArray[i])];
m.push(K.ARRAY("s16", score_data));
});
@ -100,8 +103,11 @@ export const musicgetrank: EPR = async (info, data, send) => {
});
if (score_top.length > 0) {
if (version >= 27) {
if (version >= 27) {
score_top.forEach((res) => {
let mVersion = Math.floor(res.mid / 1000);
if (mVersion > version) return;
top.push({
"@attr": ({
name0: res.names[0],
@ -115,6 +121,9 @@ export const musicgetrank: EPR = async (info, data, send) => {
});
} else {
score_top.forEach((res) => {
let mVersion = Math.floor(res.mid / 1000);
if (mVersion > version) return;
top.push({
"@attr": ({
name0: res.names[1],
@ -140,7 +149,8 @@ export const musicgetrank: EPR = async (info, data, send) => {
return send.object({
m,
b
b,
t
});
}
@ -336,7 +346,7 @@ export const musicreg: EPR = async (info, data, send) => {
let opt2Array = Array<number>(10).fill(0); // USED OPTION (CastHour) //
let update = 0;
if (version >= 18) ghost = $(data).buffer("ghost").toString("base64");
if (version >= 17) ghost = $(data).buffer("ghost").toString("base64");
if (version >= 27) {
ghost_gauge = $(data).buffer("ghost_gauge").toString("base64");
@ -369,10 +379,10 @@ export const musicreg: EPR = async (info, data, send) => {
const pExscore = esArray[clid];
if (exscore > pExscore) {
pgArray[clid] = Math.max(pgArray[clid], pgnum);
gArray[clid] = Math.max(gArray[clid], gnum);
mArray[clid] = Math.max(mArray[clid], mnum);
esArray[clid] = Math.max(esArray[clid], exscore);
pgArray[clid] = pgnum;
gArray[clid] = gnum;
mArray[clid] = mnum;
esArray[clid] = exscore;
optArray[clid] = option;
opt2Array[clid] = option_2;
update = 1;

View File

@ -7,6 +7,8 @@ import { profile, default_profile } from "../models/profile";
import { rival, rival_data } from "../models/rival";
import { world_tourism } from "../models/worldtourism";
import { shop_data } from "../models/shop";
import { tutorial } from "../models/tutorial";
import { expert } from "../models/ranking";
export const pccommon: EPR = async (info, data, send) => {
const version = GetVersion(info);
@ -378,6 +380,7 @@ export const pcget: EPR = async (info, data, send) => {
const lm_music_memo = await DB.Find<lightning_musicmemo>(refid, { collection: "lightning_musicmemo", version: version });
const lm_music_memo_new = await DB.Find<lightning_musicmemo_new>(refid, { collection: "lightning_musicmemo_new", version: version });
const shop_data = await DB.FindOne<shop_data>({ collection: "shop_data" });
const expert = await DB.Find<expert>(refid, { collection: "expert", version: version });
if (_.isNil(pcdata)) return send.deny();
@ -453,10 +456,18 @@ export const pcget: EPR = async (info, data, send) => {
let event;
if (version == 17) {
expert.sort((a: expert, b: expert) => a.coid - b.coid);
expert.forEach((res) => {
for (let a = 0; a < 6; a++) {
eArray.push([res.coid, a, res.cArray[a], res.pgArray[a], res.gArray[a]]);
}
});
return send.pugFile("pug/JDJ/pcget.pug", {
profile,
pcdata,
dArray,
eArray,
appendsettings,
custom,
rArray,
@ -870,9 +881,9 @@ export const pctakeover: EPR = async (info, data, send) => {
export const pcvisit: EPR = async (info, data, send) => {
return send.object(
K.ATTR({
anum: "0",
snum: "0",
pnum: "0",
anum: "10",
snum: "10",
pnum: "10",
aflg: "0",
sflg: "0",
pflg: "0",
@ -946,6 +957,21 @@ export const pcsave: EPR = async (info, data, send) => {
pcdata.liflen = parseInt($(data).attr().lift);
pcdata.fcombo[cltype] = parseInt($(data).attr().fcombo);
if (!_.isNil($(data).element("tutorial"))) {
let clr = parseInt($(data).attr("tutorial").clr);
await DB.Upsert<tutorial>(refid,
{
collection: "tutorial",
version: version,
tid: parseInt($(data).attr("tutorial").tid),
},
{
$set: {
clr
}
}
);
}
if (!_.isNil($(data).element("party"))) pcdata.party = $(data).element("party").numbers("fnum");
}
else if (version == 18) {

View File

@ -0,0 +1,172 @@
import { expert, ranking } from "../models/ranking";
import { profile } from "../models/profile";
import { GetVersion, IDtoRef } from "../util";
export const rankingentry: EPR = async (info, data, send) => {
// pside //
const version = GetVersion(info);
const refid = await IDtoRef(parseInt($(data).attr().iidxid));
const coid = parseInt($(data).attr().coid);
const clid = parseInt($(data).attr().clid);
const opname = $(data).attr().opname;
const oppid = parseInt($(data).attr().oppid);
const pgnum = parseInt($(data).attr().pgnum);
const gnum = parseInt($(data).attr().gnum);
const opt = parseInt($(data).attr().opt);
const opt2 = parseInt($(data).attr().opt2);
const clr = parseInt($(data).attr().clr);
const exscore = (pgnum * 2 + gnum);
const cstage = parseInt($(data).attr().cstage);
const expert_data = await DB.FindOne<expert>(refid, {
collection: "expert",
version: version,
coid: coid,
});
let pgArray = Array<number>(6).fill(0); // PGREAT //
let gArray = Array<number>(6).fill(0); // GREAT //
let cArray = Array<number>(6).fill(0); // CLEAR FLAGS //
let optArray = Array<number>(6).fill(0); // USED OPTION (SP/DP) //
let opt2Array = Array<number>(6).fill(0); // USED OPTION (DP) //
let esArray = Array<number>(6).fill(0); // EXSCORE //
if (_.isNil(expert_data)) {
cArray[clid] = clr;
pgArray[clid] = pgnum;
gArray[clid] = gnum;
optArray[clid] = opt;
opt2Array[clid] = opt2;
esArray[clid] = exscore;
}
else {
cArray = expert_data.cArray;
pgArray = expert_data.pgArray;
gArray = expert_data.gArray;
optArray = expert_data.optArray;
opt2Array = expert_data.opt2Array;
esArray = expert_data.esArray;
const pExscore = esArray[clid];
if (exscore > pExscore) {
pgArray[clid] = pgnum;
gArray[clid] = gnum;
optArray[clid] = opt;
opt2Array[clid] = opt2;
esArray[clid] = exscore;
}
cArray[clid] = Math.max(cArray[clid], clr);
}
await DB.Upsert<expert>(
refid,
{
collection: "expert",
version: version,
coid: coid,
},
{
$set: {
cArray,
pgArray,
gArray,
optArray,
opt2Array,
esArray,
}
}
);
const profile = await DB.FindOne<profile>(refid, {
collection: "profile",
});
const name = profile.name;
await DB.Upsert<ranking>(
{
collection: "ranking",
version: version,
coid: coid,
clid: clid,
},
{
$set: {
pgnum: pgnum,
gnum: gnum,
name: name,
opname: opname,
pid: oppid,
udate: 0,
exscore: exscore,
maxStage: cstage,
}
}
);
let expertUser = await DB.Find<expert>(null, {
collection: "expert",
version: version,
coid: coid,
clid: clid,
maxStage: 5,
});
return send.object(K.ATTR({
anum: String(expertUser.length),
jun: "1",
}));
};
export const rankingoentry: EPR = async (info, data, send) => {
const version = GetVersion(info);
const refid = await IDtoRef(parseInt($(data).attr().iidxid));
const coid = parseInt($(data).attr().coid);
const clid = parseInt($(data).attr().clid);
const pgnum = parseInt($(data).attr().pgnum);
const gnum = parseInt($(data).attr().gnum);
const opt = parseInt($(data).attr().opt);
const opt2 = parseInt($(data).attr().opt2);
const clr = parseInt($(data).attr().clr);
const exscore = (pgnum * 2 + gnum);
// TODO:: figure out what this does //
return send.success();
};
export const rankinggetranker: EPR = async (info, data, send) => {
const version = GetVersion(info);
const ranking = await DB.Find<ranking>(null, {
collection: "ranking",
version: version,
coid: parseInt($(data).attr().coid),
clid: parseInt($(data).attr().clid),
});
let result = {
ranker: [],
}
if (_.isNil(ranking)) return send.success();
ranking.sort((a: ranking, b: ranking) => b.exscore - a.exscore);
ranking.forEach((res) => {
result.ranker.push(
K.ATTR({
gnum: String(res.gnum),
pgnum: String(res.pgnum),
name: res.name,
opname: res.opname,
pid: String(res.pid),
udate: String(res.udate),
})
);
});
return send.object(result);
};

View File

@ -5,6 +5,7 @@ import { graderaised } from "./handlers/grade";
import { gssysteminfo } from "./handlers/gamesystem";
import { updateRivalSettings, updateCustomSettings } from "./handlers/webui";
import { GetVersion } from "./util";
import { rankingentry, rankinggetranker, rankingoentry } from "./handlers/ranking";
export function register() {
if (CORE_VERSION_MAJOR <= 1 && CORE_VERSION_MINOR < 31) {
@ -417,6 +418,10 @@ export function register() {
MultiRoute("grade.raised", graderaised);
MultiRoute("ranking.entry", rankingentry);
MultiRoute("ranking.oentry", rankingoentry);
MultiRoute("ranking.getranker", rankinggetranker);
MultiRoute("gameSystem.systemInfo", gssysteminfo);
R.Unhandled((req: EamuseInfo, data: any, send: EamuseSend) => {

View File

@ -0,0 +1,29 @@
export interface expert {
collection: "expert";
version: number;
coid: number;
cArray: number[];
pgArray: number[];
gArray: number[];
optArray: number[];
opt2Array: number[];
esArray: number[];
}
export interface ranking {
collection: "ranking";
version: number;
clid: number;
coid: number;
gnum: number;
pgnum: number;
name: string;
opname: string;
pid: number;
udate: number;
exscore: number; // <- for sort //
maxStage: number;
}

View File

@ -0,0 +1,7 @@
export interface tutorial {
collection: "tutorial";
version: number;
tid: number;
clr: number;
}

View File

@ -4,6 +4,8 @@ pc(status="0")
- for (let d of dArray)
g(__type="u8" __count="4") #{d[0]} #{d[1]} #{d[2]} #{d[3]}
ex
- for (let e of eArray)
e(__type="u32" __count="5") #{e[0]} #{e[1]} #{e[2]} #{e[3]} #{e[4]}
skin(__type="u16" __count="12") #{custom.frame} #{custom.turntable} #{custom.note_burst} #{custom.menu_music} #{appendsettings} #{custom.lane_cover} 0 #{custom.category_vox} 0 0 0
rlist
- for (let rd of rArray)