48 lines
1.7 KiB
C#
48 lines
1.7 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using SVSim.EmulatedEntrypoint.Models.Dtos.Requests.ArenaTwoPick;
|
|
using SVSim.EmulatedEntrypoint.Models.Dtos.Responses.ArenaTwoPick;
|
|
using SVSim.EmulatedEntrypoint.Services;
|
|
|
|
namespace SVSim.EmulatedEntrypoint.Controllers;
|
|
|
|
[Route("arena_two_pick_battle")]
|
|
public class ArenaTwoPickBattleController : SVSimController
|
|
{
|
|
private readonly IArenaTwoPickService _svc;
|
|
public ArenaTwoPickBattleController(IArenaTwoPickService svc) => _svc = svc;
|
|
|
|
[HttpPost("do_matching")]
|
|
public IActionResult DoMatching([FromBody] DoMatchingRequest req)
|
|
{
|
|
if (!TryGetViewerId(out _)) return Unauthorized();
|
|
return Ok(new DoMatchingResponseDto());
|
|
}
|
|
|
|
[HttpPost("finish")]
|
|
public async Task<IActionResult> Finish([FromBody] BattleFinishRequest req)
|
|
{
|
|
if (!TryGetViewerId(out var vid)) return Unauthorized();
|
|
try
|
|
{
|
|
var result = await _svc.RecordBattleResultAsync(vid, req.BattleResult == 1);
|
|
return Ok(new BattleFinishResponseDto
|
|
{
|
|
BattleResult = result.BattleResult,
|
|
GetClassExperience = result.GetClassExperience,
|
|
ClassExperience = result.ClassExperience,
|
|
ClassLevel = result.ClassLevel,
|
|
SpotPointInfo = new SpotPointInfoDto
|
|
{
|
|
BeforeSpotPoint = result.BeforeSpotPoint,
|
|
AddSpotPoint = result.AddSpotPoint,
|
|
AfterSpotPoint = result.AfterSpotPoint,
|
|
},
|
|
});
|
|
}
|
|
catch (ArenaTwoPickException ex)
|
|
{
|
|
return BadRequest(new { error_code = ex.ErrorCode });
|
|
}
|
|
}
|
|
}
|