mirror of
https://github.com/asphyxia-core/plugins.git
synced 2026-09-22 22:27:56 +03:00
Added several player profile stats to the web UI.
Refactored and cleaned up several functions. MDB loader now logs the number of loaded songs available to GF and DM. MDB: Fixed "is_secret" field being ignored (always set to false)
This commit is contained in:
@@ -6,11 +6,11 @@ const logger = new Logger("MusicList")
|
||||
|
||||
export const playableMusic: EPR = async (info, data, send) => {
|
||||
const version = getVersion(info);
|
||||
|
||||
let music: CommonMusicDataField[] = [];
|
||||
try {
|
||||
if (U.GetConfig("enable_custom_mdb")) {
|
||||
let customMdb = findMDBFile("custom")
|
||||
|
||||
music = (await readMDBFile(customMdb)).music
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -23,7 +23,12 @@ export const playableMusic: EPR = async (info, data, send) => {
|
||||
music = (await loadSongsForGameVersion(version)).music
|
||||
}
|
||||
|
||||
await send.object({
|
||||
let response = getPlayableMusicResponse(music)
|
||||
await send.object(response)
|
||||
};
|
||||
|
||||
function getPlayableMusicResponse(music) {
|
||||
return {
|
||||
hot: {
|
||||
major: K.ITEM('s32', 1),
|
||||
minor: K.ITEM('s32', 1),
|
||||
@@ -31,5 +36,5 @@ export const playableMusic: EPR = async (info, data, send) => {
|
||||
musicinfo: K.ATTR({ nr: `${music.length}` }, {
|
||||
music,
|
||||
}),
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
import { getEncoreStageData } from "../data/extrastage";
|
||||
import Logger from "../utils/logger";
|
||||
|
||||
const logger = new Logger('info');
|
||||
export const shopInfoRegist: EPR = async (info, data, send) => {
|
||||
send.object({
|
||||
data: {
|
||||
@@ -16,64 +18,8 @@ export const shopInfoRegist: EPR = async (info, data, send) => {
|
||||
}
|
||||
|
||||
export const gameInfoGet: EPR = async (info, data, send) => {
|
||||
const addition: any = {
|
||||
monstar_subjugation: {
|
||||
bonus_musicid: K.ITEM('s32', 0),
|
||||
},
|
||||
bear_fes: {},
|
||||
nextadium: {},
|
||||
};
|
||||
const time = BigInt(31536000);
|
||||
for (let i = 1; i <= 20; ++i) {
|
||||
const obj = {
|
||||
term: K.ITEM('u8', 0),
|
||||
start_date_ms: K.ITEM('u64', time),
|
||||
end_date_ms: K.ITEM('u64', time),
|
||||
};
|
||||
if (i == 1) {
|
||||
addition[`phrase_combo_challenge`] = obj;
|
||||
addition[`long_otobear_fes_1`] = {
|
||||
term: K.ITEM('u8', 0),
|
||||
start_date_ms: K.ITEM('u64', time),
|
||||
end_date_ms: K.ITEM('u64', time),
|
||||
bonus_musicid: {},
|
||||
};
|
||||
addition[`sdvx_stamprally3`] = obj;
|
||||
addition[`chronicle_1`] = obj;
|
||||
addition[`paseli_point_lottery`] = obj;
|
||||
addition['sticker_campaign'] = {
|
||||
term: K.ITEM('u8', 0),
|
||||
sticker_list: {},
|
||||
};
|
||||
addition['thanksgiving'] = {
|
||||
...obj,
|
||||
box_term: {
|
||||
state: K.ITEM('u8', 0)
|
||||
}
|
||||
};
|
||||
addition['lotterybox'] = {
|
||||
...obj,
|
||||
box_term: {
|
||||
state: K.ITEM('u8', 0)
|
||||
}
|
||||
};
|
||||
} else {
|
||||
addition[`phrase_combo_challenge_${i}`] = obj;
|
||||
}
|
||||
|
||||
if (i <= 4) {
|
||||
addition['monstar_subjugation'][`monstar_subjugation_${i}`] = obj;
|
||||
addition['bear_fes'][`bear_fes_${i}`] = obj;
|
||||
}
|
||||
|
||||
if (i <= 3) {
|
||||
addition[`kouyou_challenge_${i}`] = {
|
||||
term: K.ITEM('u8', 0),
|
||||
bonus_musicid: K.ITEM('s32', 0),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const eventData = getEventDataResponse()
|
||||
const extraData = getEncoreStageData(info)
|
||||
|
||||
await send.object({
|
||||
@@ -157,6 +103,70 @@ export const gameInfoGet: EPR = async (info, data, send) => {
|
||||
},
|
||||
},
|
||||
},
|
||||
...addition,
|
||||
...eventData,
|
||||
});
|
||||
};
|
||||
|
||||
function getEventDataResponse() {
|
||||
const addition: any = {
|
||||
monstar_subjugation: {
|
||||
bonus_musicid: K.ITEM('s32', 0),
|
||||
},
|
||||
bear_fes: {},
|
||||
nextadium: {},
|
||||
};
|
||||
const time = BigInt(31536000);
|
||||
|
||||
for (let i = 1; i <= 20; ++i) {
|
||||
const obj = {
|
||||
term: K.ITEM('u8', 0),
|
||||
start_date_ms: K.ITEM('u64', time),
|
||||
end_date_ms: K.ITEM('u64', time),
|
||||
};
|
||||
if (i == 1) {
|
||||
addition[`phrase_combo_challenge`] = obj;
|
||||
addition[`long_otobear_fes_1`] = {
|
||||
term: K.ITEM('u8', 0),
|
||||
start_date_ms: K.ITEM('u64', time),
|
||||
end_date_ms: K.ITEM('u64', time),
|
||||
bonus_musicid: {},
|
||||
};
|
||||
addition[`sdvx_stamprally3`] = obj;
|
||||
addition[`chronicle_1`] = obj;
|
||||
addition[`paseli_point_lottery`] = obj;
|
||||
addition['sticker_campaign'] = {
|
||||
term: K.ITEM('u8', 0),
|
||||
sticker_list: {},
|
||||
};
|
||||
addition['thanksgiving'] = {
|
||||
...obj,
|
||||
box_term: {
|
||||
state: K.ITEM('u8', 0)
|
||||
}
|
||||
};
|
||||
addition['lotterybox'] = {
|
||||
...obj,
|
||||
box_term: {
|
||||
state: K.ITEM('u8', 0)
|
||||
}
|
||||
};
|
||||
} else {
|
||||
|
||||
addition[`phrase_combo_challenge_${i}`] = obj;
|
||||
}
|
||||
|
||||
if (i <= 4) {
|
||||
addition['monstar_subjugation'][`monstar_subjugation_${i}`] = obj;
|
||||
addition['bear_fes'][`bear_fes_${i}`] = obj;
|
||||
}
|
||||
|
||||
if (i <= 3) {
|
||||
addition[`kouyou_challenge_${i}`] = {
|
||||
term: K.ITEM('u8', 0),
|
||||
bonus_musicid: K.ITEM('s32', 0),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return addition
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import { Record } from "../models/record";
|
||||
import { Extra } from "../models/extra";
|
||||
import { getVersion, isDM } from "../utils";
|
||||
import { Scores } from "../models/scores";
|
||||
import { PlayerStickerResponse } from "../models/playerstickerresponse";
|
||||
import { SecretMusicResponse } from "../models/secretmusicresponse";
|
||||
import { PLUGIN_VER } from "../const";
|
||||
import Logger from "../utils/logger"
|
||||
import { isAsphyxiaDebugMode } from "../Utils/index";
|
||||
@@ -230,38 +232,7 @@ export const getPlayer: EPR = async (info, data, send) => {
|
||||
}));
|
||||
}
|
||||
|
||||
const sticker: any[] = [];
|
||||
|
||||
if (_.isArray(name.card)) {
|
||||
for (const item of name.card) {
|
||||
const id = _.get(item, 'id');
|
||||
const posX = _.get(item, 'position.0');
|
||||
const posY = _.get(item, 'position.1');
|
||||
const scaleX = _.get(item, 'scale.0');
|
||||
const scaleY = _.get(item, 'scale.1');
|
||||
const rotation = _.get(item, 'rotation');
|
||||
|
||||
if (
|
||||
!isFinite(id) ||
|
||||
!isFinite(posX) ||
|
||||
!isFinite(posY) ||
|
||||
!isFinite(scaleX) ||
|
||||
!isFinite(scaleY) ||
|
||||
!isFinite(rotation)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
sticker.push({
|
||||
id: K.ITEM('s32', id),
|
||||
pos_x: K.ITEM('float', posX),
|
||||
pos_y: K.ITEM('float', posY),
|
||||
scale_x: K.ITEM('float', scaleX),
|
||||
scale_y: K.ITEM('float', scaleY),
|
||||
rotate: K.ITEM('float', rotation),
|
||||
});
|
||||
}
|
||||
}
|
||||
const sticker: PlayerStickerResponse[] = getPlayerStickers(name.card);
|
||||
|
||||
const playerData: any = {
|
||||
playerboard: {
|
||||
@@ -376,6 +347,7 @@ export const getPlayer: EPR = async (info, data, send) => {
|
||||
}
|
||||
|
||||
const innerSecretMusic = getSecretMusicResponse(profile)
|
||||
const innerFriendData = getFriendDataResponse(profile)
|
||||
|
||||
const response = {
|
||||
player: K.ATTR({ 'no': `${no}` }, {
|
||||
@@ -392,7 +364,10 @@ export const getPlayer: EPR = async (info, data, send) => {
|
||||
status: K.ARRAY('u32', extra.reward_status ?? Array(50).fill(0)),
|
||||
},
|
||||
rivaldata: {},
|
||||
frienddata: {},
|
||||
frienddata: {
|
||||
friend: innerFriendData
|
||||
},
|
||||
|
||||
thanks_medal: {
|
||||
medal: K.ITEM('s32', 0),
|
||||
grant_medal: K.ITEM('s32', 0),
|
||||
@@ -527,6 +502,42 @@ export const getPlayer: EPR = async (info, data, send) => {
|
||||
send.object(response);
|
||||
}
|
||||
|
||||
function getPlayerStickers(playerCard) : PlayerStickerResponse[] {
|
||||
let stickers : PlayerStickerResponse[] = []
|
||||
if (_.isArray(playerCard)) {
|
||||
for (const item of playerCard) {
|
||||
const id = _.get(item, 'id');
|
||||
const posX = _.get(item, 'position.0');
|
||||
const posY = _.get(item, 'position.1');
|
||||
const scaleX = _.get(item, 'scale.0');
|
||||
const scaleY = _.get(item, 'scale.1');
|
||||
const rotation = _.get(item, 'rotation');
|
||||
|
||||
if (
|
||||
!isFinite(id) ||
|
||||
!isFinite(posX) ||
|
||||
!isFinite(posY) ||
|
||||
!isFinite(scaleX) ||
|
||||
!isFinite(scaleY) ||
|
||||
!isFinite(rotation)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
stickers.push({
|
||||
id: K.ITEM('s32', id),
|
||||
pos_x: K.ITEM('float', posX),
|
||||
pos_y: K.ITEM('float', posY),
|
||||
scale_x: K.ITEM('float', scaleX),
|
||||
scale_y: K.ITEM('float', scaleY),
|
||||
rotate: K.ITEM('float', rotation),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return stickers
|
||||
}
|
||||
|
||||
async function getOrRegisterPlayerInfo(refid: string, version: string, no: number) {
|
||||
let playerInfo = await DB.FindOne<PlayerInfo>(refid, {
|
||||
collection: 'playerinfo',
|
||||
@@ -953,6 +964,8 @@ async function saveSinglePlayer(dataplayer: KDataReader, refid: string, no: numb
|
||||
await DB.Upsert(refid, { collection: 'extra', game, version }, extra)
|
||||
|
||||
const playedStages = dataplayer.elements('stage');
|
||||
// logStagesPlayed(playedStages)
|
||||
|
||||
const scores = await updatePlayerScoreCollection(refid, playedStages, version, game)
|
||||
await saveScore(refid, version, game, scores);
|
||||
}
|
||||
@@ -1122,8 +1135,8 @@ function parseSecretMusic(playerData: KDataReader) : SecretMusicEntry[]
|
||||
return response
|
||||
}
|
||||
|
||||
function getSecretMusicResponse(profile: Profile) {
|
||||
let response = []
|
||||
function getSecretMusicResponse(profile: Profile) : SecretMusicResponse[] {
|
||||
let response : SecretMusicResponse[] = []
|
||||
|
||||
if (!profile.secretmusic?.music ) {
|
||||
return response
|
||||
@@ -1140,3 +1153,19 @@ function getSecretMusicResponse(profile: Profile) {
|
||||
return response
|
||||
}
|
||||
|
||||
function getFriendDataResponse(profile: Profile) {
|
||||
let response = []
|
||||
return response;
|
||||
}
|
||||
|
||||
function logStagesPlayed(playedStages: KDataReader[]) {
|
||||
|
||||
let result = "Stages played: "
|
||||
for (let stage of playedStages) {
|
||||
let id = stage.number('musicid')
|
||||
result += `${id}, `
|
||||
}
|
||||
|
||||
logger.debugLog(result)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user