1
0
mirror of synced 2024-11-30 17:24:33 +01:00

Add Event Folder handling

This commit is contained in:
shiibe 2022-12-18 16:48:58 -05:00
parent 2e26b68cb0
commit 6ecca59095
10 changed files with 181 additions and 35 deletions

View File

@ -0,0 +1,18 @@
using System.Text.Json.Serialization;
namespace SharedProject.Models;
public class EventFolderData
{
[JsonPropertyName("folderId")]
public uint FolderId { get; set; }
[JsonPropertyName("verupNo")]
public uint VerupNo { get; set; }
[JsonPropertyName("priority")]
public uint Priority { get; set; }
[JsonPropertyName("songNo")]
public uint[]? SongNo { get; set; }
}

View File

@ -14,8 +14,12 @@ public static class Constants
public const string MUSIC_ATTRIBUTE_COMPRESSED_FILE_NAME = "music_attribute.bin"; public const string MUSIC_ATTRIBUTE_COMPRESSED_FILE_NAME = "music_attribute.bin";
public const string DAN_DATA_FILE_NAME = "dan_data.json"; public const string DAN_DATA_FILE_NAME = "dan_data.json";
public const string INTRO_DATA_FILE_NAME = "intro_data.json"; public const string INTRO_DATA_FILE_NAME = "intro_data.json";
public const string EVENT_FOLDER_DATA_FILE_NAME = "event_folder_data.json";
public static readonly int[] EVENT_FOLDER_IDS = {
1, 2, 3, 4, 5, 6, 7, 8, 12, 13, 14
};
public const int MIN_DAN_ID = 1; public const int MIN_DAN_ID = 1;
public const int MAX_DAN_ID = 19; public const int MAX_DAN_ID = 19;

View File

@ -1,7 +1,7 @@
{ {
"DataSettings" : { "DataSettings" : {
"DanDataFileName" : "dan_data.json", "DanDataFileName" : "dan_data.json",
"EventDataFileName" : "event_data.json", "EventFolderDataFileName" : "event_folder_data.json",
"IntroDataFileName" : "intro_data.json" "IntroDataFileName" : "intro_data.json"
} }
} }

View File

@ -4,6 +4,12 @@
[ApiController] [ApiController]
public class GetFolderController : BaseController<GetFolderController> public class GetFolderController : BaseController<GetFolderController>
{ {
private readonly IGameDataService gameDataService;
public GetFolderController(IGameDataService gameDataService)
{
this.gameDataService = gameDataService;
}
[HttpPost] [HttpPost]
[Produces("application/protobuf")] [Produces("application/protobuf")]
public IActionResult GetFolder([FromBody] GetfolderRequest request) public IActionResult GetFolder([FromBody] GetfolderRequest request)
@ -17,13 +23,14 @@ public class GetFolderController : BaseController<GetFolderController>
foreach (var folderId in request.FolderIds) foreach (var folderId in request.FolderIds)
{ {
response.AryEventfolderDatas.Add(new GetfolderResponse.EventfolderData gameDataService.GetFolderDictionary().TryGetValue(folderId, out var folderData);
if (folderData is null)
{ {
FolderId = folderId, Logger.LogWarning("Requested folder id {Id} does not exist!", folderId);
Priority = 1, continue;
SongNoes = new uint[] {1,2}, }
VerupNo = 1
}); response.AryEventfolderDatas.Add(folderData);
} }
return Ok(response); return Ok(response);

View File

@ -47,6 +47,16 @@ public class InitialDataCheckController : BaseController<InitialDataCheckControl
}); });
} }
var eventFolderData = new List<InitialdatacheckResponse.InformationData>();
foreach (var folderId in Constants.EVENT_FOLDER_IDS)
{
eventFolderData.Add(new InitialdatacheckResponse.InformationData
{
InfoId = (uint)folderId,
VerupNo = 0
});
}
var response = new InitialdatacheckResponse var response = new InitialdatacheckResponse
{ {
Result = 1, Result = 1,
@ -63,7 +73,7 @@ public class InitialDataCheckController : BaseController<InitialDataCheckControl
InfoId = 1, InfoId = 1,
VerupNo = 2 VerupNo = 2
} }
} },
/*AryTelopDatas = /*AryTelopDatas =
{ {
new InitialdatacheckResponse.InformationData new InitialdatacheckResponse.InformationData
@ -72,16 +82,6 @@ public class InitialDataCheckController : BaseController<InitialDataCheckControl
VerupNo = 1 VerupNo = 1
} }
}, },
ArySongIntroductionDatas =
{
new InitialdatacheckResponse.InformationData
{
InfoId = 1,
VerupNo = 1
}
},
AryDanextraOdaiDatas = AryDanextraOdaiDatas =
{ {
new InitialdatacheckResponse.InformationData new InitialdatacheckResponse.InformationData
@ -90,7 +90,6 @@ public class InitialDataCheckController : BaseController<InitialDataCheckControl
VerupNo = 1 VerupNo = 1
} }
}, },
AryAiEventDatas = AryAiEventDatas =
{ {
new InitialdatacheckResponse.AiEventData new InitialdatacheckResponse.AiEventData
@ -99,23 +98,19 @@ public class InitialDataCheckController : BaseController<InitialDataCheckControl
TokenId = 1 TokenId = 1
} }
}, },
AryEventfolderDatas = AryMovieInfos =
{ {
new InitialdatacheckResponse.InformationData new InitialdatacheckResponse.MovieData
{ {
InfoId = 1, MovieId = 2,
VerupNo = 1 EnableDays = 9999
} }
} }*/
};*/
/*response.AryMovieInfoes.Add(new InitialdatacheckResponse.MovieData
{
MovieId = 2,
EnableDays = 9999
});*/
}; };
response.AryDanOdaiDatas.AddRange(danData); response.AryDanOdaiDatas.AddRange(danData);
response.ArySongIntroductionDatas.AddRange(introData); response.ArySongIntroductionDatas.AddRange(introData);
response.AryEventfolderDatas.AddRange(eventFolderData);
return Ok(response); return Ok(response);
} }

View File

@ -21,6 +21,9 @@ public class GameDataService : IGameDataService
private ImmutableDictionary<uint, MusicAttributeEntry> musicAttributes = private ImmutableDictionary<uint, MusicAttributeEntry> musicAttributes =
ImmutableDictionary<uint, MusicAttributeEntry>.Empty; ImmutableDictionary<uint, MusicAttributeEntry>.Empty;
private ImmutableDictionary<uint, GetfolderResponse.EventfolderData> folderDictionary =
ImmutableDictionary<uint, GetfolderResponse.EventfolderData>.Empty;
private List<uint> musics = new(); private List<uint> musics = new();
private List<uint> musicsWithUra = new(); private List<uint> musicsWithUra = new();
@ -57,6 +60,11 @@ public class GameDataService : IGameDataService
return introDataDictionary; return introDataDictionary;
} }
public ImmutableDictionary<uint, GetfolderResponse.EventfolderData> GetFolderDictionary()
{
return folderDictionary;
}
public async Task InitializeAsync() public async Task InitializeAsync()
{ {
var dataPath = PathHelper.GetDataPath(); var dataPath = PathHelper.GetDataPath();
@ -64,6 +72,7 @@ public class GameDataService : IGameDataService
var compressedMusicAttributePath = Path.Combine(dataPath, Constants.MUSIC_ATTRIBUTE_COMPRESSED_FILE_NAME); var compressedMusicAttributePath = Path.Combine(dataPath, Constants.MUSIC_ATTRIBUTE_COMPRESSED_FILE_NAME);
var danDataPath = Path.Combine(dataPath, settings.DanDataFileName); var danDataPath = Path.Combine(dataPath, settings.DanDataFileName);
var songIntroDataPath = Path.Combine(dataPath, settings.IntroDataFileName); var songIntroDataPath = Path.Combine(dataPath, settings.IntroDataFileName);
var eventFolderDataPath = Path.Combine(dataPath, settings.EventFolderDataFileName);
if (File.Exists(compressedMusicAttributePath)) if (File.Exists(compressedMusicAttributePath))
{ {
@ -72,16 +81,20 @@ public class GameDataService : IGameDataService
await using var musicAttributeFile = File.OpenRead(musicAttributePath); await using var musicAttributeFile = File.OpenRead(musicAttributePath);
await using var danDataFile = File.OpenRead(danDataPath); await using var danDataFile = File.OpenRead(danDataPath);
await using var songIntroDataFile = File.OpenRead(songIntroDataPath); await using var songIntroDataFile = File.OpenRead(songIntroDataPath);
await using var eventFolderDataFile = File.OpenRead(eventFolderDataPath);
var attributesData = await JsonSerializer.DeserializeAsync<MusicAttributes>(musicAttributeFile); var attributesData = await JsonSerializer.DeserializeAsync<MusicAttributes>(musicAttributeFile);
var danData = await JsonSerializer.DeserializeAsync<List<DanData>>(danDataFile); var danData = await JsonSerializer.DeserializeAsync<List<DanData>>(danDataFile);
var introData = await JsonSerializer.DeserializeAsync<List<SongIntroductionData>>(songIntroDataFile); var introData = await JsonSerializer.DeserializeAsync<List<SongIntroductionData>>(songIntroDataFile);
var eventFolderData = await JsonSerializer.DeserializeAsync<List<EventFolderData>>(eventFolderDataFile);
InitializeMusicAttributes(attributesData); InitializeMusicAttributes(attributesData);
InitializeDanData(danData); InitializeDanData(danData);
InitializeIntroData(introData); InitializeIntroData(introData);
InitializeEventFolderData(eventFolderData);
} }
private static void TryDecompressMusicAttribute() private static void TryDecompressMusicAttribute()
@ -108,6 +121,12 @@ public class GameDataService : IGameDataService
danDataDictionary = danData.ToImmutableDictionary(data => data.DanId, ToResponseOdaiData); danDataDictionary = danData.ToImmutableDictionary(data => data.DanId, ToResponseOdaiData);
} }
private void InitializeEventFolderData(List<EventFolderData>? eventFolderData)
{
eventFolderData.ThrowIfNull("Shouldn't happen!");
folderDictionary = eventFolderData.ToImmutableDictionary(data => data.FolderId, ToResponseEventFolderData);
}
private void InitializeMusicAttributes(MusicAttributes? attributesData) private void InitializeMusicAttributes(MusicAttributes? attributesData)
{ {
attributesData.ThrowIfNull("Shouldn't happen!"); attributesData.ThrowIfNull("Shouldn't happen!");
@ -154,4 +173,17 @@ public class GameDataService : IGameDataService
return responseOdaiData; return responseOdaiData;
} }
private static GetfolderResponse.EventfolderData ToResponseEventFolderData(EventFolderData data)
{
var responseEventFolderData = new GetfolderResponse.EventfolderData
{
FolderId = data.FolderId,
VerupNo = data.VerupNo,
Priority = data.Priority,
SongNoes = data.SongNo
};
return responseEventFolderData;
}
} }

View File

@ -15,4 +15,7 @@ public interface IGameDataService
public ImmutableDictionary<uint, GetDanOdaiResponse.OdaiData> GetDanDataDictionary(); public ImmutableDictionary<uint, GetDanOdaiResponse.OdaiData> GetDanDataDictionary();
public ImmutableDictionary<uint, GetSongIntroductionResponse.SongIntroductionData> GetSongIntroDictionary(); public ImmutableDictionary<uint, GetSongIntroductionResponse.SongIntroductionData> GetSongIntroDictionary();
public ImmutableDictionary<uint, GetfolderResponse.EventfolderData> GetFolderDictionary();
} }

View File

@ -4,7 +4,7 @@ public class DataSettings
{ {
public string DanDataFileName { get; set; } = "dan_data.json"; public string DanDataFileName { get; set; } = "dan_data.json";
public string EventDataFileName { get; set; } = "event_data.json"; public string EventFolderDataFileName { get; set; } = "event_folder_data.json";
public string IntroDataFileName { get; set; } = "intro_data.json"; public string IntroDataFileName { get; set; } = "intro_data.json";
} }

View File

@ -64,6 +64,9 @@
<Content Update="wwwroot\data\dan_data.json"> <Content Update="wwwroot\data\dan_data.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Update="wwwroot\data\event_folder_data.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\data\intro_data.json"> <Content Update="wwwroot\data\intro_data.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>

View File

@ -0,0 +1,84 @@
[
{
"folderId": 1,
"verupNo": 1,
"priority": 1,
"songNo": []
},
{
"folderId": 2,
"verupNo": 1,
"priority": 1,
"songNo": [
478, 153, 200, 482, 511, 672, 675, 646, 644, 645, 676, 671, 479,
707, 480, 481, 203, 204, 483, 205, 202, 241, 14, 387, 197, 281, 226,
484, 543, 512, 709, 35
]
},
{
"folderId": 3,
"verupNo": 1,
"priority": 1,
"songNo": [
1485, 1404, 1580, 1730, 1750, 1277, 1478, 1481, 1482, 1484, 1500,
1890, 2349, 2604, 2640, 1176, 1419, 1596, 1693, 2248, 1049, 1221,
1222, 1223, 1224, 1493, 1578, 1719, 2650, 1595, 1964, 1469, 1217,
1314, 1406, 1565, 1745, 2120, 2200, 2324, 2785, 1631, 2301, 2802,
1490, 2088, 2268, 2309, 2507, 2126, 1630, 2509, 1263, 2495, 2642,
2745, 1054, 2583, 1271, 1266, 1267, 2923
]
},
{
"folderId": 4,
"verupNo": 1,
"priority": 1,
"songNo": [
1361, 1366, 1373, 1379, 1337, 1345, 1357, 1362, 1367, 1368, 1369,
1374, 1375, 1388, 1390, 1579, 2225, 1354, 1394, 2804, 1340, 1341,
1370, 1376, 1384, 1359, 1385, 2416, 2756, 1363, 1920, 1353, 1360,
1381, 1389, 1364, 1391, 1342, 1546, 1931
]
},
{
"folderId": 5,
"verupNo": 1,
"priority": 1,
"songNo": [242, 430, 368, 604, 333]
},
{
"folderId": 6,
"verupNo": 1,
"priority": 1,
"songNo": [841, 767, 658, 467, 468, 466, 460, 157, 465]
},
{
"folderId": 7,
"verupNo": 1,
"priority": 1,
"songNo": [733, 732, 44, 790, 894]
},
{
"folderId": 8,
"verupNo": 1,
"priority": 1,
"songNo": []
},
{
"folderId": 12,
"verupNo": 1,
"priority": 1,
"songNo": []
},
{
"folderId": 13,
"verupNo": 1,
"priority": 1,
"songNo": []
},
{
"folderId": 14,
"verupNo": 1,
"priority": 1,
"songNo": []
}
]