From 934c965de9a2e5f082d9cab8614849c73c2be33f Mon Sep 17 00:00:00 2001 From: Kirito Date: Tue, 27 Apr 2021 22:10:24 +0900 Subject: [PATCH] copious support --- jubeat@asphyxia/README.md | 12 +- jubeat@asphyxia/handlers/profile.ts | 271 +++++++++++++++--- jubeat@asphyxia/models/profile.ts | 60 +++- jubeat@asphyxia/templates/copious/profile.pug | 52 ++-- 4 files changed, 332 insertions(+), 63 deletions(-) diff --git a/jubeat@asphyxia/README.md b/jubeat@asphyxia/README.md index c40587a..7ba2d49 100644 --- a/jubeat@asphyxia/README.md +++ b/jubeat@asphyxia/README.md @@ -1,6 +1,6 @@ # Jubeat -Plugin Version: **v1.0.0** +Plugin Version: **v1.2.0** ### Supported Versions @@ -8,11 +8,21 @@ Plugin Version: **v1.0.0** - knit - knit APPEND +- copious +- copious APPEND ### Changelogs *** +#### 1.2.0 + +- copious (APPEND) support + +#### 1.1.0 + +- Fix profile structure + #### 1.0.0 - Initial Release diff --git a/jubeat@asphyxia/handlers/profile.ts b/jubeat@asphyxia/handlers/profile.ts index 7d0e54e..9f7c9ea 100644 --- a/jubeat@asphyxia/handlers/profile.ts +++ b/jubeat@asphyxia/handlers/profile.ts @@ -32,7 +32,6 @@ export const profile: EPR = async (info, data, send) => { if (profile.previous_version < version) { migration = true; profile.name = ""; - await DB.Update(refId, { collection: "profile" }, { $set: { name: "", previous_version: version } }); } if (name) { @@ -78,19 +77,16 @@ export const profile: EPR = async (info, data, send) => { }, last: { areaname: 'NONE', - category: 0, conciergeSuggestId: 0, filter: 0, marker: 0, mselStat: 0, musicId: 0, - parts: 0, playTime: "0", - seqEditId: '', seqId: 0, shopname: 'NONE', - showCombo: 0, - showRank: 0, + showCombo: 1, + showRank: 1, sort: 0, theme: 0, title: 0 @@ -116,21 +112,95 @@ export const profile: EPR = async (info, data, send) => { refId, migration, name: profile.name, - jubeatId: profile.jubeatId, ...profile.knit + jubeatId: profile.jubeatId, + ...profile.knit }, { compress: true }); } if (version === 4) { - if (U.GetConfig("unlock_all_songs")) { - + if (!profile.copious) { + profile.copious = { + collabo: { dailyMusicId: 0, served: 0, wonderState: 0, yellowState: 0 }, + info: { + acvOwn: 0, + acvPoint: 0, + acvState: 0, + acvThrow: [0, 0, 0], + beatCount: 0, + excellentCount: 0, + excellentSeqCount: 0, + fullComboCount: 0, + fullComboSeqCount: 0, + jubility: 0, + jubilityYday: 0, + matchCount: 0, + mynewsCount: 0, + saveCount: 0, + savedCount: 0, + tuneCount: 0, + totalBestScore: 0 + }, + item: { + markerList: Array(2).fill(0), + partsList: Array(96).fill(0), + secretList: Array(12).fill(0), + themeList: 0, + titleList: Array(32).fill(0) + }, + item_new: { + markerList: Array(2).fill(0), + secretList: Array(12).fill(0), + themeList: 0, + titleList: Array(32).fill(0) + }, + last: { + areaname: 'NONE', + category: 0, + marker: 0, + mselStat: 0, + musicId: 0, + parts: 0, + playTime: '0', + seqId: 0, + shopname: 'NONE', + showCombo: 1, + showRank: 1, + sort: 0, + theme: 0, + title: 0 + } + }; + await DB.Update(refId, { collection: "profile" }, profile); } - return send.pugFile('templates/copious/profile.pug', { refId, migration, ...profile }, { compress: false }); + if (U.GetConfig("unlock_all_songs")) { + profile.copious.item = { + markerList: Array(2).fill(-1), + partsList: Array(96).fill(-1), + secretList: Array(12).fill(-1), + themeList: -1, + titleList: Array(32).fill(-1) + }; + profile.copious.item_new = { + markerList: Array(2).fill(0), + secretList: Array(12).fill(0), + themeList: 0, + titleList: Array(32).fill(0) + }; + } + return send.pugFile('templates/copious/profile.pug', { + refId, + migration, + name: profile.name, + jubeatId: profile.jubeatId, + ...profile.copious + }, { compress: false }); } return send.deny(); }; export const saveProfile: EPR = async (info, { data }, send) => { + console.log(U.toXML(data)); const player = $(data).element("player"); const refId = player.str("refid"); @@ -141,6 +211,10 @@ export const saveProfile: EPR = async (info, { data }, send) => { const profile = await DB.FindOne(refId, { collection: "profile" }); + if (profile.previous_version < version) { + await DB.Update(refId, { collection: "profile" }, { $set: { previous_version: version } }); + } + if (version === 3) { profile.name = player.str("name"); @@ -173,15 +247,16 @@ export const saveProfile: EPR = async (info, { data }, send) => { if (!U.GetConfig("unlock_all_songs")) { item.secretList = player.numbers('item.secret_list', item.secretList); - item.themeList = player.number('item.theme_list', item.themeList); - item.markerList = player.numbers('item.marker_list', item.markerList); - item.titleList = player.numbers('item.title_list', item.titleList); - item_new.secretList = player.numbers('item.secret_new', profile.knit.item_new.secretList); - item_new.themeList = player.number('item.theme_new', profile.knit.item_new.themeList); - item_new.markerList = player.numbers('item.marker_new', profile.knit.item_new.markerList); - item_new.titleList = player.numbers('item.title_new', profile.knit.item_new.titleList); } + item.themeList = player.number('item.theme_list', item.themeList); + item.markerList = player.numbers('item.marker_list', item.markerList); + item.titleList = player.numbers('item.title_list', item.titleList); + + item_new.themeList = player.number('item.theme_new', profile.knit.item_new.themeList); + item_new.markerList = player.numbers('item.marker_new', profile.knit.item_new.markerList); + item_new.titleList = player.numbers('item.title_new', profile.knit.item_new.titleList); + // Append const collaboNode = player.element("collabo"); @@ -226,15 +301,120 @@ export const saveProfile: EPR = async (info, { data }, send) => { }); } } - } - try { await DB.Update(refId, { collection: "profile" }, profile); return send.object({ data: { player: { session_id: K.ITEM('s32', 1) } } }); - } catch { - return send.deny(); } + + if (version === 4) { + profile.name = player.str("name"); + + const { info, last, item, item_new, collabo } = profile.copious; + + last.shopname = player.str("shopname", last.shopname); + last.areaname = player.str("areaname", last.areaname); + + const infoNode = player.element("info"); + if (infoNode) { + info.jubility = infoNode.number("jubility", info.jubility); + info.jubilityYday = infoNode.number("jubility_yday", info.jubilityYday); + info.acvState = infoNode.number("acv_state", info.acvState); + info.acvPoint = infoNode.number("acv_point", info.acvPoint); + info.acvOwn = infoNode.number("acv_own", info.acvOwn); + info.acvThrow = infoNode.numbers("acv_throw", info.acvThrow); + info.tuneCount = infoNode.number("tune_cnt", info.tuneCount); + info.saveCount = infoNode.number("save_cnt", info.saveCount); + info.savedCount = infoNode.number("saved_cnt", info.savedCount); + info.fullComboCount = infoNode.number("fc_cnt", info.fullComboCount); + info.fullComboSeqCount = infoNode.number("fc_seq_cnt", info.fullComboSeqCount); + info.excellentCount = infoNode.number("exc_cnt", info.excellentCount); + info.excellentSeqCount = infoNode.number("exc_seq_cnt", info.excellentSeqCount); + info.matchCount = infoNode.number("match_cnt", info.matchCount); + info.beatCount = infoNode.number("beat_cnt", info.beatCount); + info.totalBestScore = infoNode.number("total_best_score", info.totalBestScore); + info.mynewsCount = infoNode.number("mynews_cnt", info.mynewsCount); + } + + + const itemNode = player.element("item"); + if (itemNode) { + if (!U.GetConfig("unlock_all_songs")) { + item.secretList = itemNode.numbers("secret_list", item.secretList); + item_new.secretList = itemNode.numbers("secret_new", item_new.secretList); + } + item.themeList = itemNode.number("theme_list", item.themeList); + item.markerList = itemNode.numbers("marker_list", item.markerList); + item.titleList = itemNode.numbers("title_list", item.titleList); + item.partsList = itemNode.numbers("parts_list", item.partsList); + item_new.themeList = itemNode.number("theme_new", item_new.themeList); + item_new.markerList = itemNode.numbers("marker_new", item_new.markerList); + item_new.titleList = itemNode.numbers("title_new", item_new.titleList); + } + + + last.playTime = String(new Date().getTime()); + + // Append + const collaboNode = $(data).element("collabo"); + if (collaboNode) { + collabo.dailyMusicId = collaboNode.number("daily_music_id"); + collabo.served = collaboNode.number("served"); + collabo.wonderState = collaboNode.number("wonder_state"); + collabo.yellowState = collaboNode.number("yellow_state"); + } + + const resultNode = $(data).element("result"); + if (resultNode) { + const tunes = resultNode.elements('tune'); + for (const tune of tunes) { + const musicId = tune.number("music", 0); + last.musicId = musicId; + last.seqId = parseInt(tune.attr("player.score").seq) || 0; + last.marker = tune.number("marker", last.marker); + last.title = tune.number("title", last.title); + last.parts = tune.number("parts", last.parts); + last.theme = tune.number("theme", last.theme); + last.sort = tune.number("sort", last.sort); + last.category = tune.number("category", last.category); + last.showCombo = tune.number("rank_sort", last.showCombo); + last.showRank = tune.number("combo_disp", last.showRank); + last.mselStat = tune.number("msel_stat", last.mselStat); + + const score = tune.number('player.score'); + const seq = parseInt(tune.attr('player.score').seq); + const clear = parseInt(tune.attr('player.score').clear); + const combo = parseInt(tune.attr('player.score').combo); + const bestScore = tune.number('player.best_score'); + const bestClear = tune.number('player.best_clear'); + const playCount = tune.number('player.play_cnt'); + const clearCount = tune.number('player.clear_cnt'); + const fullcomboCount = tune.number('player.fc_cnt'); + const excellentCount = tune.number('player.exc_cnt'); + const mbar = tune.numbers('player.mbar'); + + await updateScore(refId, musicId, seq, score, clear, mbar, { + playCount, + clearCount, + fullcomboCount, + excellentCount + }); + } + } + + await DB.Update(refId, { collection: "profile" }, profile); + + return send.object({ + data: { + player: { session_id: K.ITEM('s32', 1) }, + collabo: { + dellar: K.ITEM('s32', 0) + } + } + }); + } + + return send.deny(); }; export const loadScore: EPR = async (info, data, send) => { @@ -273,7 +453,7 @@ export const loadScore: EPR = async (info, data, send) => { data.bar[score.seq] = score.bar; } - if (version === 3) return send.object({ + if (version === 3 || version === 4) return send.object({ data: { player: { playdata: K.ATTR({ count: String(Object.keys(scoreData).length) }, { @@ -347,16 +527,41 @@ export const meeting: EPR = (info, data, send) => { }); }; -export const getCollabo: EPR = (info, data, send) => send.object({ - data: { - collabo: { - played: { - iidx: K.ITEM("s8", 1), - popn: K.ITEM("s8", 1), - ddr: K.ITEM("s8", 1), - reflec: K.ITEM("s8", 1), - gfdm: K.ITEM("s8", 1), +export const getCollabo: EPR = (info, data, send) => { + const version = getVersion(info); + if (version === 0) return send.deny(); + + if (version === 3) { + return send.object({ + + data: { + collabo: { + played: { + iidx: K.ITEM("s8", 1), + popn: K.ITEM("s8", 1), + ddr: K.ITEM("s8", 1), + reflec: K.ITEM("s8", 1), + gfdm: K.ITEM("s8", 1), + } + } } - } + }); } -}); + + if (version === 4) { + return send.object({ + + data: { + player: { + collabo: { + reward: K.ITEM("s32", 0), + dellar: K.ITEM("s32", 0), + music_id: K.ITEM("s32", 0), + wonder_state: K.ITEM("u32", 0), + yellow_state: K.ITEM("u32", 0), + } + } + } + }); + } +}; diff --git a/jubeat@asphyxia/models/profile.ts b/jubeat@asphyxia/models/profile.ts index af9aea3..5cc4191 100644 --- a/jubeat@asphyxia/models/profile.ts +++ b/jubeat@asphyxia/models/profile.ts @@ -32,17 +32,14 @@ export default interface Profile { areaname: string; playTime: string; title: number; - parts: number; theme: number; marker: number; showRank: number; showCombo: number; musicId: number; seqId: number; - seqEditId: string; sort: number; filter: number; - category: number; mselStat: number; conciergeSuggestId: number; }; @@ -63,4 +60,61 @@ export default interface Profile { completed: boolean; } }; + + copious?: { + info: { + jubility: number; + jubilityYday: number; + acvPoint: number; + acvState: number; + acvThrow: number[]; + acvOwn: number; + tuneCount: number; + saveCount: number; + savedCount: number; + fullComboCount: number; + fullComboSeqCount: number; + excellentCount: number; + excellentSeqCount: number; + matchCount: number; + beatCount: number; + mynewsCount: number; + totalBestScore: number; + }, + last: { + playTime: string; + shopname: string; + areaname: string; + title: number; + parts: number; + theme: number; + marker: number; + showRank: number; + showCombo: number; + musicId: number; + seqId: number; + sort: number; + category: number; + mselStat: number; + }, + item: { + secretList: number[]; + themeList: number; + markerList: number[]; + titleList: number[]; + partsList: number[]; + }, + item_new: { + secretList: number[]; + themeList: number; + markerList: number[]; + titleList: number[]; + }, + collabo: { + dailyMusicId: number; + served: number; + wonderState: number; + yellowState: number; + } + }; } diff --git a/jubeat@asphyxia/templates/copious/profile.pug b/jubeat@asphyxia/templates/copious/profile.pug index b7b10b9..1716f76 100644 --- a/jubeat@asphyxia/templates/copious/profile.pug +++ b/jubeat@asphyxia/templates/copious/profile.pug @@ -7,30 +7,30 @@ gametop info inherit(__type="bool") #{migration ? 1 : 0} - jubility(__type="s16") #{jubility} - jubility_yday(__type="s16") #{jubilityYday} - acv_point(__type="s32") 0 - acv_state(__type="s8") 0 - acv_throw(__type="s32") 0 - acv_own(__type="s32") 0 - tune_cnt(__type="s32") #{tuneCount} - save_cnt(__type="s32") #{saveCount} - saved_cnt(__type="s32") #{savedCount} - fc_cnt(__type="s32") #{fullcomboCount} - ex_cnt(__type="s32") #{excellentCount} - match_cnt(__type="s32") #{matchCount} - beat_cnt(__type="s32") #{beatCount} - mynews_cnt(__type="s32") #{mynewsCount} + jubility(__type="s16") #{info.jubility} + jubility_yday(__type="s16") #{info.jubilityYday} + acv_point(__type="s32") #{info.acvPoint} + acv_state(__type="s8") #{info.acvState} + acv_throw(__type="s32" __count="3") #{info.acvThrow.join(" ")} + acv_own(__type="s32") #{info.acvOwn} + tune_cnt(__type="s32") #{info.tuneCount} + save_cnt(__type="s32") #{info.saveCount} + saved_cnt(__type="s32") #{info.savedCount} + fc_cnt(__type="s32") #{info.fullComboCount} + ex_cnt(__type="s32") #{info.excellentCount} + match_cnt(__type="s32") #{info.matchCount} + beat_cnt(__type="s32") #{info.beatCount} + mynews_cnt(__type="s32") #{info.mynewsCount} mtg_entry_cnt(__type="s32") 0 mtg_hold_cnt(__type="s32") 0 mtg_result(__type="u8") 0 last - play_time(__type="s64") #{last.playTime || 0} + play_time(__type="s64") #{last.playTime} shopname(__type="str") #{last.shopname} areaname(__type="str") #{last.areaname} title(__type="s16") #{last.title} - parts(__type="s16") #{last.parts || 0} + parts(__type="s16") #{last.parts} theme(__type="s8") #{last.theme} marker(__type="s8") #{last.marker} rank_sort(__type="s8") #{last.showRank} @@ -38,20 +38,20 @@ gametop music_id(__type="s32") #{last.musicId} seq_id(__type="s8") #{last.seqId} sort(__type="s8") #{last.sort} - category(__type="s8") #{last.category || 0} + category(__type="s8") #{last.category} msel_stat(__type="s8") #{last.mselStat} item - secret_list(__type="s32" __count="12") #{Array(1).fill(0)} - theme_list(__type="s16") 0 - marker_list(__type="s32" __count="2") #{Array(1).fill(0)} - title_list(__type="s32" __count="32") #{Array(1).fill(0)} - parts_list(__type="s32" __count="32") #{Array(1).fill(0)} + secret_list(__type="s32" __count="12") #{item.secretList.join(" ")} + theme_list(__type="s16") #{item.themeList} + marker_list(__type="s32" __count="2") #{item.markerList.join(" ")} + title_list(__type="s32" __count="32") #{item.titleList.join(" ")} + parts_list(__type="s32" __count="96") #{item.partsList.join(" ")} new - secret_list(__type="s32" __count="12") #{Array(1).fill(0)} - theme_list(__type="s16") 0 - marker_list(__type="s32" __count="2") #{Array(1).fill(0)} - title_list(__type="s32" __count="32") #{Array(1).fill(0)} + secret_list(__type="s32" __count="12") #{item_new.secretList.join(" ")} + theme_list(__type="s16") #{item_new.themeList} + marker_list(__type="s32" __count="2") #{item_new.markerList.join(" ")} + title_list(__type="s32" __count="32") #{item_new.titleList.join(" ")} challenge today