1
0
mirror of synced 2024-11-28 08:30:56 +01:00

Update route

This commit is contained in:
esuo1198 2024-03-07 22:44:19 +09:00
parent a3cff10634
commit ae885e546f
15 changed files with 49 additions and 50 deletions

View File

@ -3,7 +3,7 @@ using Throw;
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r08_ww/chassis/addtokencount.php")] [Route("/v12r08_ww/chassis/addtokencount_7547j3o4.php")]
[ApiController] [ApiController]
public class AddTokenCountController : BaseController<AddTokenCountController> public class AddTokenCountController : BaseController<AddTokenCountController>
{ {

View File

@ -5,7 +5,7 @@ using Throw;
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[ApiController] [ApiController]
[Route("/v12r08_ww/chassis/baidcheck.php")] [Route("/v12r08_ww/chassis/baidcheck_dcfxit1u.php")]
public class BaidController : BaseController<BaidController> public class BaidController : BaseController<BaidController>
{ {
private readonly IUserDatumService userDatumService; private readonly IUserDatumService userDatumService;

View File

@ -3,7 +3,7 @@ using TaikoLocalServer.Settings;
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r08_ww/chassis/crownsdata.php")] [Route("/v12r08_ww/chassis/crownsdata_oqgqy90s.php")]
[ApiController] [ApiController]
public class CrownsDataController : BaseController<CrownsDataController> public class CrownsDataController : BaseController<CrownsDataController>
{ {
@ -24,7 +24,7 @@ public class CrownsDataController : BaseController<CrownsDataController>
Logger.LogInformation("CrownsData request : {Request}", request.Stringify()); Logger.LogInformation("CrownsData request : {Request}", request.Stringify());
var songBestData = await songBestDatumService.GetAllSongBestData(request.Baid); var songBestData = await songBestDatumService.GetAllSongBestData(request.Baid);
var songIdMax = settings.EnableMoreSongs ? Constants.MUSIC_ID_MAX_EXPANDED : Constants.MUSIC_ID_MAX; var songIdMax = settings.EnableMoreSongs ? Constants.MUSIC_ID_MAX_EXPANDED : Constants.MUSIC_ID_MAX;
var crown = new ushort[songIdMax + 1]; var crown = new ushort[songIdMax + 1];
var dondafulCrown = new byte[songIdMax + 1]; var dondafulCrown = new byte[songIdMax + 1];
@ -38,7 +38,7 @@ public class CrownsDataController : BaseController<CrownsDataController>
datum.BestCrown == CrownType.Dondaful) datum.BestCrown == CrownType.Dondaful)
// Calculate flag according to difficulty // Calculate flag according to difficulty
.Aggregate((byte)0, (flag, datum) => FlagCalculator.ComputeDondafulCrownFlag(flag, datum.Difficulty)); .Aggregate((byte)0, (flag, datum) => FlagCalculator.ComputeDondafulCrownFlag(flag, datum.Difficulty));
crown[songId] = songBestData crown[songId] = songBestData
// Select song of this song id with clear or fc crown // Select song of this song id with clear or fc crown
.Where(datum => datum.SongId == id && .Where(datum => datum.SongId == id &&

View File

@ -1,6 +1,6 @@
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r08_ww/chassis/executeqrcode.php")] [Route("/v12r08_ww/chassis/executeqrcode_rgowsr5m.php")]
[ApiController] [ApiController]
public class ExecuteQrCodeController : BaseController<ExecuteQrCodeController> public class ExecuteQrCodeController : BaseController<ExecuteQrCodeController>
{ {

View File

@ -2,7 +2,7 @@
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r08_ww/chassis/getaidata.php")] [Route("/v12r08_ww/chassis/getaidata_6x30b9nr.php")]
[ApiController] [ApiController]
public class GetAiDataController : BaseController<GetAiDataController> public class GetAiDataController : BaseController<GetAiDataController>
{ {
@ -23,7 +23,7 @@ public class GetAiDataController : BaseController<GetAiDataController>
user.ThrowIfNull($"User with baid {request.Baid} does not exist!"); user.ThrowIfNull($"User with baid {request.Baid} does not exist!");
var response = new GetAiDataResponse var response = new GetAiDataResponse
{ {
Result = 1, Result = 1,
TotalWinnings = (uint)user.AiWinCount, TotalWinnings = (uint)user.AiWinCount,
InputMedian = "1000", InputMedian = "1000",
InputVariance = "2000" InputVariance = "2000"

View File

@ -2,7 +2,7 @@
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r08_ww/chassis/getaiscore.php")] [Route("/v12r08_ww/chassis/getaiscore_lp38po4w.php")]
[ApiController] [ApiController]
public class GetAiScoreController : BaseController<GetAiScoreController> public class GetAiScoreController : BaseController<GetAiScoreController>
{ {

View File

@ -3,7 +3,7 @@ using Throw;
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r08_ww/chassis/getdanscore.php")] [Route("/v12r08_ww/chassis/getdanscore_frqhg7q6.php")]
[ApiController] [ApiController]
public class GetDanScoreController : BaseController<GetDanScoreController> public class GetDanScoreController : BaseController<GetDanScoreController>
{ {
@ -44,7 +44,7 @@ public class GetDanScoreController : BaseController<GetDanScoreController>
{ {
responseData.AryDanScoreDataStages.Add(ObjectMappers.DanStageDbToResponseMap.Apply(stageScoreDatum)); responseData.AryDanScoreDataStages.Add(ObjectMappers.DanStageDbToResponseMap.Apply(stageScoreDatum));
} }
response.AryDanScoreDatas.Add(responseData); response.AryDanScoreDatas.Add(responseData);
} }

View File

@ -3,14 +3,14 @@ using TaikoLocalServer.Settings;
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r08_ww/chassis/getscorerank.php")] [Route("/v12r08_ww/chassis/getscorerank_1c8l7y61.php")]
[ApiController] [ApiController]
public class GetScoreRankController : BaseController<GetScoreRankController> public class GetScoreRankController : BaseController<GetScoreRankController>
{ {
private readonly ISongBestDatumService songBestDatumService; private readonly ISongBestDatumService songBestDatumService;
private readonly ServerSettings settings; private readonly ServerSettings settings;
public GetScoreRankController(ISongBestDatumService songBestDatumService, IOptions<ServerSettings> settings) public GetScoreRankController(ISongBestDatumService songBestDatumService, IOptions<ServerSettings> settings)
{ {
this.songBestDatumService = songBestDatumService; this.songBestDatumService = songBestDatumService;
@ -27,7 +27,7 @@ public class GetScoreRankController : BaseController<GetScoreRankController>
var miyabiScores = new ushort[songIdMax + 1]; var miyabiScores = new ushort[songIdMax + 1];
var ikiScores = new ushort[songIdMax + 1]; var ikiScores = new ushort[songIdMax + 1];
var songBestData = await songBestDatumService.GetAllSongBestData(request.Baid); var songBestData = await songBestDatumService.GetAllSongBestData(request.Baid);
for (var songId = 0; songId < songIdMax; songId++) for (var songId = 0; songId < songIdMax; songId++)
{ {
var id = songId; var id = songId;
@ -35,12 +35,12 @@ public class GetScoreRankController : BaseController<GetScoreRankController>
.Where(datum => datum.SongId == id && .Where(datum => datum.SongId == id &&
datum.BestScoreRank == ScoreRank.Dondaful) datum.BestScoreRank == ScoreRank.Dondaful)
.Aggregate((byte)0, (flag, datum) => FlagCalculator.ComputeKiwamiScoreRankFlag(flag, datum.Difficulty)); .Aggregate((byte)0, (flag, datum) => FlagCalculator.ComputeKiwamiScoreRankFlag(flag, datum.Difficulty));
ikiScores[songId] = songBestData ikiScores[songId] = songBestData
.Where(datum => datum.SongId == id && .Where(datum => datum.SongId == id &&
datum.BestScoreRank is ScoreRank.White or ScoreRank.Bronze or ScoreRank.Silver) datum.BestScoreRank is ScoreRank.White or ScoreRank.Bronze or ScoreRank.Silver)
.Aggregate((ushort)0, (flag, datum) => FlagCalculator.ComputeMiyabiOrIkiScoreRank(flag, datum.BestScoreRank, datum.Difficulty)); .Aggregate((ushort)0, (flag, datum) => FlagCalculator.ComputeMiyabiOrIkiScoreRank(flag, datum.BestScoreRank, datum.Difficulty));
miyabiScores[songId] = songBestData miyabiScores[songId] = songBestData
.Where(datum => datum.SongId == id && .Where(datum => datum.SongId == id &&
datum.BestScoreRank is ScoreRank.Gold or ScoreRank.Purple or ScoreRank.Sakura) datum.BestScoreRank is ScoreRank.Gold or ScoreRank.Purple or ScoreRank.Sakura)
@ -53,7 +53,7 @@ public class GetScoreRankController : BaseController<GetScoreRankController>
KiwamiScoreRankFlg = GZipBytesUtil.GetGZipBytes(kiwamiScores), KiwamiScoreRankFlg = GZipBytesUtil.GetGZipBytes(kiwamiScores),
MiyabiScoreRankFlg = GZipBytesUtil.GetGZipBytes(miyabiScores) MiyabiScoreRankFlg = GZipBytesUtil.GetGZipBytes(miyabiScores)
}; };
return Ok(response); return Ok(response);
} }
} }

View File

@ -1,6 +1,6 @@
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r08_ww/chassis/gettelop.php")] [Route("/v12r08_ww/chassis/gettelop_o0cb2z3e.php")]
[ApiController] [ApiController]
public class GetTelopController : BaseController<GetTelopController> public class GetTelopController : BaseController<GetTelopController>
{ {
@ -12,7 +12,7 @@ public class GetTelopController : BaseController<GetTelopController>
var startDateTime = DateTime.Now - TimeSpan.FromDays(999.0); var startDateTime = DateTime.Now - TimeSpan.FromDays(999.0);
var endDateTime = DateTime.Now + TimeSpan.FromDays(999.0); var endDateTime = DateTime.Now + TimeSpan.FromDays(999.0);
var response = new GettelopResponse var response = new GettelopResponse
{ {
Result = 1, Result = 1,

View File

@ -3,7 +3,7 @@ using Throw;
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r08_ww/chassis/gettokencount.php")] [Route("/v12r08_ww/chassis/gettokencount_iut9g23g.php")]
[ApiController] [ApiController]
public class GetTokenCountController : BaseController<GetTokenCountController> public class GetTokenCountController : BaseController<GetTokenCountController>
{ {
@ -15,7 +15,7 @@ public class GetTokenCountController : BaseController<GetTokenCountController>
this.userDatumService = userDatumService; this.userDatumService = userDatumService;
this.gameDataService = gameDataService; this.gameDataService = gameDataService;
} }
[HttpPost] [HttpPost]
[Produces("application/protobuf")] [Produces("application/protobuf")]
public async Task<IActionResult> GetTokenCount([FromBody] GetTokenCountRequest request) public async Task<IActionResult> GetTokenCount([FromBody] GetTokenCountRequest request)
@ -43,12 +43,12 @@ public class GetTokenCountController : BaseController<GetTokenCountController>
} }
tokenCountDict.ThrowIfNull("TokenCountDict should never be null"); tokenCountDict.ThrowIfNull("TokenCountDict should never be null");
var response = new GetTokenCountResponse var response = new GetTokenCountResponse
{ {
Result = 1 Result = 1
}; };
if (tokenCountDict.Count == 0) tokenCountDict.Add(1, 0); if (tokenCountDict.Count == 0) tokenCountDict.Add(1, 0);
if (shopTokenId > 0) if (shopTokenId > 0)
{ {
@ -71,7 +71,7 @@ public class GetTokenCountController : BaseController<GetTokenCountController>
TokenId = castedKaTokenId TokenId = castedKaTokenId
}); });
} }
if (onePieceTokenId > 0) if (onePieceTokenId > 0)
{ {
var castedOnePieceTokenId = (uint)onePieceTokenId; var castedOnePieceTokenId = (uint)onePieceTokenId;
@ -82,7 +82,7 @@ public class GetTokenCountController : BaseController<GetTokenCountController>
TokenId = castedOnePieceTokenId TokenId = castedOnePieceTokenId
}); });
} }
if (soshinaTokenId > 0) if (soshinaTokenId > 0)
{ {
var castedSoshinaTokenId = (uint)soshinaTokenId; var castedSoshinaTokenId = (uint)soshinaTokenId;
@ -96,7 +96,7 @@ public class GetTokenCountController : BaseController<GetTokenCountController>
user.TokenCountDict = JsonSerializer.Serialize(tokenCountDict); user.TokenCountDict = JsonSerializer.Serialize(tokenCountDict);
await userDatumService.UpdateUserDatum(user); await userDatumService.UpdateUserDatum(user);
return Ok(response); return Ok(response);
} }
} }

View File

@ -2,7 +2,7 @@
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r08_ww/chassis/mydonentry.php")] [Route("/v12r08_ww/chassis/mydonentry_3nrd7kwk.php")]
[ApiController] [ApiController]
public class MyDonEntryController : BaseController<MyDonEntryController> public class MyDonEntryController : BaseController<MyDonEntryController>
{ {

View File

@ -1,14 +1,13 @@
using System.Buffers.Binary; using GameDatabase.Entities;
using System.Globalization; using System.Globalization;
using System.Text.Json; using System.Text.Json;
using GameDatabase.Entities;
using Throw; using Throw;
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
using StageData = PlayResultDataRequest.StageData; using StageData = PlayResultDataRequest.StageData;
[Route("/v12r08_ww/chassis/playresult.php")] [Route("/v12r08_ww/chassis/playresult_r3ky4a4z.php")]
[ApiController] [ApiController]
public class PlayResultController : BaseController<PlayResultController> public class PlayResultController : BaseController<PlayResultController>
{ {
@ -73,11 +72,11 @@ public class PlayResultController : BaseController<PlayResultController>
await UpdateDanPlayData(request, playResultData, danType); await UpdateDanPlayData(request, playResultData, danType);
return Ok(response); return Ok(response);
} }
for (var songNumber = 0; songNumber < playResultData.AryStageInfoes.Count; songNumber++) for (var songNumber = 0; songNumber < playResultData.AryStageInfoes.Count; songNumber++)
{ {
var stageData = playResultData.AryStageInfoes[songNumber]; var stageData = playResultData.AryStageInfoes[songNumber];
if (stageData.IsSkipUse) if (stageData.IsSkipUse)
{ {
await UpdatePlayData(request, songNumber, stageData, lastPlayDatetime); await UpdatePlayData(request, songNumber, stageData, lastPlayDatetime);
@ -192,7 +191,7 @@ public class PlayResultController : BaseController<PlayResultController>
userdata.ThrowIfNull($"User data is null! Baid: {request.BaidConf}"); userdata.ThrowIfNull($"User data is null! Baid: {request.BaidConf}");
var playMode = (PlayMode)playResultData.PlayMode; var playMode = (PlayMode)playResultData.PlayMode;
userdata.Title = playResultData.Title; userdata.Title = playResultData.Title;
userdata.TitlePlateId = playResultData.TitleplateId; userdata.TitlePlateId = playResultData.TitleplateId;
var costumeData = new List<uint> var costumeData = new List<uint>
@ -246,7 +245,7 @@ public class PlayResultController : BaseController<PlayResultController>
playResultData.DifficultyPlayedSort playResultData.DifficultyPlayedSort
}; };
userdata.DifficultyPlayedArray = JsonSerializer.Serialize(difficultyPlayedArray); userdata.DifficultyPlayedArray = JsonSerializer.Serialize(difficultyPlayedArray);
userdata.AiWinCount += playResultData.AryStageInfoes.Count(data => data.IsWin); userdata.AiWinCount += playResultData.AryStageInfoes.Count(data => data.IsWin);
await userDatumService.UpdateUserDatum(userdata); await userDatumService.UpdateUserDatum(userdata);
} }
@ -335,12 +334,12 @@ public class PlayResultController : BaseController<PlayResultController>
await songBestDatumService.UpdateSongBestData(existing); await songBestDatumService.UpdateSongBestData(existing);
} }
private async Task UpdateAiBattleData(PlayResultRequest request, StageData stageData) private async Task UpdateAiBattleData(PlayResultRequest request, StageData stageData)
{ {
var difficulty = (Difficulty)stageData.Level; var difficulty = (Difficulty)stageData.Level;
difficulty.Throw().IfOutOfRange(); difficulty.Throw().IfOutOfRange();
var existing = await aiDatumService.GetSongAiScore(request.BaidConf, var existing = await aiDatumService.GetSongAiScore(request.BaidConf,
stageData.SongNo, difficulty); stageData.SongNo, difficulty);
if (existing is null) if (existing is null)
@ -370,7 +369,7 @@ public class PlayResultController : BaseController<PlayResultController>
} }
else else
{ {
AddNewAiSectionScore(request,stageData,index,difficulty,existing); AddNewAiSectionScore(request, stageData, index, difficulty, existing);
} }
} }

View File

@ -3,14 +3,14 @@ using Throw;
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r08_ww/chassis/selfbest.php")] [Route("/v12r08_ww/chassis/selfbest_5nz47auu.php")]
[ApiController] [ApiController]
public class SelfBestController : BaseController<SelfBestController> public class SelfBestController : BaseController<SelfBestController>
{ {
private readonly ISongBestDatumService songBestDatumService; private readonly ISongBestDatumService songBestDatumService;
private readonly IGameDataService gameDataService; private readonly IGameDataService gameDataService;
public SelfBestController(ISongBestDatumService songBestDatumService, IGameDataService gameDataService) public SelfBestController(ISongBestDatumService songBestDatumService, IGameDataService gameDataService)
{ {
this.songBestDatumService = songBestDatumService; this.songBestDatumService = songBestDatumService;
@ -28,10 +28,10 @@ public class SelfBestController : BaseController<SelfBestController>
Result = 1, Result = 1,
Level = request.Level Level = request.Level
}; };
var requestDifficulty = (Difficulty)request.Level; var requestDifficulty = (Difficulty)request.Level;
requestDifficulty.Throw().IfOutOfRange(); requestDifficulty.Throw().IfOutOfRange();
var playerBestData = await songBestDatumService.GetAllSongBestData(request.Baid); var playerBestData = await songBestDatumService.GetAllSongBestData(request.Baid);
playerBestData = playerBestData playerBestData = playerBestData
.Where(datum => datum.Difficulty == requestDifficulty || .Where(datum => datum.Difficulty == requestDifficulty ||
@ -50,7 +50,7 @@ public class SelfBestController : BaseController<SelfBestController>
response.ArySelfbestScores.Add(selfBestData); response.ArySelfbestScores.Add(selfBestData);
} }
response.ArySelfbestScores.Sort((data, otherData) => data.SongNo.CompareTo(otherData.SongNo)); response.ArySelfbestScores.Sort((data, otherData) => data.SongNo.CompareTo(otherData.SongNo));
return Ok(response); return Ok(response);
} }

View File

@ -3,7 +3,7 @@ using Throw;
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r08_ww/chassis/songpurchase.php")] [Route("/v12r08_ww/chassis/songpurchase_wm2fh5bl.php")]
[ApiController] [ApiController]
public class SongPurchaseController : BaseController<SongPurchaseController> public class SongPurchaseController : BaseController<SongPurchaseController>
{ {
@ -36,7 +36,7 @@ public class SongPurchaseController : BaseController<SongPurchaseController>
} }
tokenCountDict.ThrowIfNull("TokenCountDict should never be null"); tokenCountDict.ThrowIfNull("TokenCountDict should never be null");
Logger.LogInformation("Original UnlockedSongIdList: {UnlockedSongIdList}", user.UnlockedSongIdList); Logger.LogInformation("Original UnlockedSongIdList: {UnlockedSongIdList}", user.UnlockedSongIdList);
var unlockedSongIdList = new List<uint>(); var unlockedSongIdList = new List<uint>();
@ -59,9 +59,9 @@ public class SongPurchaseController : BaseController<SongPurchaseController>
user.TokenCountDict = JsonSerializer.Serialize(tokenCountDict); user.TokenCountDict = JsonSerializer.Serialize(tokenCountDict);
user.UnlockedSongIdList = JsonSerializer.Serialize(unlockedSongIdList); user.UnlockedSongIdList = JsonSerializer.Serialize(unlockedSongIdList);
Logger.LogInformation("Updated UnlockedSongIdList: {UnlockedSongIdList}", user.UnlockedSongIdList); Logger.LogInformation("Updated UnlockedSongIdList: {UnlockedSongIdList}", user.UnlockedSongIdList);
await userDatumService.UpdateUserDatum(user); await userDatumService.UpdateUserDatum(user);
var response = new SongPurchaseResponse var response = new SongPurchaseResponse

View File

@ -6,7 +6,7 @@ using Throw;
namespace TaikoLocalServer.Controllers.Game; namespace TaikoLocalServer.Controllers.Game;
[Route("/v12r08_ww/chassis/userdata.php")] [Route("/v12r08_ww/chassis/userdata_gc6x17o8.php")]
[ApiController] [ApiController]
public class UserDataController : BaseController<UserDataController> public class UserDataController : BaseController<UserDataController>
{ {
@ -36,7 +36,7 @@ public class UserDataController : BaseController<UserDataController>
var songIdMax = settings.EnableMoreSongs ? Constants.MUSIC_ID_MAX_EXPANDED : Constants.MUSIC_ID_MAX; var songIdMax = settings.EnableMoreSongs ? Constants.MUSIC_ID_MAX_EXPANDED : Constants.MUSIC_ID_MAX;
var userData = await userDatumService.GetFirstUserDatumOrDefault(request.Baid); var userData = await userDatumService.GetFirstUserDatumOrDefault(request.Baid);
var unlockedSongIdList = new List<uint>(); var unlockedSongIdList = new List<uint>();
try try
{ {
@ -50,7 +50,7 @@ public class UserDataController : BaseController<UserDataController>
} }
unlockedSongIdList.ThrowIfNull("UnlockedSongIdList should never be null"); unlockedSongIdList.ThrowIfNull("UnlockedSongIdList should never be null");
var musicList = gameDataService.GetMusicList(); var musicList = gameDataService.GetMusicList();
var lockedSongsList = gameDataService.GetLockedSongsList(); var lockedSongsList = gameDataService.GetLockedSongsList();
lockedSongsList = lockedSongsList.Except(unlockedSongIdList).ToList(); lockedSongsList = lockedSongsList.Except(unlockedSongIdList).ToList();
@ -76,7 +76,7 @@ public class UserDataController : BaseController<UserDataController>
// The only way to get a null is provide string "null" as input, // The only way to get a null is provide string "null" as input,
// which means database content need to be fixed, so better throw // which means database content need to be fixed, so better throw
toneFlg.ThrowIfNull("Tone flg should never be null!"); toneFlg.ThrowIfNull("Tone flg should never be null!");
// If toneFlg is empty, add 0 to it // If toneFlg is empty, add 0 to it
if (toneFlg.Length == 0) if (toneFlg.Length == 0)
{ {