diff --git a/SharedProject/Models/SongIntroductionData.cs b/SharedProject/Models/SongIntroductionData.cs new file mode 100644 index 0000000..fe6f82a --- /dev/null +++ b/SharedProject/Models/SongIntroductionData.cs @@ -0,0 +1,18 @@ +using System.Text.Json.Serialization; + +namespace SharedProject.Models; + +public class SongIntroductionData +{ + [JsonPropertyName("setId")] + public uint SetId { get; set; } + + [JsonPropertyName("verupNo")] + public uint VerupNo { get; set; } + + [JsonPropertyName("mainSongNo")] + public uint MainSongNo { get; set; } + + [JsonPropertyName("subSongNo")] + public uint[]? SubSongNo { get; set; } +} \ No newline at end of file diff --git a/TaikoLocalServer/Common/Constants.cs b/TaikoLocalServer/Common/Constants.cs index 427594e..665423c 100644 --- a/TaikoLocalServer/Common/Constants.cs +++ b/TaikoLocalServer/Common/Constants.cs @@ -24,6 +24,8 @@ public static class Constants public const string DAN_DATA_FILE_NAME = "dan_data.json"; + public const string INTRO_DATA_FILE_NAME = "intro_data.json"; + public const int MIN_DAN_ID = 1; public const int MAX_DAN_ID = 19; public const int GOT_DAN_BITS = MAX_DAN_ID * 4; diff --git a/TaikoLocalServer/Common/Utils/SongIntroductionDataManager.cs b/TaikoLocalServer/Common/Utils/SongIntroductionDataManager.cs new file mode 100644 index 0000000..abbb329 --- /dev/null +++ b/TaikoLocalServer/Common/Utils/SongIntroductionDataManager.cs @@ -0,0 +1,42 @@ +using System.Collections.Immutable; +using System.Text.Json; +using SharedProject.Models; + +namespace TaikoLocalServer.Common.Utils; + +public class SongIntroductionDataManager +{ + public ImmutableDictionary IntroDataList { get; } + + static SongIntroductionDataManager() { } + + private SongIntroductionDataManager() + { + var dataPath = PathHelper.GetDataPath(); + var filePath = Path.Combine(dataPath, Constants.INTRO_DATA_FILE_NAME); + var jsonString = File.ReadAllText(filePath); + + var result = JsonSerializer.Deserialize>(jsonString); + + if (result is null) + { + throw new ApplicationException("Cannot parse intro data json!"); + } + + IntroDataList = result.ToImmutableDictionary(data => data.SetId, ToResponseIntroData); + } + private GetSongIntroductionResponse.SongIntroductionData ToResponseIntroData(SongIntroductionData data) + { + var responseOdaiData = new GetSongIntroductionResponse.SongIntroductionData + { + SetId = data.SetId, + VerupNo = data.VerupNo, + MainSongNo = data.MainSongNo, + SubSongNoes = data.SubSongNo + }; + + return responseOdaiData; + } + + public static SongIntroductionDataManager Instance { get; } = new(); +} \ No newline at end of file diff --git a/TaikoLocalServer/Controllers/Game/GetSongIntroductionController.cs b/TaikoLocalServer/Controllers/Game/GetSongIntroductionController.cs index 15d3215..9353c8a 100644 --- a/TaikoLocalServer/Controllers/Game/GetSongIntroductionController.cs +++ b/TaikoLocalServer/Controllers/Game/GetSongIntroductionController.cs @@ -15,15 +15,17 @@ public class GetSongIntroductionController : BaseController(); + for (var setId = 1; setId <= manager.IntroDataList.Count; setId++) + { + introData.Add(new InitialdatacheckResponse.InformationData + { + InfoId = (uint)setId, + VerupNo = 1 + }); + } var response = new InitialdatacheckResponse { @@ -100,6 +111,7 @@ public class InitialDataCheckController : BaseController