1
0
mirror of synced 2024-11-28 00:20:53 +01:00

Shop Folder Verup | Optimize EnableMoreSongs for test

This commit is contained in:
RyuMiyaX 2024-11-10 09:35:25 +00:00
parent 98db30f14d
commit ea719bdf52
8 changed files with 45 additions and 7 deletions

View File

@ -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;

View File

@ -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
}
}

View File

@ -17,7 +17,7 @@ public class GetInitialDataQueryHandler(IGameDataService gameDataService,
public Task<CommonInitialDataCheckResponse> 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<T>(uint masterType, ImmutableDictionary<uint, T> dictionary)
where T:IVerupNo

View File

@ -15,7 +15,7 @@ public class GetShopFolderHandler(IGameDataService gameDataService)
{
Result = 1,
TokenId = seasonTokenId > 0 ? (uint)seasonTokenId : 1,
VerupNo = 2,
VerupNo = gameDataService.GetShopFolderVerup(),
AryShopFolderDatas = shopFolderList
};

View File

@ -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<CommonUserDataResponse>;
public class UserDataQueryHandler(TaikoDbContext context, IGameDataService gameDataService, ILogger<UserDataQueryHandler> logger)
public class UserDataQueryHandler(TaikoDbContext context, IGameDataService gameDataService, ILogger<UserDataQueryHandler> logger, IOptions<ServerSettings> settings)
: IRequestHandler<UserDataQuery, CommonUserDataResponse>
{
private readonly ServerSettings settings = settings.Value;
public async Task<CommonUserDataResponse> 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)
{

View File

@ -35,6 +35,8 @@ public class GameDataService(IOptions<DataSettings> dataSettings) : IGameDataSer
private List<ShopFolderData> shopFolderList = [];
private uint shopFolderVerup = 1;
private List<uint> musicUniqueIdList = [];
private List<uint> musicWithUraUniqueIdList = [];
@ -103,6 +105,11 @@ public class GameDataService(IOptions<DataSettings> dataSettings) : IGameDataSer
return shopFolderList;
}
public uint GetShopFolderVerup()
{
return shopFolderVerup;
}
public Dictionary<string, int> GetTokenDataDictionary()
{
return tokenDataDictionary;
@ -231,6 +238,8 @@ public class GameDataService(IOptions<DataSettings> 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);

View File

@ -23,6 +23,8 @@ public interface IGameDataService
public List<ShopFolderData> GetShopFolderList();
public uint GetShopFolderVerup();
public Dictionary<string, int> GetTokenDataDictionary();
public List<uint> GetLockedSongsList();

View File

@ -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;
}