diff --git a/TaikoLocalServer/Controllers/Game/GetDanOdaiController.cs b/TaikoLocalServer/Controllers/Game/GetDanOdaiController.cs index 8819e69..3395fab 100644 --- a/TaikoLocalServer/Controllers/Game/GetDanOdaiController.cs +++ b/TaikoLocalServer/Controllers/Game/GetDanOdaiController.cs @@ -16,29 +16,41 @@ public class GetDanOdaiController : BaseController public IActionResult GetDanOdai([FromBody] GetDanOdaiRequest request) { Logger.LogInformation("GetDanOdai request : {Request}", request.Stringify()); - + var response = new GetDanOdaiResponse { Result = 1 }; - // if (request.Type == 2) - // { - // return Ok(response); - // } - - foreach (var danId in request.DanIds) + if (request.Type == 1) { - gameDataService.GetDanDataDictionary().TryGetValue(danId, out var odaiData); - if (odaiData is null) + foreach (var danId in request.DanIds) { - Logger.LogWarning("Requested dan id {Id} does not exist!", danId); - continue; + gameDataService.GetDanDataDictionary().TryGetValue(danId, out var odaiData); + if (odaiData is null) + { + Logger.LogWarning("Requested dan id {Id} does not exist!", danId); + continue; + } + + response.AryOdaiDatas.Add(odaiData); } - - response.AryOdaiDatas.Add(odaiData); } + else if (request.Type == 2) + { + foreach (var danId in request.DanIds) + { + gameDataService.GetGaidenDataDictionary().TryGetValue(danId, out var odaiData); + if (odaiData is null) + { + Logger.LogWarning("Requested dan id {Id} does not exist!", danId); + continue; + } + response.AryOdaiDatas.Add(odaiData); + } + } + return Ok(response); } } \ No newline at end of file diff --git a/TaikoLocalServer/Controllers/Game/InitialDataCheckController.cs b/TaikoLocalServer/Controllers/Game/InitialDataCheckController.cs index e7fc337..da98de8 100644 --- a/TaikoLocalServer/Controllers/Game/InitialDataCheckController.cs +++ b/TaikoLocalServer/Controllers/Game/InitialDataCheckController.cs @@ -73,11 +73,22 @@ public class InitialDataCheckController : BaseController(); + var gaidenDataDictionary = gameDataService.GetGaidenDataDictionary(); + foreach (var gaidenId in gaidenDataDictionary.Keys) + { + gaidenData.Add(new InitialdatacheckResponse.VerupNoData2.InformationData + { + InfoId = gaidenId, + VerupNo = 1 + }); + } + var verUp2Type102 = new InitialdatacheckResponse.VerupNoData2 { MasterType = 102, }; - verUp2Type102.AryInformationDatas.AddRange(danData); + verUp2Type102.AryInformationDatas.AddRange(gaidenData); response.AryVerupNoData2s.Add(verUp2Type102); var eventFolderData = new List(); diff --git a/TaikoLocalServer/Services/GameDataService.cs b/TaikoLocalServer/Services/GameDataService.cs index 7c411f4..4919602 100644 --- a/TaikoLocalServer/Services/GameDataService.cs +++ b/TaikoLocalServer/Services/GameDataService.cs @@ -17,6 +17,9 @@ public class GameDataService : IGameDataService private ImmutableDictionary danDataDictionary = ImmutableDictionary.Empty; + + private ImmutableDictionary gaidenDataDictionary = + ImmutableDictionary.Empty; private ImmutableDictionary introDataDictionary = ImmutableDictionary.Empty; @@ -72,6 +75,11 @@ public class GameDataService : IGameDataService { return danDataDictionary; } + + public ImmutableDictionary GetGaidenDataDictionary() + { + return gaidenDataDictionary; + } public ImmutableDictionary GetSongIntroDictionary() { @@ -111,6 +119,7 @@ public class GameDataService : IGameDataService var musicAttributePath = Path.Combine(dataPath, Constants.MUSIC_ATTRIBUTE_FILE_NAME); var compressedMusicAttributePath = Path.Combine(dataPath, Constants.MUSIC_ATTRIBUTE_COMPRESSED_FILE_NAME); var danDataPath = Path.Combine(dataPath, settings.DanDataFileName); + var gaidenDataPath = Path.Combine(dataPath, settings.GaidenDataFileName); var songIntroDataPath = Path.Combine(dataPath, settings.IntroDataFileName); var movieDataPath = Path.Combine(dataPath, settings.MovieDataFileName); var eventFolderDataPath = Path.Combine(dataPath, settings.EventFolderDataFileName); @@ -129,6 +138,7 @@ public class GameDataService : IGameDataService await using var musicInfoFile = File.OpenRead(musicInfoPath); await using var musicAttributeFile = File.OpenRead(musicAttributePath); await using var danDataFile = File.OpenRead(danDataPath); + await using var gaidenDataFile = File.OpenRead(gaidenDataPath); await using var songIntroDataFile = File.OpenRead(songIntroDataPath); await using var movieDataFile = File.OpenRead(movieDataPath); await using var eventFolderDataFile = File.OpenRead(eventFolderDataPath); @@ -139,6 +149,7 @@ public class GameDataService : IGameDataService var infoesData = await JsonSerializer.DeserializeAsync(musicInfoFile); var attributesData = await JsonSerializer.DeserializeAsync(musicAttributeFile); var danData = await JsonSerializer.DeserializeAsync>(danDataFile); + var gaidenData = await JsonSerializer.DeserializeAsync>(gaidenDataFile); var introData = await JsonSerializer.DeserializeAsync>(songIntroDataFile); var movieData = await JsonSerializer.DeserializeAsync>(movieDataFile); var eventFolderData = await JsonSerializer.DeserializeAsync>(eventFolderDataFile); @@ -151,6 +162,8 @@ public class GameDataService : IGameDataService InitializeMusicAttributes(attributesData); InitializeDanData(danData); + + InitializeGaidenData(gaidenData); InitializeIntroData(introData); @@ -206,6 +219,12 @@ public class GameDataService : IGameDataService danData.ThrowIfNull("Shouldn't happen!"); danDataDictionary = danData.ToImmutableDictionary(data => data.DanId, ToResponseOdaiData); } + + private void InitializeGaidenData(List? gaidenData) + { + gaidenData.ThrowIfNull("Shouldn't happen!"); + gaidenDataDictionary = gaidenData.ToImmutableDictionary(data => data.DanId, ToResponseOdaiData); + } private void InitializeEventFolderData(List? eventFolderData) { diff --git a/TaikoLocalServer/Services/Interfaces/IGameDataService.cs b/TaikoLocalServer/Services/Interfaces/IGameDataService.cs index 1b6035c..82f302d 100644 --- a/TaikoLocalServer/Services/Interfaces/IGameDataService.cs +++ b/TaikoLocalServer/Services/Interfaces/IGameDataService.cs @@ -15,6 +15,8 @@ public interface IGameDataService public ImmutableDictionary GetMusicAttributes(); public ImmutableDictionary GetDanDataDictionary(); + + public ImmutableDictionary GetGaidenDataDictionary(); public ImmutableDictionary GetSongIntroDictionary(); diff --git a/TaikoLocalServer/Settings/DataSettings.cs b/TaikoLocalServer/Settings/DataSettings.cs index c6d4976..ddcdc65 100644 --- a/TaikoLocalServer/Settings/DataSettings.cs +++ b/TaikoLocalServer/Settings/DataSettings.cs @@ -3,6 +3,8 @@ public class DataSettings { public string DanDataFileName { get; set; } = "dan_data.json"; + + public string GaidenDataFileName { get; set; } = "gaiden_data.json"; public string EventFolderDataFileName { get; set; } = "event_folder_data.json"; diff --git a/TaikoLocalServer/TaikoLocalServer.csproj b/TaikoLocalServer/TaikoLocalServer.csproj index cc7dcb1..f6e9384 100644 --- a/TaikoLocalServer/TaikoLocalServer.csproj +++ b/TaikoLocalServer/TaikoLocalServer.csproj @@ -81,6 +81,9 @@ PreserveNewest + + PreserveNewest + diff --git a/TaikoLocalServer/wwwroot/data/gaiden_data.json b/TaikoLocalServer/wwwroot/data/gaiden_data.json new file mode 100644 index 0000000..d732bb2 --- /dev/null +++ b/TaikoLocalServer/wwwroot/data/gaiden_data.json @@ -0,0 +1,38 @@ +[ + { + "danId":20, + "verupNo":1, + "title":"gaiden_2022_odai_7", + "aryOdaiSong":[ + { + "songNo":828, + "level":2, + "isHiddenSongName":false + }, + { + "songNo":187, + "level":2, + "isHiddenSongName":false + }, + { + "songNo":789, + "level":2, + "isHiddenSongName":false + } + ], + "aryOdaiBorder":[ + { + "odaiType":1, + "borderType":1, + "redBorderTotal":92, + "goldBorderTotal":95 + }, + { + "odaiType":8, + "borderType":1, + "redBorderTotal":786, + "goldBorderTotal":832 + } + ] + } +] \ No newline at end of file