From 64e3d1871e99a0f3cc47651751ddc5261b24af9a Mon Sep 17 00:00:00 2001 From: DitFranXX Date: Wed, 2 Dec 2020 00:14:37 +0900 Subject: [PATCH] types for better debug. --- museca@asphyxia/data/helper.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/museca@asphyxia/data/helper.ts b/museca@asphyxia/data/helper.ts index dee658d..4a9c368 100644 --- a/museca@asphyxia/data/helper.ts +++ b/museca@asphyxia/data/helper.ts @@ -1,3 +1,13 @@ +export interface CommonMusicDataField { + music_id: KITEM<"s32">; + music_type: KITEM<"u8">; + limited: KITEM<"u8">; +} + +interface CommonMusicData { + music: CommonMusicDataField[] +} + export async function readXML(path: string) { const xml = await IO.ReadFile(path, 'utf-8'); const json = U.parseXML(xml, false) @@ -10,7 +20,7 @@ export async function readJSON(path: string) { return json } -export async function readJSONOrXML(jsonPath: string, xmlPath: string) { +export async function readJSONOrXML(jsonPath: string, xmlPath: string): Promise { const str: string | null = await IO.ReadFile(jsonPath, 'utf-8'); if (str == null || str.length == 0) { const data = await processMdbData(xmlPath) @@ -22,11 +32,11 @@ export async function readJSONOrXML(jsonPath: string, xmlPath: string) { } } -export async function processMdbData(path: string) { +export async function processMdbData(path: string): Promise { const data = await readXML(path); const mdb = $(data).elements("mdb.music"); const diff_list = ["novice", "advanced", "exhaust", "infinite"] - const music: any[] = []; + const music: CommonMusicDataField[] = []; for (const m of mdb) { for (const [i, d] of diff_list.entries()) { const elem = m.element(`difficulty.${d}`)