mirror of
https://github.com/asphyxia-core/plugins.git
synced 2026-03-21 17:34:46 -05:00
IIDX: Added experimental badge save/load support
This commit is contained in:
parent
432cd116c1
commit
064838bca9
|
|
@ -135,6 +135,7 @@ Changelogs
|
|||
**v0.1.15**
|
||||
- Added Initial support for GOLD
|
||||
- Added Disable Beginner Option
|
||||
- Added Experimental Badge saving support
|
||||
- Fixed where plugin may fail to register due to missing types in dev mode
|
||||
- Fixed where pacemaker isn't working as intended due to malformed ghost data on music.appoint response (~ DJ TROOPERS)
|
||||
- Fixed where unable to login after first-play (SPADA, SINOBUZ, Rootage)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { pcdata } from "../models/pcdata";
|
|||
import { grade } from "../models/grade";
|
||||
import { IDtoRef, GetVersion } from "../util";
|
||||
import { eisei_grade } from "../models/lightning";
|
||||
import { badge } from "../models/badge";
|
||||
|
||||
export const graderaised: EPR = async (info, data, send) => {
|
||||
const version = GetVersion(info);
|
||||
|
|
@ -153,6 +154,23 @@ export const graderaised: EPR = async (info, data, send) => {
|
|||
);
|
||||
}
|
||||
|
||||
if (!_.isNil($(data).element("badge"))) {
|
||||
await DB.Upsert<badge>(
|
||||
refid,
|
||||
{
|
||||
collection: "badge",
|
||||
version: version,
|
||||
category_name: "grade",
|
||||
flg_id: parseInt($(data).attr("badge").badge_flg_id),
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
flg: parseInt($(data).attr("badge").badge_flg),
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
let gradeUser = await DB.Find<grade>(null, {
|
||||
collection: "grade",
|
||||
version: version,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { score, score_top } from "../models/score";
|
|||
import { profile } from "../models/profile";
|
||||
import { shop_data } from "../models/shop";
|
||||
import { tutorial } from "../models/tutorial";
|
||||
import { badge } from "../models/badge";
|
||||
|
||||
export const musicgetrank: EPR = async (info, data, send) => {
|
||||
const version = GetVersion(info);
|
||||
|
|
@ -435,12 +436,16 @@ export const musicappoint: EPR = async (info, data, send) => {
|
|||
|
||||
export const musicreg: EPR = async (info, data, send) => {
|
||||
const version = GetVersion(info);
|
||||
const refid = await IDtoRef(parseInt($(data).attr().iidxid));
|
||||
|
||||
const shop_data = await DB.FindOne<shop_data>({
|
||||
collection: "shop_data",
|
||||
});
|
||||
const profile = await DB.FindOne<profile>(refid, {
|
||||
collection: "profile",
|
||||
});
|
||||
|
||||
// wid, oppid, opname, opt, opt2, pside, nocnt, anum //
|
||||
const refid = await IDtoRef(parseInt($(data).attr().iidxid));
|
||||
const pgnum = parseInt($(data).attr().pgnum);
|
||||
const gnum = parseInt($(data).attr().gnum);
|
||||
const mnum = parseInt($(data).attr().mnum);
|
||||
|
|
@ -470,10 +475,6 @@ export const musicreg: EPR = async (info, data, send) => {
|
|||
mid: mid,
|
||||
});
|
||||
|
||||
const profile = await DB.FindOne<profile>(refid, {
|
||||
collection: "profile",
|
||||
});
|
||||
|
||||
// SPN -> DPA [0~5] -> LINCLE //
|
||||
// SPB -> DPL [0~9] -> Heroic Verse //
|
||||
let pgArray = Array<number>(10).fill(0); // PGREAT //
|
||||
|
|
@ -618,6 +619,59 @@ export const musicreg: EPR = async (info, data, send) => {
|
|||
}
|
||||
);
|
||||
|
||||
if (!_.isNil($(data).element("badge"))) {
|
||||
if (!_.isNil($(data).attr("badge").djLevel_badge_flg_id)) {
|
||||
await DB.Upsert<badge>(
|
||||
refid,
|
||||
{
|
||||
collection: "badge",
|
||||
version: version,
|
||||
category_name: "djLevel",
|
||||
flg_id: parseInt($(data).attr("badge").djLevel_badge_flg_id),
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
flg: parseInt($(data).attr("badge").djLevel_badge_flg),
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (!_.isNil($(data).attr("badge").clear_badge_flg_id)) {
|
||||
await DB.Upsert<badge>(
|
||||
refid,
|
||||
{
|
||||
collection: "badge",
|
||||
version: version,
|
||||
category_name: "clear",
|
||||
flg_id: parseInt($(data).attr("badge").clear_badge_flg_id),
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
flg: parseInt($(data).attr("badge").clear_badge_flg),
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (!_.isNil($(data).attr("badge").rivalChallenge_badge_flg)) {
|
||||
await DB.Upsert<badge>(
|
||||
refid,
|
||||
{
|
||||
collection: "badge",
|
||||
version: version,
|
||||
category_name: "rivalChallenge",
|
||||
flg_id: 0,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
flg: parseInt($(data).attr("badge").rivalChallenge_badge_flg),
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let shop_rank = -1, shop_rank_data = [];
|
||||
let scores: any[][];
|
||||
scores = (
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import { shop_data } from "../models/shop";
|
|||
import { tutorial } from "../models/tutorial";
|
||||
import { expert } from "../models/ranking";
|
||||
import { blueboss } from "../models/event";
|
||||
import { badge } from "../models/badge";
|
||||
|
||||
export const pccommon: EPR = async (info, data, send) => {
|
||||
const version = GetVersion(info);
|
||||
|
|
@ -469,14 +470,16 @@ export const pcget: EPR = async (info, data, send) => {
|
|||
const custom = await DB.FindOne<custom>(refid, { collection: "custom", version: version });
|
||||
const grade = await DB.Find<grade>(refid, { collection: "grade", version: version });
|
||||
const rivals = await DB.Find<rival>(refid, { collection: "rival" });
|
||||
const shop_data = await DB.FindOne<shop_data>({ collection: "shop_data" });
|
||||
const expert = await DB.Find<expert>(refid, { collection: "expert", version: version });
|
||||
const world_tourism = await DB.Find<world_tourism>(refid, { collection: "world_tourism", version: version });
|
||||
const badge = await DB.Find<badge>(refid, { collection: "badge", version: version });
|
||||
|
||||
const lm_settings = await DB.FindOne<lightning_settings>(refid, { collection: "lightning_settings", version: version });
|
||||
const lm_playdata = await DB.FindOne<lightning_playdata>(refid, { collection: "lightning_playdata", version: version });
|
||||
const lm_eisei_grade = await DB.Find<eisei_grade>(refid, { collection: "eisei_grade", version: version });
|
||||
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();
|
||||
|
||||
|
|
@ -900,43 +903,54 @@ export const pcget: EPR = async (info, data, send) => {
|
|||
badge_flg
|
||||
***/
|
||||
|
||||
if (version >= 30) {
|
||||
for (let a = 0; a < 13; a++) {
|
||||
if (a == 0 || a == 1) {
|
||||
for (let b = 0; b < 24; b++) {
|
||||
bArray.push({
|
||||
id: a,
|
||||
flg_id: b,
|
||||
flg: -1,
|
||||
});
|
||||
}
|
||||
continue;
|
||||
} else if (a == 9) {
|
||||
for (let b = 0; b < 10; b++) {
|
||||
bArray.push({
|
||||
id: a,
|
||||
flg_id: b,
|
||||
flg: -1,
|
||||
});
|
||||
}
|
||||
continue;
|
||||
} else if (a == 7 || a == 10) {
|
||||
for (let b = 0; b < 2; b++) {
|
||||
bArray.push({
|
||||
id: a,
|
||||
flg_id: b,
|
||||
flg: -1,
|
||||
});
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (version >= 30 && badge.length > 0) {
|
||||
let djLevel, clear, visitor, notes_radar, event1;
|
||||
djLevel = badge.filter((res) => res.category_name === "djLevel");
|
||||
djLevel.forEach((res) => {
|
||||
bArray.push({
|
||||
id: a,
|
||||
flg_id: 0,
|
||||
flg: -1,
|
||||
id: 0,
|
||||
flg_id: res.flg_id,
|
||||
flg: res.flg,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
clear = badge.filter((res) => res.category_name === "clear");
|
||||
clear.forEach((res) => {
|
||||
bArray.push({
|
||||
id: 1,
|
||||
flg_id: res.flg_id,
|
||||
flg: res.flg,
|
||||
});
|
||||
});
|
||||
|
||||
// this keep sending back on save //
|
||||
// possibly wrong category_id but at least doesn't show as new badges //
|
||||
visitor = badge.filter((res) => res.category_name === "visitor");
|
||||
visitor.forEach((res) => {
|
||||
bArray.push({
|
||||
id: 6,
|
||||
flg_id: res.flg_id,
|
||||
flg: res.flg,
|
||||
});
|
||||
});
|
||||
|
||||
notes_radar = badge.filter((res) => res.category_name === "notes_radar");
|
||||
notes_radar.forEach((res) => {
|
||||
bArray.push({
|
||||
id: 7,
|
||||
flg_id: res.flg_id,
|
||||
flg: res.flg,
|
||||
});
|
||||
});
|
||||
|
||||
event1 = badge.filter((res) => res.category_name === "event1");
|
||||
event1.forEach((res) => {
|
||||
bArray.push({
|
||||
id: 9,
|
||||
flg_id: res.flg_id,
|
||||
flg: res.flg,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (version == 24) { // migration //
|
||||
|
|
@ -1211,6 +1225,7 @@ export const pcsave: EPR = async (info, data, send) => {
|
|||
const hasWorldTourism = !(_.isNil($(data).element("world_tourism_data")));
|
||||
const hasMusicMemo = !(_.isNil($(data).element("music_memo")));
|
||||
const hasTowerData = !(_.isNil($(data).element("tower_data")));
|
||||
const hasBadgeData = !(_.isNil($(data).element("badge")));
|
||||
|
||||
if (cltype == 0) pcdata.spnum += 1;
|
||||
else pcdata.dpnum += 1;
|
||||
|
|
@ -3515,6 +3530,116 @@ export const pcsave: EPR = async (info, data, send) => {
|
|||
profile.total_kbd += parseInt($(data).attr("tower_data").keyboard);
|
||||
profile.total_scr += parseInt($(data).attr("tower_data").scratch);
|
||||
}
|
||||
|
||||
// saving for future purpose //
|
||||
if (hasBadgeData) {
|
||||
let badge_data = [];
|
||||
let badge = $(data).element("badge");
|
||||
|
||||
if (!(_.isNil(badge.element("today_recommend")))) {
|
||||
let badgeInfo = {
|
||||
category_id: "today_recommend",
|
||||
flg_id: 0,
|
||||
flg: parseInt(badge.element("today_recommend").attr().flg),
|
||||
};
|
||||
|
||||
badge_data.push(badgeInfo);
|
||||
}
|
||||
|
||||
if (!(_.isNil(badge.element("weekly_ranking")))) {
|
||||
let badgeInfo = {
|
||||
category_id: "weekly_ranking",
|
||||
flg_id: 0,
|
||||
flg: parseInt(badge.element("weekly_ranking").attr().flg),
|
||||
};
|
||||
|
||||
badge_data.push(badgeInfo);
|
||||
}
|
||||
|
||||
if (!(_.isNil(badge.element("visitor")))) {
|
||||
badge.elements("visitor").forEach((res) => {
|
||||
let badgeInfo = {
|
||||
category_id: "visitor",
|
||||
flg_id: parseInt(res.attr().flg_id),
|
||||
flg: parseInt(res.attr().flg),
|
||||
};
|
||||
|
||||
badge_data.push(badgeInfo);
|
||||
});
|
||||
}
|
||||
|
||||
if (!(_.isNil(badge.element("notes_radar")))) {
|
||||
badge.elements("notes_radar").forEach((res) => {
|
||||
let badgeInfo = {
|
||||
category_id: "notes_radar",
|
||||
flg_id: parseInt(res.attr().flg_id),
|
||||
flg: parseInt(res.attr().flg),
|
||||
};
|
||||
|
||||
badge_data.push(badgeInfo);
|
||||
});
|
||||
}
|
||||
|
||||
if (!(_.isNil(badge.element("world_tourism")))) {
|
||||
let badgeInfo = {
|
||||
category_id: "world_tourism",
|
||||
flg_id: 0,
|
||||
flg: parseInt(badge.element("world_tourism").attr().flg),
|
||||
};
|
||||
|
||||
badge_data.push(badgeInfo);
|
||||
}
|
||||
|
||||
if (!(_.isNil(badge.element("event1")))) {
|
||||
badge.elements("event1").forEach((res) => {
|
||||
let badgeInfo = {
|
||||
category_id: "event1",
|
||||
flg_id: parseInt(res.attr().flg_id),
|
||||
flg: parseInt(res.attr().flg),
|
||||
};
|
||||
|
||||
badge_data.push(badgeInfo);
|
||||
});
|
||||
}
|
||||
|
||||
if (!(_.isNil(badge.element("arena")))) {
|
||||
badge.elements("arena").forEach((res) => {
|
||||
let badgeInfo = {
|
||||
category_id: "arena",
|
||||
flg_id: parseInt(res.attr().flg_id),
|
||||
flg: parseInt(res.attr().flg),
|
||||
};
|
||||
|
||||
badge_data.push(badgeInfo);
|
||||
});
|
||||
}
|
||||
|
||||
if (!(_.isNil(badge.element("iidx_exam")))) {
|
||||
let badgeInfo = {
|
||||
category_id: "iidx_exam",
|
||||
flg_id: 0,
|
||||
flg: parseInt(badge.element("iidx_exam").attr().flg),
|
||||
};
|
||||
|
||||
badge_data.push(badgeInfo);
|
||||
}
|
||||
|
||||
badge_data.forEach((res) => {
|
||||
DB.Upsert<badge>(
|
||||
refid,
|
||||
{
|
||||
collection: "badge",
|
||||
version: version,
|
||||
category_name: res.category_id,
|
||||
flg_id: res.flg_id,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
flg: res.flg,
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
await DB.Upsert<profile>(
|
||||
|
|
|
|||
8
iidx@asphyxia/models/badge.ts
Normal file
8
iidx@asphyxia/models/badge.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
export interface badge {
|
||||
collection: "badge";
|
||||
version: number;
|
||||
|
||||
category_name: string;
|
||||
flg_id: number;
|
||||
flg: number;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user