Merge branch 'stable' into feature/00_sharedFavorites

# Conflicts:
#	gitadora@asphyxia/README.md
#	gitadora@asphyxia/handlers/profiles.ts
This commit is contained in:
Thome Valentin
2022-05-17 09:21:32 +02:00
17 changed files with 449 additions and 371 deletions
+5
View File
@@ -29,6 +29,11 @@ Known Issues
Release Notes Release Notes
============= =============
v1.2.4
----------------
* Fixed note scroll speed defaulting to 0.5x for newly registered profiles.
* Misc code cleanup. No changes expected to plugin behaviour.
v1.3.0 v1.3.0
---------------- ----------------
* Added experimental 'Shared Favorite Songs' option. If disabled, players will be able to keep separate lists of favorite songs for each version of Gitadora, as well as between Guitar Freaks and Drummania. Enable this option to have a single unified list of favorite songs for both games, and across all versions. Default is false, to match original arcade behaviour. * Added experimental 'Shared Favorite Songs' option. If disabled, players will be able to keep separate lists of favorite songs for each version of Gitadora, as well as between Guitar Freaks and Drummania. Enable this option to have a single unified list of favorite songs for both games, and across all versions. Default is false, to match original arcade behaviour.
+2 -1
View File
@@ -7,4 +7,5 @@ mt.json
nt.json nt.json
hv.json hv.json
custom.xml custom.xml
custom.json custom.json
blacklist.txt
+7 -13
View File
@@ -2,12 +2,13 @@ import { getVersion } from "../utils";
import { findMDBFile, readMDBFile, loadSongsForGameVersion } from "../data/mdb"; import { findMDBFile, readMDBFile, loadSongsForGameVersion } from "../data/mdb";
import { CommonMusicDataField } from "../models/commonmusicdata"; import { CommonMusicDataField } from "../models/commonmusicdata";
import Logger from "../utils/logger" import Logger from "../utils/logger"
import { getPlayableMusicResponse, PlayableMusicResponse } from "../models/Responses/playablemusicresponse";
const logger = new Logger("MusicList") const logger = new Logger("MusicList")
export const playableMusic: EPR = async (info, data, send) => { export const playableMusic: EPR = async (info, data, send) => {
const version = getVersion(info); const version = getVersion(info);
const start = Date.now()
let music: CommonMusicDataField[] = []; let music: CommonMusicDataField[] = [];
try { try {
if (U.GetConfig("enable_custom_mdb")) { if (U.GetConfig("enable_custom_mdb")) {
@@ -24,18 +25,11 @@ export const playableMusic: EPR = async (info, data, send) => {
music = (await loadSongsForGameVersion(version)).music music = (await loadSongsForGameVersion(version)).music
} }
let response = getPlayableMusicResponse(music) const end = Date.now()
const timeDiff = end - start
logger.debugInfo(`MDB loading took ${timeDiff} ms`)
let response : PlayableMusicResponse = getPlayableMusicResponse(music)
await send.object(response) await send.object(response)
}; };
function getPlayableMusicResponse(music) {
return {
hot: {
major: K.ITEM('s32', 1),
minor: K.ITEM('s32', 1),
},
musicinfo: K.ATTR({ nr: `${music.length}` }, {
music,
}),
}
}
+26 -340
View File
@@ -1,16 +1,20 @@
import { PlayerInfo } from "../models/playerinfo"; import { getDefaultPlayerInfo, PlayerInfo } from "../models/playerinfo";
import { PlayerRanking } from "../models/playerranking"; import { PlayerRanking } from "../models/playerranking";
import { Profile } from "../models/profile"; import { getDefaultProfile, Profile } from "../models/profile";
import { Record } from "../models/record"; import { getDefaultRecord, Record } from "../models/record";
import { Extra } from "../models/extra"; import { Extra, getDefaultExtra } from "../models/extra";
import { getVersion, isDM } from "../utils"; import { getVersion, isDM } from "../utils";
import { Scores } from "../models/scores"; import { getDefaultScores, Scores } from "../models/scores";
import { PlayerStickerResponse } from "../models/playerstickerresponse";
import { SecretMusicResponse } from "../models/secretmusicresponse";
import { PLUGIN_VER } from "../const"; import { PLUGIN_VER } from "../const";
import Logger from "../utils/logger" import Logger from "../utils/logger"
import { isAsphyxiaDebugMode } from "../Utils/index"; import { isAsphyxiaDebugMode } from "../Utils/index";
import { SecretMusicEntry } from "../models/secretmusicentry"; import { SecretMusicEntry } from "../models/secretmusicentry";
import { CheckPlayerResponse, getCheckPlayerResponse } from "../models/Responses/checkplayerresponse";
import { getPlayerStickerResponse, PlayerStickerResponse } from "../models/Responses/playerstickerresponse";
import { getSecretMusicResponse, SecretMusicResponse } from "../models/Responses/secretmusicresponse";
import { getSaveProfileResponse } from "../models/Responses/saveprofileresponse";
import { getDefaultBattleDataResponse } from "../models/Responses/battledataresponse";
import { applySharedFavoriteMusicToExtra, saveSharedFavoriteMusicFromExtra } from "./FavoriteMusic"; import { applySharedFavoriteMusicToExtra, saveSharedFavoriteMusicFromExtra } from "./FavoriteMusic";
const logger = new Logger("profiles") const logger = new Logger("profiles")
@@ -48,19 +52,8 @@ export const check: EPR = async (info, data, send) => {
const version = getVersion(info) const version = getVersion(info)
const playerInfo = await getOrRegisterPlayerInfo(refid, version, no) const playerInfo = await getOrRegisterPlayerInfo(refid, version, no)
await send.object({ const result : CheckPlayerResponse = getCheckPlayerResponse(no, playerInfo.name, playerInfo.id)
player: K.ATTR({ no: `${no}`, state: '2' }, { await send.object(result)
name: K.ITEM('str', playerInfo.name),
charaid: K.ITEM('s32', 0),
did: K.ITEM('s32', playerInfo.id),
skilldata: {
skill: K.ITEM('s32', 0),
all_skill: K.ITEM('s32', 0),
old_skill: K.ITEM('s32', 0),
old_all_skill: K.ITEM('s32', 0),
}
})
})
} }
export const getPlayer: EPR = async (info, data, send) => { export const getPlayer: EPR = async (info, data, send) => {
@@ -235,7 +228,7 @@ export const getPlayer: EPR = async (info, data, send) => {
})); }));
} }
const sticker: PlayerStickerResponse[] = getPlayerStickers(name.card); const sticker: PlayerStickerResponse[] = getPlayerStickerResponse(name.card);
const playerData: any = { const playerData: any = {
playerboard: { playerboard: {
@@ -351,6 +344,7 @@ export const getPlayer: EPR = async (info, data, send) => {
const innerSecretMusic = getSecretMusicResponse(profile) const innerSecretMusic = getSecretMusicResponse(profile)
const innerFriendData = getFriendDataResponse(profile) const innerFriendData = getFriendDataResponse(profile)
const innerBattleData = getDefaultBattleDataResponse()
const response = { const response = {
player: K.ATTR({ 'no': `${no}` }, { player: K.ATTR({ 'no': `${no}` }, {
@@ -380,42 +374,7 @@ export const getPlayer: EPR = async (info, data, send) => {
skindata: { skindata: {
skin: K.ARRAY('u32', Array(100).fill(-1)), skin: K.ARRAY('u32', Array(100).fill(-1)),
}, },
battledata: { battledata: innerBattleData,
info: {
orb: K.ITEM('s32', 0),
get_gb_point: K.ITEM('s32', 0),
send_gb_point: K.ITEM('s32', 0),
},
greeting: {
greeting_1: K.ITEM('str', ''),
greeting_2: K.ITEM('str', ''),
greeting_3: K.ITEM('str', ''),
greeting_4: K.ITEM('str', ''),
greeting_5: K.ITEM('str', ''),
greeting_6: K.ITEM('str', ''),
greeting_7: K.ITEM('str', ''),
greeting_8: K.ITEM('str', ''),
greeting_9: K.ITEM('str', ''),
},
setting: {
matching: K.ITEM('s32', 0),
info_level: K.ITEM('s32', 0),
},
score: {
battle_class: K.ITEM('s32', 0),
max_battle_class: K.ITEM('s32', 0),
battle_point: K.ITEM('s32', 0),
win: K.ITEM('s32', 0),
lose: K.ITEM('s32', 0),
draw: K.ITEM('s32', 0),
consecutive_win: K.ITEM('s32', 0),
max_consecutive_win: K.ITEM('s32', 0),
glorious_win: K.ITEM('s32', 0),
max_defeat_skill: K.ITEM('s32', 0),
latest_result: K.ITEM('s32', 0),
},
history: {},
},
is_free_ok: K.ITEM('bool', 0), is_free_ok: K.ITEM('bool', 0),
ranking: { ranking: {
skill: { rank: K.ITEM('s32', playerRanking.skill), total_nr: K.ITEM('s32', playerRanking.totalPlayers) }, skill: { rank: K.ITEM('s32', playerRanking.skill), total_nr: K.ITEM('s32', playerRanking.totalPlayers) },
@@ -505,42 +464,6 @@ export const getPlayer: EPR = async (info, data, send) => {
send.object(response); 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) { async function getOrRegisterPlayerInfo(refid: string, version: string, no: number) {
let playerInfo = await DB.FindOne<PlayerInfo>(refid, { let playerInfo = await DB.FindOne<PlayerInfo>(refid, {
collection: 'playerinfo', collection: 'playerinfo',
@@ -559,221 +482,24 @@ function getPlayerNo(data: any): number {
} }
async function registerUser(refid: string, version: string, id = _.random(0, 99999999)) { async function registerUser(refid: string, version: string, id = _.random(0, 99999999)) {
while (await DB.FindOne<PlayerInfo>(null, { collecttion: 'profile', id })) { while (await DB.FindOne<Profile>(null, { collection: 'profile', id })) {
id = _.random(0, 99999999); id = _.random(0, 99999999);
} }
const defaultInfo: PlayerInfo = { const defaultInfo: PlayerInfo = getDefaultPlayerInfo(version, id)
collection: 'playerinfo',
pluginVer: PLUGIN_VER,
id,
version,
name: 'ASPHYXIA-CORE USER',
title: 'Please edit on WebUI',
}
const defaultProfile = (game: 'gf' | 'dm'): Profile => {
return {
collection: 'profile',
pluginVer: PLUGIN_VER,
game,
version,
id,
play: 0,
playtime: 0,
playterm: 0,
session_cnt: 0,
extra_stage: 0,
extra_play: 0,
extra_clear: 0,
encore_play: 0,
encore_clear: 0,
pencore_play: 0,
pencore_clear: 0,
max_clear_diff: 0,
max_full_diff: 0,
max_exce_diff: 0,
clear_num: 0,
full_num: 0,
exce_num: 0,
no_num: 0,
e_num: 0,
d_num: 0,
c_num: 0,
b_num: 0,
a_num: 0,
s_num: 0,
ss_num: 0,
last_category: 0,
last_musicid: -1,
last_seq: 0,
disp_level: 0,
progress: 0,
disp_state: 0,
skill: 0,
all_skill: 0,
extra_gauge: 0,
encore_gauge: 0,
encore_cnt: 0,
encore_success: 0,
unlock_point: 0,
max_skill: 0,
max_all_skill: 0,
clear_diff: 0,
full_diff: 0,
exce_diff: 0,
clear_music_num: 0,
full_music_num: 0,
exce_music_num: 0,
clear_seq_num: 0,
classic_all_skill: 0,
secretmusic: {
music: []
}
}
};
const defaultRecord = (game: 'gf' | 'dm'): Record => {
return {
collection: 'record',
pluginVer: PLUGIN_VER,
game,
version,
diff_100_nr: 0,
diff_150_nr: 0,
diff_200_nr: 0,
diff_250_nr: 0,
diff_300_nr: 0,
diff_350_nr: 0,
diff_400_nr: 0,
diff_450_nr: 0,
diff_500_nr: 0,
diff_550_nr: 0,
diff_600_nr: 0,
diff_650_nr: 0,
diff_700_nr: 0,
diff_750_nr: 0,
diff_800_nr: 0,
diff_850_nr: 0,
diff_900_nr: 0,
diff_950_nr: 0,
diff_100_clear: [0, 0, 0, 0, 0, 0, 0],
diff_150_clear: [0, 0, 0, 0, 0, 0, 0],
diff_200_clear: [0, 0, 0, 0, 0, 0, 0],
diff_250_clear: [0, 0, 0, 0, 0, 0, 0],
diff_300_clear: [0, 0, 0, 0, 0, 0, 0],
diff_350_clear: [0, 0, 0, 0, 0, 0, 0],
diff_400_clear: [0, 0, 0, 0, 0, 0, 0],
diff_450_clear: [0, 0, 0, 0, 0, 0, 0],
diff_500_clear: [0, 0, 0, 0, 0, 0, 0],
diff_550_clear: [0, 0, 0, 0, 0, 0, 0],
diff_600_clear: [0, 0, 0, 0, 0, 0, 0],
diff_650_clear: [0, 0, 0, 0, 0, 0, 0],
diff_700_clear: [0, 0, 0, 0, 0, 0, 0],
diff_750_clear: [0, 0, 0, 0, 0, 0, 0],
diff_800_clear: [0, 0, 0, 0, 0, 0, 0],
diff_850_clear: [0, 0, 0, 0, 0, 0, 0],
diff_900_clear: [0, 0, 0, 0, 0, 0, 0],
diff_950_clear: [0, 0, 0, 0, 0, 0, 0],
}
}
const defaultExtra = (game: 'gf' | 'dm'): Extra => {
return {
collection: 'extra',
pluginVer: PLUGIN_VER,
game,
version,
id,
playstyle: [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
20,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
20,
0,
],
custom: Array(50).fill(0),
list_1: Array(100).fill(-1),
list_2: Array(100).fill(-1),
list_3: Array(100).fill(-1),
recommend_musicid_list: Array(5).fill(-1),
reward_status: Array(50).fill(0),
}
}
const defaultScores = (game: 'gf' | 'dm'): Scores => {
return {
collection: 'scores',
version,
pluginVer: PLUGIN_VER,
game,
scores: {}
}
};
const gf = { game: 'gf', version }; const gf = { game: 'gf', version };
const dm = { game: 'dm', version }; const dm = { game: 'dm', version };
await DB.Upsert(refid, { collection: 'playerinfo', version }, defaultInfo); await DB.Upsert(refid, { collection: 'playerinfo', version }, defaultInfo);
await DB.Upsert(refid, { collection: 'profile', ...gf }, defaultProfile('gf')); await DB.Upsert(refid, { collection: 'profile', ...gf }, getDefaultProfile('gf', version, id));
await DB.Upsert(refid, { collection: 'profile', ...dm }, defaultProfile('dm')); await DB.Upsert(refid, { collection: 'profile', ...dm }, getDefaultProfile('dm', version, id));
await DB.Upsert(refid, { collection: 'record', ...gf }, defaultRecord('gf')); await DB.Upsert(refid, { collection: 'record', ...gf }, getDefaultRecord('gf', version));
await DB.Upsert(refid, { collection: 'record', ...dm }, defaultRecord('dm')); await DB.Upsert(refid, { collection: 'record', ...dm }, getDefaultRecord('dm', version));
await DB.Upsert(refid, { collection: 'extra', ...gf }, defaultExtra('gf')); await DB.Upsert(refid, { collection: 'extra', ...gf }, getDefaultExtra('gf', version, id));
await DB.Upsert(refid, { collection: 'extra', ...dm }, defaultExtra('dm')); await DB.Upsert(refid, { collection: 'extra', ...dm }, getDefaultExtra('dm', version, id));
await DB.Upsert(refid, { collection: 'scores', ...gf }, defaultScores('gf')); await DB.Upsert(refid, { collection: 'scores', ...gf }, getDefaultScores('gf', version));
await DB.Upsert(refid, { collection: 'scores', ...dm }, defaultScores('dm')); await DB.Upsert(refid, { collection: 'scores', ...dm }, getDefaultScores('dm', version));
return defaultInfo return defaultInfo
} }
@@ -1039,27 +765,6 @@ async function getPlayerRanking(refid: string, version: string, game: 'gf' | 'dm
} }
} }
function getSaveProfileResponse(playerNo: number, ranking : PlayerRanking)
{
const result = K.ATTR({ no: `${playerNo}` }, {
skill: { rank: K.ITEM('s32', ranking.skill), total_nr: K.ITEM('s32', ranking.totalPlayers) },
all_skill: { rank: K.ITEM('s32', ranking.all_skill), total_nr: K.ITEM('s32', ranking.totalPlayers) },
kac2018: {
data: {
term: K.ITEM('s32', 0),
total_score: K.ITEM('s32', 0),
score: K.ARRAY('s32', [0, 0, 0, 0, 0, 0]),
music_type: K.ARRAY('s32', [0, 0, 0, 0, 0, 0]),
play_count: K.ARRAY('s32', [0, 0, 0, 0, 0, 0]),
},
},
})
return result
}
async function getAllProfiles( version: string, game: 'gf' | 'dm') { async function getAllProfiles( version: string, game: 'gf' | 'dm') {
return await DB.Find<Profile>(null, { return await DB.Find<Profile>(null, {
collection: 'profile', collection: 'profile',
@@ -1140,24 +845,6 @@ function parseSecretMusic(playerData: KDataReader) : SecretMusicEntry[]
return response return response
} }
function getSecretMusicResponse(profile: Profile) : SecretMusicResponse[] {
let response : SecretMusicResponse[] = []
if (!profile.secretmusic?.music ) {
return response
}
for (let music of profile.secretmusic.music) {
response.push({
musicid: K.ITEM('s32', music.musicid),
seq: K.ITEM('u16', music.seq),
kind: K.ITEM('s32', music.kind)
})
}
return response
}
function getFriendDataResponse(profile: Profile) { function getFriendDataResponse(profile: Profile) {
let response = [] let response = []
return response; return response;
@@ -1173,4 +860,3 @@ function logStagesPlayed(playedStages: KDataReader[]) {
logger.debugLog(result) logger.debugLog(result)
} }
@@ -0,0 +1,79 @@
export interface BattleDataResponse
{
info: {
orb: KITEM<'s32'>,
get_gb_point: KITEM<'s32'>,
send_gb_point: KITEM<'s32'>,
}
greeting: {
greeting_1: KITEM<'str'>,
greeting_2: KITEM<'str'>,
greeting_3: KITEM<'str'>,
greeting_4: KITEM<'str'>,
greeting_5: KITEM<'str'>,
greeting_6: KITEM<'str'>,
greeting_7: KITEM<'str'>,
greeting_8: KITEM<'str'>,
greeting_9: KITEM<'str'>,
}
setting: {
matching: KITEM<'s32'>,
info_level: KITEM<'s32'>,
}
score: {
battle_class: KITEM<'s32'>,
max_battle_class: KITEM<'s32'>,
battle_point: KITEM<'s32'>,
win: KITEM<'s32'>,
lose: KITEM<'s32'>,
draw: KITEM<'s32'>,
consecutive_win: KITEM<'s32'>,
max_consecutive_win: KITEM<'s32'>,
glorious_win: KITEM<'s32'>,
max_defeat_skill: KITEM<'s32'>,
latest_result: KITEM<'s32'>,
}
history: {}
}
export function getDefaultBattleDataResponse() : BattleDataResponse {
return {
info: {
orb: K.ITEM('s32', 0),
get_gb_point: K.ITEM('s32', 0),
send_gb_point: K.ITEM('s32', 0),
},
greeting: {
greeting_1: K.ITEM('str', ''),
greeting_2: K.ITEM('str', ''),
greeting_3: K.ITEM('str', ''),
greeting_4: K.ITEM('str', ''),
greeting_5: K.ITEM('str', ''),
greeting_6: K.ITEM('str', ''),
greeting_7: K.ITEM('str', ''),
greeting_8: K.ITEM('str', ''),
greeting_9: K.ITEM('str', ''),
},
setting: {
matching: K.ITEM('s32', 0),
info_level: K.ITEM('s32', 0),
},
score: {
battle_class: K.ITEM('s32', 0),
max_battle_class: K.ITEM('s32', 0),
battle_point: K.ITEM('s32', 0),
win: K.ITEM('s32', 0),
lose: K.ITEM('s32', 0),
draw: K.ITEM('s32', 0),
consecutive_win: K.ITEM('s32', 0),
max_consecutive_win: K.ITEM('s32', 0),
glorious_win: K.ITEM('s32', 0),
max_defeat_skill: K.ITEM('s32', 0),
latest_result: K.ITEM('s32', 0),
},
history: {},
}
}
@@ -0,0 +1,30 @@
export interface CheckPlayerResponse {
player: {
name: KITEM<'str'>,
charaid: KITEM<'s32'>,
did: KITEM<'s32'>,
skilldata: {
skill: KITEM<'s32'>
all_skill: KITEM<'s32'>
old_skill: KITEM<'s32'>
old_all_skill: KITEM<'s32'>
},
}
}
export function getCheckPlayerResponse(playerNo : number, name: string, id: number) : CheckPlayerResponse
{
return {
player: K.ATTR({ no: `${playerNo}`, state: '2' }, {
name: K.ITEM('str', name),
charaid: K.ITEM('s32', 0),
did: K.ITEM('s32', id),
skilldata: {
skill: K.ITEM('s32', 0),
all_skill: K.ITEM('s32', 0),
old_skill: K.ITEM('s32', 0),
old_all_skill: K.ITEM('s32', 0),
}
})
}
}
@@ -0,0 +1,22 @@
import { CommonMusicDataField } from "../commonmusicdata"
export interface PlayableMusicResponse
{
hot: {
major: KITEM<'s32'>,
minor: KITEM<'s32'>
}
musicinfo: KATTR<any>
}
export function getPlayableMusicResponse(music : CommonMusicDataField[]) : PlayableMusicResponse {
return {
hot: {
major: K.ITEM('s32', 1),
minor: K.ITEM('s32', 1),
},
musicinfo: K.ATTR({ nr: `${music.length}` }, {
music,
}),
}
}
@@ -0,0 +1,46 @@
export interface PlayerStickerResponse {
id: KITEM<'s32'>,
pos_x: KITEM<'float'> ,
pos_y: KITEM<'float'>,
scale_x: KITEM<'float'> ,
scale_y: KITEM<'float'>,
rotate: KITEM<'float'>
}
export function getPlayerStickerResponse(playerCard : any[]) : PlayerStickerResponse[] {
let stickers : PlayerStickerResponse[] = []
if (!_.isArray(playerCard)) {
return stickers
}
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
}
@@ -0,0 +1,41 @@
import { PlayerRanking } from "../playerranking"
export interface SaveProfileResponse
{
skill: {
rank: KITEM<'s32'>,
total_nr: KITEM<'s32'>
}
all_skill: {
rank: KITEM<'s32'>,
total_nr: KITEM<'s32'>
}
kac2018: {
data: {
term: KITEM<'s32'>,
total_score: KITEM<'s32'>,
score: KARRAY<'s32'>,
music_type: KARRAY<'s32'>,
play_count: KARRAY<'s32'>
}
}
}
export function getSaveProfileResponse(playerNo: number, ranking : PlayerRanking)
{
const result : SaveProfileResponse = K.ATTR({ no: `${playerNo}` }, {
skill: { rank: K.ITEM('s32', ranking.skill), total_nr: K.ITEM('s32', ranking.totalPlayers) },
all_skill: { rank: K.ITEM('s32', ranking.all_skill), total_nr: K.ITEM('s32', ranking.totalPlayers) },
kac2018: {
data: {
term: K.ITEM('s32', 0),
total_score: K.ITEM('s32', 0),
score: K.ARRAY('s32', [0, 0, 0, 0, 0, 0]),
music_type: K.ARRAY('s32', [0, 0, 0, 0, 0, 0]),
play_count: K.ARRAY('s32', [0, 0, 0, 0, 0, 0]),
},
},
})
return result
}
@@ -0,0 +1,25 @@
import { Profile } from "../profile";
export interface SecretMusicResponse {
musicid: KITEM<'s32'>;
seq: KITEM<'u16'>;
kind: KITEM<'s32'>;
}
export function getSecretMusicResponse(profile: Profile) : SecretMusicResponse[] {
let response : SecretMusicResponse[] = []
if (!profile.secretmusic?.music ) {
return response
}
for (let music of profile.secretmusic.music) {
response.push({
musicid: K.ITEM('s32', music.musicid),
seq: K.ITEM('u16', music.seq),
kind: K.ITEM('s32', music.kind)
})
}
return response
}
+26 -1
View File
@@ -1,3 +1,5 @@
import { PLUGIN_VER } from "../const";
export interface Extra { export interface Extra {
collection: 'extra'; collection: 'extra';
@@ -13,4 +15,27 @@ export interface Extra {
list_3: number[]; list_3: number[];
recommend_musicid_list: number[]; recommend_musicid_list: number[];
reward_status: number[]; reward_status: number[];
} }
export function getDefaultExtra(game: 'gf' | 'dm', version: string, id: number) : Extra {
const result : Extra = {
collection: 'extra',
pluginVer: PLUGIN_VER,
game,
version,
id,
playstyle: Array(50).fill(0),
custom: Array(50).fill(0),
list_1: Array(100).fill(-1),
list_2: Array(100).fill(-1),
list_3: Array(100).fill(-1),
recommend_musicid_list: Array(5).fill(-1),
reward_status: Array(50).fill(0),
}
result.playstyle[1] = 1 // Note scroll speed (should default to 1.0x)
result.playstyle[36] = 20 // Unknown
result.playstyle[48] = 20 // Unknown
return result
}
+15 -2
View File
@@ -1,7 +1,9 @@
import { PLUGIN_VER } from "../const";
export interface PlayerInfo { export interface PlayerInfo {
collection: 'playerinfo', collection: 'playerinfo',
pluginVer: Number; pluginVer: number;
id: number; id: number;
version: string, version: string,
@@ -16,4 +18,15 @@ export interface PlayerInfo {
}[]; }[];
// TODO: Add Board things. // TODO: Add Board things.
} }
export function getDefaultPlayerInfo(version: string, id: number) : PlayerInfo {
return {
collection: 'playerinfo',
pluginVer: PLUGIN_VER,
id,
version,
name: 'ASPHYXIA-CORE USER',
title: 'Please edit on WebUI',
}
}
@@ -1,8 +0,0 @@
export interface PlayerStickerResponse {
id: KITEM<'s32'>,
pos_x: KITEM<'float'> ,
pos_y: KITEM<'float'>,
scale_x: KITEM<'float'> ,
scale_y: KITEM<'float'>,
rotate: KITEM<'float'>
}
+64
View File
@@ -1,3 +1,4 @@
import { PLUGIN_VER } from "../const";
import { SecretMusicEntry } from "./secretmusicentry"; import { SecretMusicEntry } from "./secretmusicentry";
export interface Profile { export interface Profile {
@@ -60,3 +61,66 @@ export interface Profile {
music: SecretMusicEntry[]; music: SecretMusicEntry[];
} }
} }
export function getDefaultProfile (game: 'gf' | 'dm', version: string, id: number): Profile {
return {
collection: 'profile',
pluginVer: PLUGIN_VER,
game,
version,
id,
play: 0,
playtime: 0,
playterm: 0,
session_cnt: 0,
extra_stage: 0,
extra_play: 0,
extra_clear: 0,
encore_play: 0,
encore_clear: 0,
pencore_play: 0,
pencore_clear: 0,
max_clear_diff: 0,
max_full_diff: 0,
max_exce_diff: 0,
clear_num: 0,
full_num: 0,
exce_num: 0,
no_num: 0,
e_num: 0,
d_num: 0,
c_num: 0,
b_num: 0,
a_num: 0,
s_num: 0,
ss_num: 0,
last_category: 0,
last_musicid: -1,
last_seq: 0,
disp_level: 0,
progress: 0,
disp_state: 0,
skill: 0,
all_skill: 0,
extra_gauge: 0,
encore_gauge: 0,
encore_cnt: 0,
encore_success: 0,
unlock_point: 0,
max_skill: 0,
max_all_skill: 0,
clear_diff: 0,
full_diff: 0,
exce_diff: 0,
clear_music_num: 0,
full_music_num: 0,
exce_music_num: 0,
clear_seq_num: 0,
classic_all_skill: 0,
secretmusic: {
music: []
}
}
};
+49 -1
View File
@@ -1,3 +1,5 @@
import { PLUGIN_VER } from "../const";
export interface Record { export interface Record {
collection: 'record'; collection: 'record';
@@ -41,4 +43,50 @@ export interface Record {
diff_850_clear: number[]; diff_850_clear: number[];
diff_900_clear: number[]; diff_900_clear: number[];
diff_950_clear: number[]; diff_950_clear: number[];
} }
export function getDefaultRecord(game: 'gf' | 'dm', version: string): Record {
return {
collection: 'record',
pluginVer: PLUGIN_VER,
game,
version,
diff_100_nr: 0,
diff_150_nr: 0,
diff_200_nr: 0,
diff_250_nr: 0,
diff_300_nr: 0,
diff_350_nr: 0,
diff_400_nr: 0,
diff_450_nr: 0,
diff_500_nr: 0,
diff_550_nr: 0,
diff_600_nr: 0,
diff_650_nr: 0,
diff_700_nr: 0,
diff_750_nr: 0,
diff_800_nr: 0,
diff_850_nr: 0,
diff_900_nr: 0,
diff_950_nr: 0,
diff_100_clear: [0, 0, 0, 0, 0, 0, 0],
diff_150_clear: [0, 0, 0, 0, 0, 0, 0],
diff_200_clear: [0, 0, 0, 0, 0, 0, 0],
diff_250_clear: [0, 0, 0, 0, 0, 0, 0],
diff_300_clear: [0, 0, 0, 0, 0, 0, 0],
diff_350_clear: [0, 0, 0, 0, 0, 0, 0],
diff_400_clear: [0, 0, 0, 0, 0, 0, 0],
diff_450_clear: [0, 0, 0, 0, 0, 0, 0],
diff_500_clear: [0, 0, 0, 0, 0, 0, 0],
diff_550_clear: [0, 0, 0, 0, 0, 0, 0],
diff_600_clear: [0, 0, 0, 0, 0, 0, 0],
diff_650_clear: [0, 0, 0, 0, 0, 0, 0],
diff_700_clear: [0, 0, 0, 0, 0, 0, 0],
diff_750_clear: [0, 0, 0, 0, 0, 0, 0],
diff_800_clear: [0, 0, 0, 0, 0, 0, 0],
diff_850_clear: [0, 0, 0, 0, 0, 0, 0],
diff_900_clear: [0, 0, 0, 0, 0, 0, 0],
diff_950_clear: [0, 0, 0, 0, 0, 0, 0],
}
}
+12
View File
@@ -1,3 +1,5 @@
import { PLUGIN_VER } from "../const";
export interface Scores { export interface Scores {
collection: 'scores'; collection: 'scores';
@@ -22,3 +24,13 @@ export interface Scores {
}; };
}; };
} }
export function getDefaultScores (game: 'gf' | 'dm', version: string): Scores {
return {
collection: 'scores',
version,
pluginVer: PLUGIN_VER,
game,
scores: {}
}
};
@@ -1,5 +0,0 @@
export interface SecretMusicResponse {
musicid: KITEM<'s32'>;
seq: KITEM<'u16'>;
kind: KITEM<'s32'>;
}