From aa6499866f8b70f59b7c08a18c251dd5ef1acb3f Mon Sep 17 00:00:00 2001 From: esuo1198 <54134.es@gmail.com> Date: Wed, 13 Sep 2023 12:24:48 +0900 Subject: [PATCH] Add ary_movie_info handle --- SharedProject/Models/MovieData.cs | 12 +++++ .../Game/InitialDataCheckController.cs | 20 ++++--- TaikoLocalServer/Services/GameDataService.cs | 52 +++++++++++++++---- .../Services/Interfaces/IGameDataService.cs | 8 +-- TaikoLocalServer/Settings/DataSettings.cs | 16 +++--- TaikoLocalServer/TaikoLocalServer.csproj | 12 +++++ TaikoLocalServer/wwwroot/data/movie_data.json | 6 +++ 7 files changed, 98 insertions(+), 28 deletions(-) create mode 100644 SharedProject/Models/MovieData.cs create mode 100644 TaikoLocalServer/wwwroot/data/movie_data.json diff --git a/SharedProject/Models/MovieData.cs b/SharedProject/Models/MovieData.cs new file mode 100644 index 0000000..7a3a2b5 --- /dev/null +++ b/SharedProject/Models/MovieData.cs @@ -0,0 +1,12 @@ +using System.Text.Json.Serialization; + +namespace SharedProject.Models; + +public class MovieData +{ + [JsonPropertyName("movie_id")] + public uint MovieId { get; set; } + + [JsonPropertyName("enable_days")] + public uint EnableDays { get; set; } +} \ No newline at end of file diff --git a/TaikoLocalServer/Controllers/Game/InitialDataCheckController.cs b/TaikoLocalServer/Controllers/Game/InitialDataCheckController.cs index 74a3977..a83aab8 100644 --- a/TaikoLocalServer/Controllers/Game/InitialDataCheckController.cs +++ b/TaikoLocalServer/Controllers/Game/InitialDataCheckController.cs @@ -24,7 +24,7 @@ public class InitialDataCheckController : BaseController new InitialdatacheckResponse.VerupNoData1 - { - MasterType = i, - VerupNo = 1 - }) + { + MasterType = i, + VerupNo = 1 + }) .ToList(); var response = new InitialdatacheckResponse @@ -49,8 +51,11 @@ public class InitialDataCheckController : BaseController(); for (var danId = Constants.MIN_DAN_ID; danId <= 18; danId++) { @@ -60,6 +65,7 @@ public class InitialDataCheckController : BaseController introDataDictionary = ImmutableDictionary.Empty; + private ImmutableDictionary movieDataDictionary = + ImmutableDictionary.Empty; + private ImmutableDictionary musicAttributes = ImmutableDictionary.Empty; private ImmutableDictionary folderDictionary = ImmutableDictionary.Empty; - + private ImmutableDictionary shopFolderDictionary = ImmutableDictionary.Empty; private List musics = new(); private List musicsWithUra = new(); - + private List lockedSongsList = new(); private Dictionary tokenDataDictionary = new(); @@ -75,16 +78,21 @@ public class GameDataService : IGameDataService return introDataDictionary; } + public ImmutableDictionary GetMovieDataDictionary() + { + return movieDataDictionary; + } + public ImmutableDictionary GetFolderDictionary() { return folderDictionary; } - + public ImmutableDictionary GetShopFolderDictionary() { return shopFolderDictionary; } - + public Dictionary GetTokenDataDictionary() { return tokenDataDictionary; @@ -104,6 +112,7 @@ public class GameDataService : IGameDataService var compressedMusicAttributePath = Path.Combine(dataPath, Constants.MUSIC_ATTRIBUTE_COMPRESSED_FILE_NAME); var danDataPath = Path.Combine(dataPath, settings.DanDataFileName); var songIntroDataPath = Path.Combine(dataPath, settings.IntroDataFileName); + var movieDataPath = Path.Combine(dataPath, settings.MovieDataFileName); var eventFolderDataPath = Path.Combine(dataPath, settings.EventFolderDataFileName); var shopFolderDataPath = Path.Combine(dataPath, settings.ShopFolderDataFileName); var tokenDataPath = Path.Combine(dataPath, settings.TokenDataFileName); @@ -121,6 +130,7 @@ public class GameDataService : IGameDataService await using var musicAttributeFile = File.OpenRead(musicAttributePath); await using var danDataFile = File.OpenRead(danDataPath); await using var songIntroDataFile = File.OpenRead(songIntroDataPath); + await using var movieDataFile = File.OpenRead(movieDataPath); await using var eventFolderDataFile = File.OpenRead(eventFolderDataPath); await using var shopFolderDataFile = File.OpenRead(shopFolderDataPath); await using var tokenDataFile = File.OpenRead(tokenDataPath); @@ -130,6 +140,7 @@ public class GameDataService : IGameDataService var attributesData = await JsonSerializer.DeserializeAsync(musicAttributeFile); var danData = await JsonSerializer.DeserializeAsync>(danDataFile); var introData = await JsonSerializer.DeserializeAsync>(songIntroDataFile); + var movieData = await JsonSerializer.DeserializeAsync>(movieDataFile); var eventFolderData = await JsonSerializer.DeserializeAsync>(eventFolderDataFile); var shopFolderData = await JsonSerializer.DeserializeAsync>(shopFolderDataFile); var tokenData = await JsonSerializer.DeserializeAsync>(tokenDataFile); @@ -143,10 +154,12 @@ public class GameDataService : IGameDataService InitializeIntroData(introData); + InitializeMovieData(movieData); + InitializeEventFolderData(eventFolderData); - + InitializeShopFolderData(shopFolderData); - + InitializeTokenData(tokenData); InitializeLockedSongsData(lockedSongsData); @@ -182,6 +195,12 @@ public class GameDataService : IGameDataService introDataDictionary = introData.ToImmutableDictionary(data => data.SetId, ToResponseIntroData); } + private void InitializeMovieData(List? movieData) + { + movieData.ThrowIfNull("Shouldn't happen!"); + movieDataDictionary = movieData.ToImmutableDictionary(data => data.MovieId, ToResponseMovieData); + } + private void InitializeDanData(List? danData) { danData.ThrowIfNull("Shouldn't happen!"); @@ -216,7 +235,7 @@ public class GameDataService : IGameDataService .ToList(); musics.Sort(); } - + private void InitializeShopFolderData(List? shopFolderData) { shopFolderData.ThrowIfNull("Shouldn't happen!"); @@ -234,7 +253,7 @@ public class GameDataService : IGameDataService lockedSongsData.ThrowIfNull("Shouldn't happen!"); lockedSongsList = lockedSongsData["songNo"].ToList(); } - + private static GetDanOdaiResponse.OdaiData ToResponseOdaiData(DanData data) { var responseOdaiData = new GetDanOdaiResponse.OdaiData @@ -255,7 +274,7 @@ public class GameDataService : IGameDataService private static GetSongIntroductionResponse.SongIntroductionData ToResponseIntroData(SongIntroductionData data) { - var responseOdaiData = new GetSongIntroductionResponse.SongIntroductionData + var responseIntroData = new GetSongIntroductionResponse.SongIntroductionData { SetId = data.SetId, VerupNo = data.VerupNo, @@ -263,7 +282,18 @@ public class GameDataService : IGameDataService SubSongNoes = data.SubSongNo }; - return responseOdaiData; + return responseIntroData; + } + + private static InitialdatacheckResponse.MovieData ToResponseMovieData(MovieData data) + { + var responseMovieData = new InitialdatacheckResponse.MovieData + { + MovieId = data.MovieId, + EnableDays = data.EnableDays + }; + + return responseMovieData; } private static GetfolderResponse.EventfolderData ToResponseEventFolderData(EventFolderData data) @@ -278,7 +308,7 @@ public class GameDataService : IGameDataService return responseEventFolderData; } - + private static GetShopFolderResponse.ShopFolderData ToResponseShopFolderData(ShopFolderData data) { var responseShopFolderData = new GetShopFolderResponse.ShopFolderData diff --git a/TaikoLocalServer/Services/Interfaces/IGameDataService.cs b/TaikoLocalServer/Services/Interfaces/IGameDataService.cs index dfa0d9f..5c97fd5 100644 --- a/TaikoLocalServer/Services/Interfaces/IGameDataService.cs +++ b/TaikoLocalServer/Services/Interfaces/IGameDataService.cs @@ -18,12 +18,14 @@ public interface IGameDataService public ImmutableDictionary GetSongIntroDictionary(); + public ImmutableDictionary GetMovieDataDictionary(); + public ImmutableDictionary GetFolderDictionary(); - + public ImmutableDictionary GetShopFolderDictionary(); - + public Dictionary GetTokenDataDictionary(); - + public List GetLockedSongsList(); } diff --git a/TaikoLocalServer/Settings/DataSettings.cs b/TaikoLocalServer/Settings/DataSettings.cs index 9f76838..c6d4976 100644 --- a/TaikoLocalServer/Settings/DataSettings.cs +++ b/TaikoLocalServer/Settings/DataSettings.cs @@ -2,15 +2,17 @@ public class DataSettings { - public string DanDataFileName { get; set; } = "dan_data.json"; + public string DanDataFileName { get; set; } = "dan_data.json"; - public string EventFolderDataFileName { get; set; } = "event_folder_data.json"; + public string EventFolderDataFileName { get; set; } = "event_folder_data.json"; - public string IntroDataFileName { get; set; } = "intro_data.json"; - - public string ShopFolderDataFileName { get; set; } = "shop_folder_data.json"; + public string IntroDataFileName { get; set; } = "intro_data.json"; - public string TokenDataFileName { get; set; } = "token_data.json"; + public string MovieDataFileName { get; set; } = "movie_data.json"; - public string LockedSongsDataFileName { get; set; } = "locked_songs_data.json"; + public string ShopFolderDataFileName { get; set; } = "shop_folder_data.json"; + + public string TokenDataFileName { get; set; } = "token_data.json"; + + public string LockedSongsDataFileName { get; set; } = "locked_songs_data.json"; } \ No newline at end of file diff --git a/TaikoLocalServer/TaikoLocalServer.csproj b/TaikoLocalServer/TaikoLocalServer.csproj index b82b844..e666b02 100644 --- a/TaikoLocalServer/TaikoLocalServer.csproj +++ b/TaikoLocalServer/TaikoLocalServer.csproj @@ -58,12 +58,24 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest diff --git a/TaikoLocalServer/wwwroot/data/movie_data.json b/TaikoLocalServer/wwwroot/data/movie_data.json new file mode 100644 index 0000000..f26aa0b --- /dev/null +++ b/TaikoLocalServer/wwwroot/data/movie_data.json @@ -0,0 +1,6 @@ +[ + { + "movie_id": 0, + "enable_days": 0 + } +] \ No newline at end of file