1
0
mirror of synced 2024-12-01 01:27:21 +01:00

Merge pull request #33 from ryumiyax/dev-1

Shop Folder Verup
This commit is contained in:
RyuMiyaX 2024-11-10 17:41:01 +08:00 committed by GitHub
commit 9fec2e2bbd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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 ShougouBaseName = "shougou";
public const string NeiroBaseName = "neiro"; public const string NeiroBaseName = "neiro";
// Verup1
public const uint ShopVerupMasterType = 104;
// Verup2
public const uint DanVerupMasterType = 101; public const uint DanVerupMasterType = 101;
public const uint GaidenVerupMasterType = 102; public const uint GaidenVerupMasterType = 102;
public const uint FolderVerupMasterType = 103; public const uint FolderVerupMasterType = 103;

View File

@ -2,6 +2,7 @@
"ServerSettings": { "ServerSettings": {
"MuchaUrl": "https://v402-front.mucha-prd.nbgi-amnet.jp:10122", "MuchaUrl": "https://v402-front.mucha-prd.nbgi-amnet.jp:10122",
"GameUrl": "vsapi.taiko-p.jp", "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) 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 musicList = gameDataService.GetMusicList();
var lockedSongsList = gameDataService.GetLockedSongsList(); var lockedSongsList = gameDataService.GetLockedSongsList();
@ -51,13 +51,18 @@ public class GetInitialDataQueryHandler(IGameDataService gameDataService,
} }
// TODO: Figure out what they are individually // 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 var aryVerUp = verupNo1.Select(i => new CommonInitialDataCheckResponse.VerupNoData1
{ {
MasterType = i, MasterType = i,
VerupNo = 1 VerupNo = 1
}).ToList(); }).ToList();
CommonInitialDataCheckResponse.VerupNoData1[] verupNo1List =
[
GetVerupNoData1(Constants.ShopVerupMasterType, gameDataService.GetShopFolderVerup()),
];
response.AryVerupNoData1s.AddRange(aryVerUp); response.AryVerupNoData1s.AddRange(aryVerUp);
response.AryVerupNoData1s.AddRange(verupNo1List);
var commonDanDataDictionary = gameDataService.GetCommonDanDataDictionary(); var commonDanDataDictionary = gameDataService.GetCommonDanDataDictionary();
var commonGaidenDataDictionary = gameDataService.GetCommonGaidenDataDictionary(); var commonGaidenDataDictionary = gameDataService.GetCommonGaidenDataDictionary();
@ -83,6 +88,15 @@ public class GetInitialDataQueryHandler(IGameDataService gameDataService,
return Task.FromResult(response); 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) private CommonInitialDataCheckResponse.VerupNoData2 GetVerupNoData2<T>(uint masterType, ImmutableDictionary<uint, T> dictionary)
where T:IVerupNo where T:IVerupNo
{ {

View File

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

View File

@ -1,15 +1,19 @@
using System.Buffers.Binary; using System.Buffers.Binary;
using GameDatabase.Context; using GameDatabase.Context;
using Microsoft.Extensions.Options;
using TaikoLocalServer.Settings;
using Throw; using Throw;
namespace TaikoLocalServer.Handlers; namespace TaikoLocalServer.Handlers;
public record UserDataQuery(uint Baid) : IRequest<CommonUserDataResponse>; 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> : IRequestHandler<UserDataQuery, CommonUserDataResponse>
{ {
private readonly ServerSettings settings = settings.Value;
public async Task<CommonUserDataResponse> Handle(UserDataQuery request, CancellationToken cancellationToken) public async Task<CommonUserDataResponse> Handle(UserDataQuery request, CancellationToken cancellationToken)
{ {
var userData = await context.UserData.FindAsync(request.Baid, 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 unlockedSongIdList = userData.UnlockedSongIdList;
var unlockedUraSongIdList = userData.UnlockedUraSongIdList; var unlockedUraSongIdList = userData.UnlockedUraSongIdList;
var songIdMax = settings.EnableMoreSongs ? settings.MoreSongsSize : Constants.MusicIdMax;
var musicList = gameDataService.GetMusicList(); var musicList = gameDataService.GetMusicList();
var lockedSongsList = gameDataService.GetLockedSongsList().Except(unlockedSongIdList).ToList(); var lockedSongsList = gameDataService.GetLockedSongsList().Except(unlockedSongIdList).ToList();
var lockedUraSongsList = gameDataService.GetLockedUraSongsList().Except(unlockedUraSongIdList).ToList(); var lockedUraSongsList = gameDataService.GetLockedUraSongsList().Except(unlockedUraSongIdList).ToList();
var enabledMusicList = musicList.Except(lockedSongsList); var enabledMusicList = musicList.Except(lockedSongsList);
var releaseSongArray = var releaseSongArray =
FlagCalculator.GetBitArrayFromIds(enabledMusicList, Constants.MusicIdMax, logger); FlagCalculator.GetBitArrayFromIds(enabledMusicList, songIdMax, logger);
var defaultSongWithUraList = gameDataService.GetMusicWithUraList(); var defaultSongWithUraList = gameDataService.GetMusicWithUraList();
var enabledUraMusicList = defaultSongWithUraList.Except(lockedUraSongsList); var enabledUraMusicList = defaultSongWithUraList.Except(lockedUraSongsList);
var uraSongArray = var uraSongArray =
FlagCalculator.GetBitArrayFromIds(enabledUraMusicList, Constants.MusicIdMax, logger); FlagCalculator.GetBitArrayFromIds(enabledUraMusicList, songIdMax, logger);
if (userData.ToneFlgArray.Count == 0) if (userData.ToneFlgArray.Count == 0)
{ {

View File

@ -35,6 +35,8 @@ public class GameDataService(IOptions<DataSettings> dataSettings) : IGameDataSer
private List<ShopFolderData> shopFolderList = []; private List<ShopFolderData> shopFolderList = [];
private uint shopFolderVerup = 1;
private List<uint> musicUniqueIdList = []; private List<uint> musicUniqueIdList = [];
private List<uint> musicWithUraUniqueIdList = []; private List<uint> musicWithUraUniqueIdList = [];
@ -103,6 +105,11 @@ public class GameDataService(IOptions<DataSettings> dataSettings) : IGameDataSer
return shopFolderList; return shopFolderList;
} }
public uint GetShopFolderVerup()
{
return shopFolderVerup;
}
public Dictionary<string, int> GetTokenDataDictionary() public Dictionary<string, int> GetTokenDataDictionary()
{ {
return tokenDataDictionary; return tokenDataDictionary;
@ -231,6 +238,8 @@ public class GameDataService(IOptions<DataSettings> dataSettings) : IGameDataSer
throw new FileNotFoundException($"{Path.GetFileName(filePath)} file not found!"); 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 musicInfoFile = File.OpenRead(musicInfoPath);
await using var danDataFile = File.OpenRead(danDataPath); await using var danDataFile = File.OpenRead(danDataPath);
await using var gaidenDataFile = File.OpenRead(gaidenDataPath); await using var gaidenDataFile = File.OpenRead(gaidenDataPath);

View File

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

View File

@ -7,4 +7,6 @@ public class ServerSettings
public string GameUrl { get; set; } = string.Empty; public string GameUrl { get; set; } = string.Empty;
public bool EnableMoreSongs { get; set; } public bool EnableMoreSongs { get; set; }
public int MoreSongsSize { get; set; } = Constants.MusicIdMaxExpanded;
} }