commit
23988544c4
18
SharedProject/Models/SongIntroductionData.cs
Normal file
18
SharedProject/Models/SongIntroductionData.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace SharedProject.Models;
|
||||
|
||||
public class SongIntroductionData
|
||||
{
|
||||
[JsonPropertyName("setId")]
|
||||
public uint SetId { get; set; }
|
||||
|
||||
[JsonPropertyName("verupNo")]
|
||||
public uint VerupNo { get; set; }
|
||||
|
||||
[JsonPropertyName("mainSongNo")]
|
||||
public uint MainSongNo { get; set; }
|
||||
|
||||
[JsonPropertyName("subSongNo")]
|
||||
public uint[]? SubSongNo { get; set; }
|
||||
}
|
@ -24,6 +24,8 @@ public static class Constants
|
||||
|
||||
public const string DAN_DATA_FILE_NAME = "dan_data.json";
|
||||
|
||||
public const string INTRO_DATA_FILE_NAME = "intro_data.json";
|
||||
|
||||
public const int MIN_DAN_ID = 1;
|
||||
public const int MAX_DAN_ID = 19;
|
||||
public const int GOT_DAN_BITS = MAX_DAN_ID * 4;
|
||||
|
42
TaikoLocalServer/Common/Utils/SongIntroductionDataManager.cs
Normal file
42
TaikoLocalServer/Common/Utils/SongIntroductionDataManager.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using System.Collections.Immutable;
|
||||
using System.Text.Json;
|
||||
using SharedProject.Models;
|
||||
|
||||
namespace TaikoLocalServer.Common.Utils;
|
||||
|
||||
public class SongIntroductionDataManager
|
||||
{
|
||||
public ImmutableDictionary<uint, GetSongIntroductionResponse.SongIntroductionData> IntroDataList { get; }
|
||||
|
||||
static SongIntroductionDataManager() { }
|
||||
|
||||
private SongIntroductionDataManager()
|
||||
{
|
||||
var dataPath = PathHelper.GetDataPath();
|
||||
var filePath = Path.Combine(dataPath, Constants.INTRO_DATA_FILE_NAME);
|
||||
var jsonString = File.ReadAllText(filePath);
|
||||
|
||||
var result = JsonSerializer.Deserialize<List<SongIntroductionData>>(jsonString);
|
||||
|
||||
if (result is null)
|
||||
{
|
||||
throw new ApplicationException("Cannot parse intro data json!");
|
||||
}
|
||||
|
||||
IntroDataList = result.ToImmutableDictionary(data => data.SetId, ToResponseIntroData);
|
||||
}
|
||||
private GetSongIntroductionResponse.SongIntroductionData ToResponseIntroData(SongIntroductionData data)
|
||||
{
|
||||
var responseOdaiData = new GetSongIntroductionResponse.SongIntroductionData
|
||||
{
|
||||
SetId = data.SetId,
|
||||
VerupNo = data.VerupNo,
|
||||
MainSongNo = data.MainSongNo,
|
||||
SubSongNoes = data.SubSongNo
|
||||
};
|
||||
|
||||
return responseOdaiData;
|
||||
}
|
||||
|
||||
public static SongIntroductionDataManager Instance { get; } = new();
|
||||
}
|
@ -15,15 +15,17 @@ public class GetSongIntroductionController : BaseController<GetSongIntroductionC
|
||||
Result = 1
|
||||
};
|
||||
|
||||
var manager = SongIntroductionDataManager.Instance;
|
||||
foreach (var setId in request.SetIds)
|
||||
{
|
||||
response.ArySongIntroductionDatas.Add(new GetSongIntroductionResponse.SongIntroductionData
|
||||
manager.IntroDataList.TryGetValue(setId, out var introData);
|
||||
if (introData is null)
|
||||
{
|
||||
MainSongNo = 2,
|
||||
SubSongNoes = new uint[] {177,193,3,4},
|
||||
SetId = setId,
|
||||
VerupNo = 1
|
||||
});
|
||||
Logger.LogWarning("Requested set id {Id} does not exist!", setId);
|
||||
continue;
|
||||
}
|
||||
|
||||
response.ArySongIntroductionDatas.Add(introData);
|
||||
}
|
||||
|
||||
return Ok(response);
|
||||
|
@ -31,6 +31,17 @@ public class InitialDataCheckController : BaseController<InitialDataCheckControl
|
||||
VerupNo = 1
|
||||
});
|
||||
}
|
||||
|
||||
var manager = SongIntroductionDataManager.Instance;
|
||||
var introData = new List<InitialdatacheckResponse.InformationData>();
|
||||
for (var setId = 1; setId <= manager.IntroDataList.Count; setId++)
|
||||
{
|
||||
introData.Add(new InitialdatacheckResponse.InformationData
|
||||
{
|
||||
InfoId = (uint)setId,
|
||||
VerupNo = 1
|
||||
});
|
||||
}
|
||||
|
||||
var response = new InitialdatacheckResponse
|
||||
{
|
||||
@ -100,6 +111,7 @@ public class InitialDataCheckController : BaseController<InitialDataCheckControl
|
||||
});*/
|
||||
};
|
||||
response.AryDanOdaiDatas.AddRange(danData);
|
||||
response.ArySongIntroductionDatas.AddRange(introData);
|
||||
return Ok(response);
|
||||
}
|
||||
|
||||
|
74
TaikoLocalServer/wwwroot/intro_data.json
Normal file
74
TaikoLocalServer/wwwroot/intro_data.json
Normal file
@ -0,0 +1,74 @@
|
||||
[
|
||||
{
|
||||
"setId":1,
|
||||
"verupNo":1,
|
||||
"mainSongNo":895,
|
||||
"subSongNo":[894,732,44,921]
|
||||
},
|
||||
{
|
||||
"setId":2,
|
||||
"verupNo":1,
|
||||
"mainSongNo":912,
|
||||
"subSongNo":[827,871,36,227]
|
||||
},
|
||||
{
|
||||
"setId":3,
|
||||
"verupNo":1,
|
||||
"mainSongNo":913,
|
||||
"subSongNo":[460,916,430,872]
|
||||
},
|
||||
{
|
||||
"setId":4,
|
||||
"verupNo":1,
|
||||
"mainSongNo":842,
|
||||
"subSongNo":[7,233,256,831]
|
||||
},
|
||||
{
|
||||
"setId":5,
|
||||
"verupNo":1,
|
||||
"mainSongNo":947,
|
||||
"subSongNo":[926,882,730,695]
|
||||
},
|
||||
{
|
||||
"setId":6,
|
||||
"verupNo":1,
|
||||
"mainSongNo":937,
|
||||
"subSongNo":[828,925,474,924]
|
||||
},
|
||||
{
|
||||
"setId":7,
|
||||
"verupNo":1,
|
||||
"mainSongNo":956,
|
||||
"subSongNo":[839,255,285,187]
|
||||
},
|
||||
{
|
||||
"setId":8,
|
||||
"verupNo":1,
|
||||
"mainSongNo":923,
|
||||
"subSongNo":[729,873,789,893]
|
||||
},
|
||||
{
|
||||
"setId":9,
|
||||
"verupNo":1,
|
||||
"mainSongNo":915,
|
||||
"subSongNo":[726,811,711,303]
|
||||
},
|
||||
{
|
||||
"setId":10,
|
||||
"verupNo":1,
|
||||
"mainSongNo":885,
|
||||
"subSongNo":[837,464,801,18]
|
||||
},
|
||||
{
|
||||
"setId":11,
|
||||
"verupNo":1,
|
||||
"mainSongNo":898,
|
||||
"subSongNo":[47,135,374,792]
|
||||
},
|
||||
{
|
||||
"setId":12,
|
||||
"verupNo":1,
|
||||
"mainSongNo":948,
|
||||
"subSongNo":[412,538,411,413]
|
||||
}
|
||||
]
|
Loading…
Reference in New Issue
Block a user