From ea719bdf52b605ed9c50fd007303c283666dd86f Mon Sep 17 00:00:00 2001 From: RyuMiyaX <52694802+ryumiyax@users.noreply.github.com> Date: Sun, 10 Nov 2024 09:35:25 +0000 Subject: [PATCH] Shop Folder Verup | Optimize EnableMoreSongs for test --- TaikoLocalServer/Common/Constants.cs | 4 ++++ .../Configurations/ServerSettings.json | 3 ++- .../Handlers/GetInitialDataQuery.cs | 18 ++++++++++++++++-- .../Handlers/GetShopFolderQuery.cs | 2 +- TaikoLocalServer/Handlers/UserDataQuery.cs | 12 +++++++++--- TaikoLocalServer/Services/GameDataService.cs | 9 +++++++++ .../Services/Interfaces/IGameDataService.cs | 2 ++ TaikoLocalServer/Settings/ServerSettings.cs | 2 ++ 8 files changed, 45 insertions(+), 7 deletions(-) diff --git a/TaikoLocalServer/Common/Constants.cs b/TaikoLocalServer/Common/Constants.cs index b8c3f1d..b475fda 100644 --- a/TaikoLocalServer/Common/Constants.cs +++ b/TaikoLocalServer/Common/Constants.cs @@ -17,6 +17,10 @@ public static class Constants public const string ShougouBaseName = "shougou"; public const string NeiroBaseName = "neiro"; + // Verup1 + public const uint ShopVerupMasterType = 104; + + // Verup2 public const uint DanVerupMasterType = 101; public const uint GaidenVerupMasterType = 102; public const uint FolderVerupMasterType = 103; diff --git a/TaikoLocalServer/Configurations/ServerSettings.json b/TaikoLocalServer/Configurations/ServerSettings.json index 31294fb..9995f9e 100644 --- a/TaikoLocalServer/Configurations/ServerSettings.json +++ b/TaikoLocalServer/Configurations/ServerSettings.json @@ -2,6 +2,7 @@ "ServerSettings": { "MuchaUrl": "https://v402-front.mucha-prd.nbgi-amnet.jp:10122", "GameUrl": "vsapi.taiko-p.jp", - "EnableMoreSongs": false + "EnableMoreSongs": false, + "MoreSongsSize": 9000 } } \ No newline at end of file diff --git a/TaikoLocalServer/Handlers/GetInitialDataQuery.cs b/TaikoLocalServer/Handlers/GetInitialDataQuery.cs index ac48631..a484d9f 100644 --- a/TaikoLocalServer/Handlers/GetInitialDataQuery.cs +++ b/TaikoLocalServer/Handlers/GetInitialDataQuery.cs @@ -17,7 +17,7 @@ public class GetInitialDataQueryHandler(IGameDataService gameDataService, public Task Handle(GetInitialDataQuery request, CancellationToken cancellationToken) { - var songIdMax = settings.EnableMoreSongs ? Constants.MusicIdMaxExpanded : Constants.MusicIdMax; + var songIdMax = settings.EnableMoreSongs ? settings.MoreSongsSize : Constants.MusicIdMax; var musicList = gameDataService.GetMusicList(); var lockedSongsList = gameDataService.GetLockedSongsList(); @@ -51,13 +51,18 @@ public class GetInitialDataQueryHandler(IGameDataService gameDataService, } // TODO: Figure out what they are individually - var verupNo1 = new uint[] { 2, 3, 4, 5, 6, 7, 8, 13, 15, 24, 25, 26, 27, 28, 29, 30, 31, 104 }; + var verupNo1 = new uint[] { 2, 3, 4, 5, 6, 7, 8, 13, 15, 24, 25, 26, 27, 28, 29, 30, 31 }; var aryVerUp = verupNo1.Select(i => new CommonInitialDataCheckResponse.VerupNoData1 { MasterType = i, VerupNo = 1 }).ToList(); + CommonInitialDataCheckResponse.VerupNoData1[] verupNo1List = + [ + GetVerupNoData1(Constants.ShopVerupMasterType, gameDataService.GetShopFolderVerup()), + ]; response.AryVerupNoData1s.AddRange(aryVerUp); + response.AryVerupNoData1s.AddRange(verupNo1List); var commonDanDataDictionary = gameDataService.GetCommonDanDataDictionary(); var commonGaidenDataDictionary = gameDataService.GetCommonGaidenDataDictionary(); @@ -82,6 +87,15 @@ public class GetInitialDataQueryHandler(IGameDataService gameDataService, return Task.FromResult(response); } + + private CommonInitialDataCheckResponse.VerupNoData1 GetVerupNoData1(uint masterType, uint verup) + { + return new CommonInitialDataCheckResponse.VerupNoData1 + { + MasterType = masterType, + VerupNo = verup + }; + } private CommonInitialDataCheckResponse.VerupNoData2 GetVerupNoData2(uint masterType, ImmutableDictionary dictionary) where T:IVerupNo diff --git a/TaikoLocalServer/Handlers/GetShopFolderQuery.cs b/TaikoLocalServer/Handlers/GetShopFolderQuery.cs index 0a530b1..0fd76b9 100644 --- a/TaikoLocalServer/Handlers/GetShopFolderQuery.cs +++ b/TaikoLocalServer/Handlers/GetShopFolderQuery.cs @@ -15,7 +15,7 @@ public class GetShopFolderHandler(IGameDataService gameDataService) { Result = 1, TokenId = seasonTokenId > 0 ? (uint)seasonTokenId : 1, - VerupNo = 2, + VerupNo = gameDataService.GetShopFolderVerup(), AryShopFolderDatas = shopFolderList }; diff --git a/TaikoLocalServer/Handlers/UserDataQuery.cs b/TaikoLocalServer/Handlers/UserDataQuery.cs index 3471026..21de45e 100644 --- a/TaikoLocalServer/Handlers/UserDataQuery.cs +++ b/TaikoLocalServer/Handlers/UserDataQuery.cs @@ -1,15 +1,19 @@ using System.Buffers.Binary; using GameDatabase.Context; +using Microsoft.Extensions.Options; +using TaikoLocalServer.Settings; using Throw; namespace TaikoLocalServer.Handlers; public record UserDataQuery(uint Baid) : IRequest; -public class UserDataQueryHandler(TaikoDbContext context, IGameDataService gameDataService, ILogger logger) +public class UserDataQueryHandler(TaikoDbContext context, IGameDataService gameDataService, ILogger logger, IOptions settings) : IRequestHandler { + private readonly ServerSettings settings = settings.Value; + public async Task Handle(UserDataQuery request, CancellationToken cancellationToken) { var userData = await context.UserData.FindAsync(request.Baid, cancellationToken); @@ -18,17 +22,19 @@ public class UserDataQueryHandler(TaikoDbContext context, IGameDataService gameD var unlockedSongIdList = userData.UnlockedSongIdList; var unlockedUraSongIdList = userData.UnlockedUraSongIdList; + var songIdMax = settings.EnableMoreSongs ? settings.MoreSongsSize : Constants.MusicIdMax; + var musicList = gameDataService.GetMusicList(); var lockedSongsList = gameDataService.GetLockedSongsList().Except(unlockedSongIdList).ToList(); var lockedUraSongsList = gameDataService.GetLockedUraSongsList().Except(unlockedUraSongIdList).ToList(); var enabledMusicList = musicList.Except(lockedSongsList); var releaseSongArray = - FlagCalculator.GetBitArrayFromIds(enabledMusicList, Constants.MusicIdMax, logger); + FlagCalculator.GetBitArrayFromIds(enabledMusicList, songIdMax, logger); var defaultSongWithUraList = gameDataService.GetMusicWithUraList(); var enabledUraMusicList = defaultSongWithUraList.Except(lockedUraSongsList); var uraSongArray = - FlagCalculator.GetBitArrayFromIds(enabledUraMusicList, Constants.MusicIdMax, logger); + FlagCalculator.GetBitArrayFromIds(enabledUraMusicList, songIdMax, logger); if (userData.ToneFlgArray.Count == 0) { diff --git a/TaikoLocalServer/Services/GameDataService.cs b/TaikoLocalServer/Services/GameDataService.cs index 0ac451b..5aaf5c2 100644 --- a/TaikoLocalServer/Services/GameDataService.cs +++ b/TaikoLocalServer/Services/GameDataService.cs @@ -35,6 +35,8 @@ public class GameDataService(IOptions dataSettings) : IGameDataSer private List shopFolderList = []; + private uint shopFolderVerup = 1; + private List musicUniqueIdList = []; private List musicWithUraUniqueIdList = []; @@ -103,6 +105,11 @@ public class GameDataService(IOptions dataSettings) : IGameDataSer return shopFolderList; } + public uint GetShopFolderVerup() + { + return shopFolderVerup; + } + public Dictionary GetTokenDataDictionary() { return tokenDataDictionary; @@ -231,6 +238,8 @@ public class GameDataService(IOptions dataSettings) : IGameDataSer throw new FileNotFoundException($"{Path.GetFileName(filePath)} file not found!"); } + shopFolderVerup = (uint)((File.GetLastWriteTime(shopFolderDataPath).ToFileTime() / 1000) % (1L << 32)); + await using var musicInfoFile = File.OpenRead(musicInfoPath); await using var danDataFile = File.OpenRead(danDataPath); await using var gaidenDataFile = File.OpenRead(gaidenDataPath); diff --git a/TaikoLocalServer/Services/Interfaces/IGameDataService.cs b/TaikoLocalServer/Services/Interfaces/IGameDataService.cs index e3d8088..c465815 100644 --- a/TaikoLocalServer/Services/Interfaces/IGameDataService.cs +++ b/TaikoLocalServer/Services/Interfaces/IGameDataService.cs @@ -23,6 +23,8 @@ public interface IGameDataService public List GetShopFolderList(); + public uint GetShopFolderVerup(); + public Dictionary GetTokenDataDictionary(); public List GetLockedSongsList(); diff --git a/TaikoLocalServer/Settings/ServerSettings.cs b/TaikoLocalServer/Settings/ServerSettings.cs index 3dd9136..fb983fe 100644 --- a/TaikoLocalServer/Settings/ServerSettings.cs +++ b/TaikoLocalServer/Settings/ServerSettings.cs @@ -7,4 +7,6 @@ public class ServerSettings public string GameUrl { get; set; } = string.Empty; public bool EnableMoreSongs { get; set; } + + public int MoreSongsSize { get; set; } = Constants.MusicIdMaxExpanded; } \ No newline at end of file