Use base controller for logger service
Add shared project
This commit is contained in:
parent
a5b8bb10ff
commit
94e3d03762
14
Shared/Shared.projitems
Normal file
14
Shared/Shared.projitems
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
<HasSharedItems>true</HasSharedItems>
|
||||
<SharedGUID>29FAECCD-4C19-44F3-963F-6535BE962E2E</SharedGUID>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Configuration">
|
||||
<Import_RootNamespace>Shared</Import_RootNamespace>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="$(MSBuildThisFileDirectory)Models" />
|
||||
</ItemGroup>
|
||||
</Project>
|
11
Shared/Shared.shproj
Normal file
11
Shared/Shared.shproj
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{739247D2-9B9B-45DE-A97F-216E0D97930C}</ProjectGuid>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
|
||||
<Import Project="Shared.projitems" Label="Shared" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
|
||||
</Project>
|
@ -5,6 +5,8 @@ VisualStudioVersion = 17.0.32112.339
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TaikoLocalServer", "TaikoLocalServer\TaikoLocalServer.csproj", "{98FDA12C-CD3C-42D0-BEBE-4E809E6E41AC}"
|
||||
EndProject
|
||||
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Shared", "Shared\Shared.shproj", "{739247D2-9B9B-45DE-A97F-216E0D97930C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -2,15 +2,19 @@
|
||||
|
||||
namespace TaikoLocalServer.Common.Utils;
|
||||
|
||||
using DanScoreDataStage = GetDanScoreResponse.DanScoreData.DanScoreDataStage;
|
||||
|
||||
public static class ObjectMappers
|
||||
{
|
||||
|
||||
public static readonly IObjectMap<DanStageScoreDatum, GetDanScoreResponse.DanScoreData.DanScoreDataStage> DanStageDataMap;
|
||||
public static readonly IObjectMap<DanStageScoreDatum, DanScoreDataStage> DanStageDbToResponseMap;
|
||||
|
||||
public static readonly IObjectMap<DanScoreDataStage, DanStageScoreDatum> DanStageResponseToDbMap;
|
||||
|
||||
static ObjectMappers()
|
||||
{
|
||||
var mapper = new ObjectMapper();
|
||||
DanStageDataMap = mapper.AddMap<DanStageScoreDatum, GetDanScoreResponse.DanScoreData.DanScoreDataStage>()
|
||||
DanStageDbToResponseMap = mapper.AddMap<DanStageScoreDatum, DanScoreDataStage>()
|
||||
.Add(t => t.ComboCnt, s => s.ComboCount)
|
||||
.Add(t => t.GoodCnt, s => s.GoodCount)
|
||||
.Add(t => t.OkCnt, s => s.OkCount)
|
||||
@ -19,5 +23,15 @@ public static class ObjectMappers
|
||||
.Add(t => t.PoundCnt, s => s.DrumrollCount)
|
||||
.Add(t => t.PlayScore, s => s.PlayScore)
|
||||
.Add(t => t.HighScore, s => s.HighScore);
|
||||
|
||||
DanStageResponseToDbMap = mapper.AddMap<DanScoreDataStage, DanStageScoreDatum>()
|
||||
.Add(t => t.ComboCount, s => s.ComboCnt)
|
||||
.Add(t => t.GoodCount, s => s.GoodCnt)
|
||||
.Add(t => t.OkCount, s => s.OkCnt)
|
||||
.Add(t => t.BadCount, s => s.NgCnt)
|
||||
.Add(t => t.TotalHitCount, s => s.HitCnt)
|
||||
.Add(t => t.DrumrollCount, s => s.PoundCnt)
|
||||
.Add(t => t.PlayScore, s => s.PlayScore)
|
||||
.Add(t => t.HighScore, s => s.HighScore);
|
||||
}
|
||||
}
|
@ -1,27 +1,21 @@
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
namespace TaikoLocalServer.Controllers.AmAuth;
|
||||
|
||||
[ApiController]
|
||||
[Route("/sys/servlet/PowerOn")]
|
||||
public class PowerOnController : ControllerBase
|
||||
public class PowerOnController : BaseController<PowerOnController>
|
||||
{
|
||||
private const string HostStartup = "vsapi.taiko-p.jp";
|
||||
|
||||
private readonly ILogger<PowerOnController> logger;
|
||||
|
||||
public PowerOnController(ILogger<PowerOnController> logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
private const string HOST_STARTUP = "vsapi.taiko-p.jp";
|
||||
|
||||
[HttpPost]
|
||||
public ContentResult PowerOn([FromForm] PowerOnRequest request)
|
||||
{
|
||||
logger.LogInformation("Power on request: {Request}",request.Stringify());
|
||||
Logger.LogInformation("Power on request: {Request}",request.Stringify());
|
||||
var now = DateTime.Now;
|
||||
var response = new Dictionary<string, string>
|
||||
{
|
||||
{"stat", "1"},
|
||||
{"uri", HostStartup},
|
||||
{"host", HostStartup},
|
||||
{"uri", HOST_STARTUP},
|
||||
{"host", HOST_STARTUP},
|
||||
{"place_id", "JPN0123"},
|
||||
{"name", "NAMCO"},
|
||||
{"nickname", "NAMCO"},
|
@ -1,18 +1,14 @@
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
namespace TaikoLocalServer.Controllers.AmUpdater;
|
||||
|
||||
public class MuchaController : ControllerBase
|
||||
public class MuchaController : BaseController<MuchaController>
|
||||
{
|
||||
private const string UrlBase = "https://v402-front.mucha-prd.nbgi-amnet.jp:10122";
|
||||
private readonly ILogger<MuchaController> logger;
|
||||
public MuchaController(ILogger<MuchaController> logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
private const string URL_BASE = "https://v402-front.mucha-prd.nbgi-amnet.jp:10122";
|
||||
|
||||
[HttpPost("/mucha_front/boardauth.do")]
|
||||
|
||||
public ContentResult BoardAuth([FromForm] MuchaUpdateCheckRequest request)
|
||||
{
|
||||
logger.LogInformation("Mucha request: {Request}", request.Stringify());
|
||||
Logger.LogInformation("Mucha request: {Request}", request.Stringify());
|
||||
var serverTime = DateTime.Now.ToString("yyyyMMddHHmm");
|
||||
var utcServerTime = DateTime.UtcNow.ToString("yyyyMMddHHmm");
|
||||
var response = new Dictionary<string, string>
|
||||
@ -35,12 +31,12 @@ public class MuchaController : ControllerBase
|
||||
{ "AREA_FULL_3", "" },
|
||||
{ "AREA_FULL_3_EN", "" },
|
||||
{ "AUTH_INTERVAL", "86400" },
|
||||
{ "CHARGE_URL", $"{UrlBase}/charge/" },
|
||||
{ "CHARGE_URL", $"{URL_BASE}/charge/" },
|
||||
{ "CONSUME_TOKEN", "0" },
|
||||
{ "COUNTRY_CD", "JPN" },
|
||||
{ "DONGLE_FLG", "1" },
|
||||
{ "EXPIRATION_DATE", "null" },
|
||||
{ "FILE_URL", $"{UrlBase}/file/" },
|
||||
{ "FILE_URL", $"{URL_BASE}/file/" },
|
||||
{ "FORCE_BOOT", "0" },
|
||||
{ "PLACE_ID", request.PlaceId ?? "" },
|
||||
{ "PREFECTURE_ID", "14" },
|
||||
@ -50,9 +46,9 @@ public class MuchaController : ControllerBase
|
||||
{ "SHOP_NAME_EN", "NAMCO" },
|
||||
{ "SHOP_NICKNAME", "W" },
|
||||
{ "SHOP_NICKNAME_EN", "W" },
|
||||
{ "URL_1", $"{UrlBase}/url1/" },
|
||||
{ "URL_2", $"{UrlBase}/url2/" },
|
||||
{ "URL_3", $"{UrlBase}/url3/" },
|
||||
{ "URL_1", $"{URL_BASE}/url1/" },
|
||||
{ "URL_2", $"{URL_BASE}/url2/" },
|
||||
{ "URL_3", $"{URL_BASE}/url3/" },
|
||||
{ "USE_TOKEN", "0" }
|
||||
};
|
||||
var formOutput = FormOutputUtil.ToFormOutput(response);
|
||||
@ -62,15 +58,15 @@ public class MuchaController : ControllerBase
|
||||
[HttpPost("/mucha_front/updatacheck.do")]
|
||||
public ContentResult UpdateCheck(MuchaBoardAuthRequest request)
|
||||
{
|
||||
logger.LogInformation("Request is {Request}", request.Stringify());
|
||||
Logger.LogInformation("Request is {Request}", request.Stringify());
|
||||
var response = new Dictionary<string, string>
|
||||
{
|
||||
{ "RESULTS", "001" },
|
||||
{ "UPDATE_VER_1", request.GameVersion ?? "S1210JPN08.18" },
|
||||
{ "UPDATE_URL_1", $"{UrlBase}/updUrl1/" },
|
||||
{ "UPDATE_URL_1", $"{URL_BASE}/updUrl1/" },
|
||||
{ "UPDATE_SIZE_1", "0" },
|
||||
{ "UPDATE_CRC_1", "0000000000000000" },
|
||||
{ "CHECK_URL_1", $"{UrlBase}/checkUrl/" },
|
||||
{ "CHECK_URL_1", $"{URL_BASE}/checkUrl/" },
|
||||
{ "EXE_VER_1", request.GameVersion ?? "S1210JPN08.18" },
|
||||
{ "INFO_SIZE_1", "0" },
|
||||
{ "COM_SIZE_1", "0" },
|
8
TaikoLocalServer/Controllers/Api/DashboardController.cs
Normal file
8
TaikoLocalServer/Controllers/Api/DashboardController.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace TaikoLocalServer.Controllers.Api;
|
||||
|
||||
[ApiController]
|
||||
[Route("/api/[controller]")]
|
||||
public class DashboardController : BaseController<DashboardController>
|
||||
{
|
||||
|
||||
}
|
8
TaikoLocalServer/Controllers/BaseController.cs
Normal file
8
TaikoLocalServer/Controllers/BaseController.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
|
||||
public abstract class BaseController<T> : ControllerBase where T : BaseController<T>
|
||||
{
|
||||
private ILogger<T>? logger;
|
||||
|
||||
protected ILogger<T> Logger => (logger ??= HttpContext.RequestServices.GetService<ILogger<T>>()) ?? throw new InvalidOperationException();
|
||||
}
|
@ -1,19 +1,14 @@
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[Route("/v12r03/chassis/addtokencount.php")]
|
||||
[ApiController]
|
||||
public class AddTokenCountController : ControllerBase
|
||||
public class AddTokenCountController : BaseController<AddTokenCountController>
|
||||
{
|
||||
private readonly ILogger<AddTokenCountController> logger;
|
||||
public AddTokenCountController(ILogger<AddTokenCountController> logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult AddTokenCount([FromBody] AddTokenCountRequest request)
|
||||
{
|
||||
logger.LogInformation("AddTokenCount request : {Request}", request.Stringify());
|
||||
Logger.LogInformation("AddTokenCount request : {Request}", request.Stringify());
|
||||
|
||||
var response = new AddTokenCountResponse
|
||||
{
|
@ -1,18 +1,15 @@
|
||||
using System.Text.Json;
|
||||
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[ApiController]
|
||||
[Route("/v12r03/chassis/baidcheck.php")]
|
||||
public class BaidController:ControllerBase
|
||||
public class BaidController : BaseController<BaidController>
|
||||
{
|
||||
private readonly ILogger<BaidController> logger;
|
||||
|
||||
private readonly TaikoDbContext context;
|
||||
|
||||
public BaidController(ILogger<BaidController> logger, TaikoDbContext context)
|
||||
public BaidController(TaikoDbContext context)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@ -21,11 +18,11 @@ public class BaidController:ControllerBase
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult GetBaid([FromBody] BAIDRequest request)
|
||||
{
|
||||
logger.LogInformation("Baid request: {Request}", request.Stringify());
|
||||
Logger.LogInformation("Baid request: {Request}", request.Stringify());
|
||||
BAIDResponse response;
|
||||
if (!context.Cards.Any(card => card.AccessCode == request.AccessCode))
|
||||
{
|
||||
logger.LogInformation("New user from access code {AccessCode}", request.AccessCode);
|
||||
Logger.LogInformation("New user from access code {AccessCode}", request.AccessCode);
|
||||
var newId = context.Cards.Any() ? context.Cards.Max(card => card.Baid) + 1 : 1;
|
||||
|
||||
response = new BAIDResponse
|
||||
@ -94,11 +91,11 @@ public class BaidController:ControllerBase
|
||||
}
|
||||
catch (JsonException e)
|
||||
{
|
||||
logger.LogError(e, "Parsing costume json data failed");
|
||||
Logger.LogError(e, "Parsing costume json data failed");
|
||||
}
|
||||
if (costumeData == null || costumeData.Count < 5)
|
||||
{
|
||||
logger.LogWarning("Costume data is null or count less than 5!");
|
||||
Logger.LogWarning("Costume data is null or count less than 5!");
|
||||
costumeData = new List<uint> { 0, 0, 0, 0, 0 };
|
||||
}
|
||||
|
||||
@ -114,7 +111,7 @@ public class BaidController:ControllerBase
|
||||
.DefaultIfEmpty()
|
||||
.Max();
|
||||
var gotDanFlagArray = FlagCalculator.ComputeGotDanFlags(danData);
|
||||
logger.LogInformation("Got dan array {Array}", gotDanFlagArray.Stringify());
|
||||
Logger.LogInformation("Got dan array {Array}", gotDanFlagArray.Stringify());
|
||||
|
||||
response = new BAIDResponse
|
||||
{
|
@ -1,19 +1,14 @@
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[ApiController]
|
||||
[Route("/v12r03/chassis/bookkeeping.php")]
|
||||
public class BookkeepingController : ControllerBase
|
||||
public class BookkeepingController : BaseController<BookkeepingController>
|
||||
{
|
||||
private readonly ILogger<BookkeepingController> logger;
|
||||
public BookkeepingController(ILogger<BookkeepingController> logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult StartupAuth([FromBody] BookKeepingRequest request)
|
||||
{
|
||||
logger.LogInformation("Bookkeeping request: {Request}", request.Stringify());
|
||||
Logger.LogInformation("Bookkeeping request: {Request}", request.Stringify());
|
||||
var response = new BookKeepingResponse
|
||||
{
|
||||
Result = 1
|
@ -1,19 +1,14 @@
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[Route("/v12r03/chassis/challengecompe.php")]
|
||||
[ApiController]
|
||||
public class ChallengeCompetitionController : ControllerBase
|
||||
public class ChallengeCompetitionController : BaseController<ChallengeCompetitionController>
|
||||
{
|
||||
private readonly ILogger<ChallengeCompetitionController> logger;
|
||||
public ChallengeCompetitionController(ILogger<ChallengeCompetitionController> logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult HandleChallenge([FromBody] ChallengeCompeRequest request)
|
||||
{
|
||||
logger.LogInformation("ChallengeCompe request : {Request}", request.Stringify());
|
||||
Logger.LogInformation("ChallengeCompe request : {Request}", request.Stringify());
|
||||
|
||||
var response = new ChallengeCompeResponse
|
||||
{
|
@ -1,16 +1,13 @@
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[Route("/v12r03/chassis/crownsdata.php")]
|
||||
[ApiController]
|
||||
public class CrownsDataController : ControllerBase
|
||||
public class CrownsDataController : BaseController<CrownsDataController>
|
||||
{
|
||||
private readonly ILogger<CrownsDataController> logger;
|
||||
|
||||
private readonly TaikoDbContext context;
|
||||
|
||||
public CrownsDataController(ILogger<CrownsDataController> logger, TaikoDbContext context)
|
||||
public CrownsDataController(TaikoDbContext context)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@ -18,7 +15,7 @@ public class CrownsDataController : ControllerBase
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult CrownsData([FromBody] CrownsDataRequest request)
|
||||
{
|
||||
logger.LogInformation("CrownsData request : {Request}", request.Stringify());
|
||||
Logger.LogInformation("CrownsData request : {Request}", request.Stringify());
|
||||
|
||||
var songBestData = context.SongBestData.Where(datum => datum.Baid == request.Baid).ToList();
|
||||
|
@ -1,19 +1,14 @@
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[Route("/v12r03/chassis/executeqrcode.php")]
|
||||
[ApiController]
|
||||
public class ExecuteQrCodeController : ControllerBase
|
||||
public class ExecuteQrCodeController : BaseController<ExecuteQrCodeController>
|
||||
{
|
||||
private readonly ILogger<ExecuteQrCodeController> logger;
|
||||
public ExecuteQrCodeController(ILogger<ExecuteQrCodeController> logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult ExecuteQrCode([FromBody] ExecuteQrcodeRequest request)
|
||||
{
|
||||
logger.LogInformation("ExecuteQrcode request : {Request}", request.Stringify());
|
||||
Logger.LogInformation("ExecuteQrcode request : {Request}", request.Stringify());
|
||||
|
||||
var response = new ExecuteQrcodeResponse
|
||||
{
|
@ -1,19 +1,14 @@
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[Route("/v12r03/chassis/getaidata.php")]
|
||||
[ApiController]
|
||||
public class GetAiDataController : ControllerBase
|
||||
public class GetAiDataController : BaseController<GetAiDataController>
|
||||
{
|
||||
private readonly ILogger<GetAiDataController> logger;
|
||||
public GetAiDataController(ILogger<GetAiDataController> logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult GetAiData([FromBody] GetAiDataRequest request)
|
||||
{
|
||||
logger.LogInformation("GetAiData request : {Request}", request.Stringify());
|
||||
Logger.LogInformation("GetAiData request : {Request}", request.Stringify());
|
||||
|
||||
var response = new GetAiDataResponse
|
||||
{
|
@ -1,19 +1,14 @@
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[Route("/v12r03/chassis/getaiscore.php")]
|
||||
[ApiController]
|
||||
public class GetAiScoreController : ControllerBase
|
||||
public class GetAiScoreController : BaseController<GetAiScoreController>
|
||||
{
|
||||
private readonly ILogger<GetAiScoreController> logger;
|
||||
public GetAiScoreController(ILogger<GetAiScoreController> logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult GetAiScore([FromBody] GetAiScoreRequest request)
|
||||
{
|
||||
logger.LogInformation("GetAiScore request : {Request}", request.Stringify());
|
||||
Logger.LogInformation("GetAiScore request : {Request}", request.Stringify());
|
||||
|
||||
var response = new GetAiScoreResponse
|
||||
{
|
@ -0,0 +1,23 @@
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[Route("/v12r03/chassis/getapplicationurl.php")]
|
||||
[ApiController]
|
||||
public class GetApplicationUrlController : BaseController<GetApplicationUrlController>
|
||||
{
|
||||
private const string APPLICATION_URL = "vsapi.taiko-p.jp";
|
||||
|
||||
[HttpPost]
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult GetApplicationUrl([FromBody] GetApplicationUrlRequest request)
|
||||
{
|
||||
Logger.LogInformation("GetApplicationUrl request : {Request}", request.Stringify());
|
||||
|
||||
var response = new GetApplicationUrlResponse
|
||||
{
|
||||
Result = 1,
|
||||
ApplicationUrl = APPLICATION_URL
|
||||
};
|
||||
|
||||
return Ok(response);
|
||||
}
|
||||
}
|
@ -1,19 +1,14 @@
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[Route("/v12r03/chassis/getdanodai.php")]
|
||||
[ApiController]
|
||||
public class GetDanOdaiController : ControllerBase
|
||||
public class GetDanOdaiController : BaseController<GetDanOdaiController>
|
||||
{
|
||||
private readonly ILogger<GetDanOdaiController> logger;
|
||||
public GetDanOdaiController(ILogger<GetDanOdaiController> logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult GetDanOdai([FromBody] GetDanOdaiRequest request)
|
||||
{
|
||||
logger.LogInformation("GetDanOdai request : {Request}", request.Stringify());
|
||||
Logger.LogInformation("GetDanOdai request : {Request}", request.Stringify());
|
||||
|
||||
var response = new GetDanOdaiResponse
|
||||
{
|
||||
@ -31,7 +26,7 @@ public class GetDanOdaiController : ControllerBase
|
||||
manager.OdaiDataList.TryGetValue(danId, out var odaiData);
|
||||
if (odaiData is null)
|
||||
{
|
||||
logger.LogWarning("Requested dan id {Id} does not exist!", danId);
|
||||
Logger.LogWarning("Requested dan id {Id} does not exist!", danId);
|
||||
continue;
|
||||
}
|
||||
|
@ -1,16 +1,13 @@
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[Route("/v12r03/chassis/getdanscore.php")]
|
||||
[ApiController]
|
||||
public class GetDanScoreController : ControllerBase
|
||||
public class GetDanScoreController : BaseController<GetDanScoreController>
|
||||
{
|
||||
private readonly ILogger<GetDanScoreController> logger;
|
||||
|
||||
private readonly TaikoDbContext context;
|
||||
|
||||
public GetDanScoreController(ILogger<GetDanScoreController> logger, TaikoDbContext context)
|
||||
public GetDanScoreController(TaikoDbContext context)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@ -18,7 +15,7 @@ public class GetDanScoreController : ControllerBase
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult GetDanScore([FromBody] GetDanScoreRequest request)
|
||||
{
|
||||
logger.LogInformation("GetDanScore request : {Request}", request.Stringify());
|
||||
Logger.LogInformation("GetDanScore request : {Request}", request.Stringify());
|
||||
|
||||
var response = new GetDanScoreResponse
|
||||
{
|
||||
@ -43,7 +40,7 @@ public class GetDanScoreController : ControllerBase
|
||||
};
|
||||
foreach (var stageScoreDatum in datum.DanStageScoreData)
|
||||
{
|
||||
responseData.AryDanScoreDataStages.Add(ObjectMappers.DanStageDataMap.Apply(stageScoreDatum));
|
||||
responseData.AryDanScoreDataStages.Add(ObjectMappers.DanStageDbToResponseMap.Apply(stageScoreDatum));
|
||||
}
|
||||
|
||||
response.AryDanScoreDatas.Add(responseData);
|
@ -1,19 +1,14 @@
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[Route("/v12r03/chassis/getfolder.php")]
|
||||
[ApiController]
|
||||
public class GetFolderController : ControllerBase
|
||||
public class GetFolderController : BaseController<GetFolderController>
|
||||
{
|
||||
private readonly ILogger<GetFolderController> logger;
|
||||
public GetFolderController(ILogger<GetFolderController> logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult GetFolder([FromBody] GetfolderRequest request)
|
||||
{
|
||||
logger.LogInformation("GetFolder request : {Request}", request.Stringify());
|
||||
Logger.LogInformation("GetFolder request : {Request}", request.Stringify());
|
||||
|
||||
var response = new GetfolderResponse
|
||||
{
|
@ -1,16 +1,13 @@
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[Route("/v12r03/chassis/getscorerank.php")]
|
||||
[ApiController]
|
||||
public class GetScoreRankController : ControllerBase
|
||||
public class GetScoreRankController : BaseController<GetScoreRankController>
|
||||
{
|
||||
private readonly ILogger<GetScoreRankController> logger;
|
||||
|
||||
private readonly TaikoDbContext context;
|
||||
|
||||
public GetScoreRankController(ILogger<GetScoreRankController> logger, TaikoDbContext context)
|
||||
public GetScoreRankController(TaikoDbContext context)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@ -18,7 +15,7 @@ public class GetScoreRankController : ControllerBase
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult GetScoreRank([FromBody] GetScoreRankRequest request)
|
||||
{
|
||||
logger.LogInformation("GetScoreRank request : {Request}", request.Stringify());
|
||||
Logger.LogInformation("GetScoreRank request : {Request}", request.Stringify());
|
||||
var kiwamiScores = new byte[Constants.KIWAMI_SCORE_RANK_ARRAY_SIZE];
|
||||
var miyabiScores = new ushort[Constants.MIYABI_CORE_RANK_ARRAY_SIZE];
|
||||
var ikiScores = new ushort[Constants.IKI_CORE_RANK_ARRAY_SIZE];
|
@ -1,19 +1,14 @@
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[Route("/v12r03/chassis/getshopfolder.php")]
|
||||
[ApiController]
|
||||
public class GetShopFolderController : ControllerBase
|
||||
public class GetShopFolderController : BaseController<GetShopFolderController>
|
||||
{
|
||||
private readonly ILogger<GetShopFolderController> logger;
|
||||
public GetShopFolderController(ILogger<GetShopFolderController> logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult GetShopFolder([FromBody] GetShopFolderRequest request)
|
||||
{
|
||||
logger.LogInformation("GetShopFolder request : {Request}", request.Stringify());
|
||||
Logger.LogInformation("GetShopFolder request : {Request}", request.Stringify());
|
||||
|
||||
var response = new GetShopFolderResponse
|
||||
{
|
@ -1,19 +1,14 @@
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[Route("/v12r03/chassis/getsongintroduction.php")]
|
||||
[ApiController]
|
||||
public class GetSongIntroductionController : ControllerBase
|
||||
public class GetSongIntroductionController : BaseController<GetSongIntroductionController>
|
||||
{
|
||||
private readonly ILogger<GetSongIntroductionController> logger;
|
||||
public GetSongIntroductionController(ILogger<GetSongIntroductionController> logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult GetSongIntroduction([FromBody] GetSongIntroductionRequest request)
|
||||
{
|
||||
logger.LogInformation("GetSongIntroduction request : {Request}", request.Stringify());
|
||||
Logger.LogInformation("GetSongIntroduction request : {Request}", request.Stringify());
|
||||
|
||||
var response = new GetSongIntroductionResponse
|
||||
{
|
@ -1,19 +1,14 @@
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[Route("/v12r03/chassis/gettelop.php")]
|
||||
[ApiController]
|
||||
public class GetTelopController : ControllerBase
|
||||
public class GetTelopController : BaseController<GetTelopController>
|
||||
{
|
||||
private readonly ILogger<GetTelopController> logger;
|
||||
public GetTelopController(ILogger<GetTelopController> logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult GetTelop([FromBody] GettelopRequest request)
|
||||
{
|
||||
logger.LogInformation("GetTelop request : {Request}", request.Stringify());
|
||||
Logger.LogInformation("GetTelop request : {Request}", request.Stringify());
|
||||
|
||||
var startDateTime = DateTime.Now - TimeSpan.FromDays(999.0);
|
||||
var endDateTime = DateTime.Now + TimeSpan.FromDays(999.0);
|
@ -1,19 +1,14 @@
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[Route("/v12r03/chassis/gettokencount.php")]
|
||||
[ApiController]
|
||||
public class GetTokenCountController : ControllerBase
|
||||
public class GetTokenCountController : BaseController<GetTokenCountController>
|
||||
{
|
||||
private readonly ILogger<GetTokenCountController> logger;
|
||||
public GetTokenCountController(ILogger<GetTokenCountController> logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult GetTokenCount([FromBody] GetTokenCountRequest request)
|
||||
{
|
||||
logger.LogInformation("GetTokenCount request : {Request}", request.Stringify());
|
||||
Logger.LogInformation("GetTokenCount request : {Request}", request.Stringify());
|
||||
|
||||
var response = new GetTokenCountResponse
|
||||
{
|
@ -1,20 +1,14 @@
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[ApiController]
|
||||
[Route("/v12r03/chassis/heartbeat.php")]
|
||||
public class HeartbeatController : ControllerBase
|
||||
public class HeartbeatController : BaseController<HeartbeatController>
|
||||
{
|
||||
private readonly ILogger<HeartbeatController> logger;
|
||||
|
||||
public HeartbeatController(ILogger<HeartbeatController> logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult HeartBeat([FromBody] HeartBeatRequest request)
|
||||
{
|
||||
logger.LogInformation("Heartbeat request: {Request}", request.Stringify());
|
||||
Logger.LogInformation("Heartbeat request: {Request}", request.Stringify());
|
||||
var response = new HeartBeatResponse
|
||||
{
|
||||
Result = 1,
|
@ -1,24 +1,16 @@
|
||||
using System.Collections;
|
||||
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[ApiController]
|
||||
[Route("/v12r03/chassis/initialdatacheck.php")]
|
||||
public class InitialDataCheckController : ControllerBase
|
||||
public class InitialDataCheckController : BaseController<InitialDataCheckController>
|
||||
{
|
||||
private readonly ILogger<InitialDataCheckController> logger;
|
||||
|
||||
public InitialDataCheckController(ILogger<InitialDataCheckController> logger)
|
||||
{
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult InitialDataCheck([FromBody] InitialdatacheckRequest request)
|
||||
{
|
||||
logger.LogInformation("Initial data check request: {Request}", request.Stringify());
|
||||
Logger.LogInformation("Initial data check request: {Request}", request.Stringify());
|
||||
|
||||
var musicAttributeManager = MusicAttributeManager.Instance;
|
||||
|
||||
@ -46,7 +38,6 @@ public class InitialDataCheckController : ControllerBase
|
||||
IsDanplay = true,
|
||||
IsAibattle = false,
|
||||
IsClose = false,
|
||||
//SongIntroductionEndDatetime = (DateTime.Now + TimeSpan.FromDays(999)).ToString(Constants.DATE_TIME_FORMAT),
|
||||
DefaultSongFlg = enabledArray,
|
||||
AchievementSongBit = enabledArray,
|
||||
AryShopFolderDatas =
|
@ -1,16 +1,13 @@
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[Route("/v12r03/chassis/mydonentry.php")]
|
||||
[ApiController]
|
||||
public class MyDonEntryController : ControllerBase
|
||||
public class MyDonEntryController : BaseController<MyDonEntryController>
|
||||
{
|
||||
private readonly ILogger<MyDonEntryController> logger;
|
||||
|
||||
private readonly TaikoDbContext context;
|
||||
|
||||
public MyDonEntryController(ILogger<MyDonEntryController> logger, TaikoDbContext context)
|
||||
public MyDonEntryController(TaikoDbContext context)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@ -18,7 +15,7 @@ public class MyDonEntryController : ControllerBase
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult GetMyDonEntry([FromBody] MydonEntryRequest request)
|
||||
{
|
||||
logger.LogInformation("MyDonEntry request : {Request}", request.Stringify());
|
||||
Logger.LogInformation("MyDonEntry request : {Request}", request.Stringify());
|
||||
|
||||
var newId = context.Cards.Any() ? context.Cards.Max(card => card.Baid) + 1 : 1;
|
||||
context.Cards.Add(new Card
|
||||
@ -26,6 +23,7 @@ public class MyDonEntryController : ControllerBase
|
||||
AccessCode = request.AccessCode,
|
||||
Baid = newId
|
||||
});
|
||||
|
||||
context.UserData.Add(new UserDatum
|
||||
{
|
||||
Baid = newId,
|
||||
@ -35,7 +33,8 @@ public class MyDonEntryController : ControllerBase
|
||||
AchievementDisplayDifficulty = Difficulty.None,
|
||||
ColorFace = 0,
|
||||
ColorBody = 1,
|
||||
ColorLimb = 3
|
||||
ColorLimb = 3,
|
||||
FavoriteSongsArray = "{}"
|
||||
});
|
||||
context.SaveChanges();
|
||||
|
@ -1,19 +1,16 @@
|
||||
using System.Globalization;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[Route("/v12r03/chassis/playresult.php")]
|
||||
[ApiController]
|
||||
public class PlayResultController : ControllerBase
|
||||
public class PlayResultController : BaseController<PlayResultController>
|
||||
{
|
||||
private readonly ILogger<PlayResultController> logger;
|
||||
|
||||
private readonly TaikoDbContext context;
|
||||
|
||||
public PlayResultController(ILogger<PlayResultController> logger, TaikoDbContext context)
|
||||
public PlayResultController(TaikoDbContext context)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@ -21,12 +18,12 @@ public class PlayResultController : ControllerBase
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult UploadPlayResult([FromBody] PlayResultRequest request)
|
||||
{
|
||||
logger.LogInformation("PlayResult request : {Request}", request.Stringify());
|
||||
Logger.LogInformation("PlayResult request : {Request}", request.Stringify());
|
||||
var decompressed = GZipBytesUtil.DecompressGZipBytes(request.PlayresultData);
|
||||
|
||||
var playResultData = Serializer.Deserialize<PlayResultDataRequest>(new ReadOnlySpan<byte>(decompressed));
|
||||
|
||||
logger.LogInformation("Play result data {Data}", playResultData.Stringify());
|
||||
Logger.LogInformation("Play result data {Data}", playResultData.Stringify());
|
||||
|
||||
var response = new PlayResultResponse
|
||||
{
|
||||
@ -63,6 +60,7 @@ public class PlayResultController : ControllerBase
|
||||
{
|
||||
if (playResultDataRequest.IsNotRecordedDan)
|
||||
{
|
||||
Logger.LogInformation("Dan score will not be saved!");
|
||||
return;
|
||||
}
|
||||
var danScoreDataQuery = context.DanScoreData
|
||||
@ -113,18 +111,13 @@ public class PlayResultController : ControllerBase
|
||||
add = false;
|
||||
}
|
||||
|
||||
// FIXME: Add proper logic for high score update
|
||||
if (danStageData.HighScore >= stageData.PlayScore)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
danStageData.GoodCount = stageData.GoodCnt;
|
||||
danStageData.OkCount = stageData.OkCnt;
|
||||
danStageData.BadCount = stageData.NgCnt;
|
||||
danStageData.PlayScore = stageData.PlayScore;
|
||||
danStageData.HighScore = stageData.PlayScore;
|
||||
danStageData.ComboCount = stageData.ComboCnt;
|
||||
danStageData.TotalHitCount = stageData.HitCnt;
|
||||
danStageData.DrumrollCount = stageData.PoundCnt;
|
||||
|
||||
ObjectMappers.DanStageResponseToDbMap.Apply(stageData, danStageData);
|
||||
|
||||
if (add)
|
||||
{
|
@ -1,19 +1,14 @@
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[Route("/v12r03/chassis/rewarditem.php")]
|
||||
[ApiController]
|
||||
public class RewardItemController : ControllerBase
|
||||
public class RewardItemController : BaseController<RewardItemController>
|
||||
{
|
||||
private readonly ILogger<RewardItemController> logger;
|
||||
public RewardItemController(ILogger<RewardItemController> logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult RewardItem([FromBody] RewardItemRequest request)
|
||||
{
|
||||
logger.LogInformation("RewardItem request : {Request}", request.Stringify());
|
||||
Logger.LogInformation("RewardItem request : {Request}", request.Stringify());
|
||||
|
||||
var response = new RewardItemResponse
|
||||
{
|
79
TaikoLocalServer/Controllers/Game/SelfBestController.cs
Normal file
79
TaikoLocalServer/Controllers/Game/SelfBestController.cs
Normal file
@ -0,0 +1,79 @@
|
||||
using Throw;
|
||||
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[Route("/v12r03/chassis/selfbest.php")]
|
||||
[ApiController]
|
||||
public class SelfBestController : BaseController<SelfBestController>
|
||||
{
|
||||
private readonly TaikoDbContext context;
|
||||
|
||||
public SelfBestController(TaikoDbContext context)
|
||||
{
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult SelfBest([FromBody] SelfBestRequest request)
|
||||
{
|
||||
Logger.LogInformation("SelfBest request : {Request}", request.Stringify());
|
||||
|
||||
var response = new SelfBestResponse
|
||||
{
|
||||
Result = 1,
|
||||
Level = request.Level
|
||||
};
|
||||
|
||||
var manager = MusicAttributeManager.Instance;
|
||||
|
||||
var requestDifficulty = (Difficulty)request.Level;
|
||||
requestDifficulty.Throw().IfOutOfRange();
|
||||
|
||||
var playerBestData = context.SongBestData
|
||||
.Where(datum => datum.Baid == request.Baid &&
|
||||
(datum.Difficulty == requestDifficulty ||
|
||||
(datum.Difficulty == Difficulty.UraOni && requestDifficulty == Difficulty.Oni)))
|
||||
.ToList();
|
||||
foreach (var songNo in request.ArySongNoes)
|
||||
{
|
||||
if (!manager.MusicAttributes.ContainsKey(songNo))
|
||||
{
|
||||
Logger.LogWarning("Music no {No} is missing!", songNo);
|
||||
continue;
|
||||
}
|
||||
|
||||
var selfBestData = GetSongSelfBestData(playerBestData, songNo);
|
||||
|
||||
response.ArySelfbestScores.Add(selfBestData);
|
||||
}
|
||||
response.ArySelfbestScores.Sort((data, otherData) => data.SongNo.CompareTo(otherData.SongNo));
|
||||
|
||||
return Ok(response);
|
||||
}
|
||||
|
||||
private static SelfBestResponse.SelfBestData GetSongSelfBestData(IEnumerable<SongBestDatum> playerBestData, uint songNo)
|
||||
{
|
||||
var songBestDatum = playerBestData.Where(datum => datum.SongId == songNo);
|
||||
|
||||
var selfBestData = new SelfBestResponse.SelfBestData
|
||||
{
|
||||
SongNo = songNo,
|
||||
};
|
||||
|
||||
foreach (var datum in songBestDatum)
|
||||
{
|
||||
if (datum.Difficulty == Difficulty.UraOni)
|
||||
{
|
||||
selfBestData.UraBestScore = datum.BestScore;
|
||||
selfBestData.UraBestScoreRate = datum.BestRate;
|
||||
continue;
|
||||
}
|
||||
|
||||
selfBestData.SelfBestScore = datum.BestScore;
|
||||
selfBestData.SelfBestScoreRate = datum.BestRate;
|
||||
}
|
||||
|
||||
return selfBestData;
|
||||
}
|
||||
}
|
@ -1,19 +1,14 @@
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[Route("/v12r03/chassis/songpurchase.php")]
|
||||
[ApiController]
|
||||
public class SongPurchaseController : ControllerBase
|
||||
public class SongPurchaseController : BaseController<SongPurchaseController>
|
||||
{
|
||||
private readonly ILogger<SongPurchaseController> logger;
|
||||
public SongPurchaseController(ILogger<SongPurchaseController> logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult SongPurchase([FromBody] SongPurchaseRequest request)
|
||||
{
|
||||
logger.LogInformation("SongPurchase request : {Request}", request.Stringify());
|
||||
Logger.LogInformation("SongPurchase request : {Request}", request.Stringify());
|
||||
|
||||
var response = new SongPurchaseResponse
|
||||
{
|
@ -1,22 +1,16 @@
|
||||
using taiko.vsinterface;
|
||||
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[ApiController]
|
||||
[Route("/v01r00/chassis/startupauth.php")]
|
||||
public class StartupAuthController : ControllerBase
|
||||
public class StartupAuthController : BaseController<StartupAuthController>
|
||||
{
|
||||
private readonly ILogger<StartupAuthController> logger;
|
||||
|
||||
public StartupAuthController(ILogger<StartupAuthController> logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult StartupAuth([FromBody] StartupAuthRequest request)
|
||||
{
|
||||
logger.LogInformation("StartupAuth request: {Request}", request.Stringify());
|
||||
Logger.LogInformation("StartupAuth request: {Request}", request.Stringify());
|
||||
var response = new StartupAuthResponse
|
||||
{
|
||||
Result = 1
|
@ -1,19 +1,14 @@
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[Route("/v12r03/chassis/tournamentcheck.php")]
|
||||
[ApiController]
|
||||
public class TournamentCheckController : ControllerBase
|
||||
public class TournamentCheckController : BaseController<TournamentCheckController>
|
||||
{
|
||||
private readonly ILogger<TournamentCheckController> logger;
|
||||
public TournamentCheckController(ILogger<TournamentCheckController> logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult TournamentCheck([FromBody] TournamentcheckRequest request)
|
||||
{
|
||||
logger.LogInformation("TournamentCheck request : {Request}", request.Stringify());
|
||||
Logger.LogInformation("TournamentCheck request : {Request}", request.Stringify());
|
||||
|
||||
var response = new TournamentcheckResponse
|
||||
{
|
@ -1,19 +1,17 @@
|
||||
using System.Collections;
|
||||
using System.Text.Json;
|
||||
using Throw;
|
||||
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[Route("/v12r03/chassis/userdata.php")]
|
||||
[ApiController]
|
||||
public class UserDataController : ControllerBase
|
||||
public class UserDataController : BaseController<UserDataController>
|
||||
{
|
||||
private readonly ILogger<UserDataController> logger;
|
||||
|
||||
private readonly TaikoDbContext context;
|
||||
|
||||
public UserDataController(ILogger<UserDataController> logger, TaikoDbContext context)
|
||||
public UserDataController(TaikoDbContext context)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@ -21,7 +19,7 @@ public class UserDataController : ControllerBase
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult GetUserData([FromBody] UserDataRequest request)
|
||||
{
|
||||
logger.LogInformation("UserData request : {Request}", request.Stringify());
|
||||
Logger.LogInformation("UserData request : {Request}", request.Stringify());
|
||||
|
||||
var musicAttributeManager = MusicAttributeManager.Instance;
|
||||
|
||||
@ -60,21 +58,20 @@ public class UserDataController : ControllerBase
|
||||
userData = context.UserData.First(datum => datum.Baid == request.Baid);
|
||||
}
|
||||
|
||||
var favoriteSongs = new uint[] { 0 };
|
||||
var favoriteSongs = Array.Empty<uint>();
|
||||
try
|
||||
{
|
||||
favoriteSongs = JsonSerializer.Deserialize<uint[]>(userData.FavoriteSongsArray);
|
||||
}
|
||||
catch (JsonException e)
|
||||
{
|
||||
logger.LogError(e, "Parsing favorite songs json data failed");
|
||||
}
|
||||
if (favoriteSongs == null || favoriteSongs.Length < 1)
|
||||
{
|
||||
logger.LogWarning("Favorite songs is null!");
|
||||
favoriteSongs = new uint[] { };
|
||||
Logger.LogError(e, "Parsing favorite songs json data failed");
|
||||
}
|
||||
|
||||
// The only way to get a null is provide string "null" as input,
|
||||
// which means database content need to be fixed, so better throw
|
||||
favoriteSongs.ThrowIfNull("Favorite song should never be null!");
|
||||
|
||||
var response = new UserDataResponse
|
||||
{
|
||||
Result = 1,
|
@ -1,19 +1,14 @@
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
namespace TaikoLocalServer.Controllers.Game;
|
||||
|
||||
[Route("/v12r03/chassis/verifyqrcode.php")]
|
||||
[ApiController]
|
||||
public class VerifyQrCodeController : ControllerBase
|
||||
public class VerifyQrCodeController : BaseController<VerifyQrCodeController>
|
||||
{
|
||||
private readonly ILogger<VerifyQrCodeController> logger;
|
||||
public VerifyQrCodeController(ILogger<VerifyQrCodeController> logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult VerifyQrCode([FromBody] VerifyQrcodeRequest request)
|
||||
{
|
||||
logger.LogInformation("VerifyQrCode request : {Request}", request.Stringify());
|
||||
Logger.LogInformation("VerifyQrCode request : {Request}", request.Stringify());
|
||||
|
||||
var response = new VerifyQrcodeResponse
|
||||
{
|
@ -1,28 +0,0 @@
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
|
||||
[Route("/v12r03/chassis/getapplicationurl.php")]
|
||||
[ApiController]
|
||||
public class GetApplicationUrlController : ControllerBase
|
||||
{
|
||||
private const string ApplicationUrl = "vsapi.taiko-p.jp";
|
||||
|
||||
private readonly ILogger<GetApplicationUrlController> logger;
|
||||
public GetApplicationUrlController(ILogger<GetApplicationUrlController> logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult GetApplicationUrl([FromBody] GetApplicationUrlRequest request)
|
||||
{
|
||||
logger.LogInformation("GetApplicationUrl request : {Request}", request.Stringify());
|
||||
|
||||
var response = new GetApplicationUrlResponse
|
||||
{
|
||||
Result = 1,
|
||||
ApplicationUrl = ApplicationUrl
|
||||
};
|
||||
|
||||
return Ok(response);
|
||||
}
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
namespace TaikoLocalServer.Controllers;
|
||||
|
||||
[Route("/v12r03/chassis/selfbest.php")]
|
||||
[ApiController]
|
||||
public class SelfBestController : ControllerBase
|
||||
{
|
||||
private readonly ILogger<SelfBestController> logger;
|
||||
|
||||
private readonly TaikoDbContext context;
|
||||
|
||||
public SelfBestController(ILogger<SelfBestController> logger, TaikoDbContext context)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult SelfBest([FromBody] SelfBestRequest request)
|
||||
{
|
||||
logger.LogInformation("SelfBest request : {Request}", request.Stringify());
|
||||
|
||||
var response = new SelfBestResponse
|
||||
{
|
||||
Result = 1,
|
||||
Level = request.Level
|
||||
};
|
||||
|
||||
var manager = MusicAttributeManager.Instance;
|
||||
var difficulty = (Difficulty)request.Level;
|
||||
var playerBestData = context.SongBestData
|
||||
.Where(datum => datum.Baid == request.Baid &&
|
||||
(datum.Difficulty == difficulty || (datum.Difficulty == Difficulty.UraOni && difficulty == Difficulty.Oni)))
|
||||
.ToList();
|
||||
foreach (var songNo in request.ArySongNoes)
|
||||
{
|
||||
if (!manager.MusicAttributes.ContainsKey(songNo))
|
||||
{
|
||||
logger.LogWarning("Music no {No} is missing!", songNo);
|
||||
continue;
|
||||
}
|
||||
|
||||
var songBestDatum = playerBestData.Where(datum => datum.SongId == songNo);
|
||||
|
||||
var selfBestData = new SelfBestResponse.SelfBestData
|
||||
{
|
||||
SongNo = songNo,
|
||||
};
|
||||
|
||||
foreach (var datum in songBestDatum)
|
||||
{
|
||||
if (datum.Difficulty == difficulty)
|
||||
{
|
||||
selfBestData.SelfBestScore = datum.BestScore;
|
||||
selfBestData.SelfBestScoreRate = datum.BestRate;
|
||||
}
|
||||
else if (datum.Difficulty == Difficulty.UraOni)
|
||||
{
|
||||
selfBestData.UraBestScore = datum.BestScore;
|
||||
selfBestData.UraBestScoreRate = datum.BestRate;
|
||||
}
|
||||
}
|
||||
|
||||
response.ArySelfbestScores.Add(selfBestData);
|
||||
}
|
||||
response.ArySelfbestScores.Sort((data, otherData) => data.SongNo.CompareTo(otherData.SongNo));
|
||||
|
||||
return Ok(response);
|
||||
}
|
||||
}
|
@ -23,6 +23,7 @@
|
||||
<PackageReference Include="Swan.Core" Version="6.0.2-beta.90" />
|
||||
<PackageReference Include="Swan.Logging" Version="6.0.2-beta.69" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||
<PackageReference Include="Throw" Version="1.2.0" />
|
||||
<PackageReference Include="Yoh.Text.Json.NamingPolicies" Version="0.2.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user