Deletes the scripted opponent and every entry point that created a BattleType.Scripted session (the ?scripted=1 query opt-in, the SoloDefaultsToScripted toggle, the resolver short-circuit, the WS handler case, the bridge validation arm). Real two-client PvP and the Bot matchmaking-timeout fallback are untouched. ResolveAsync drops its scriptedOptIn parameter. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
77 lines
2.6 KiB
C#
77 lines
2.6 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using SVSim.BattleNode.Bridge;
|
|
using SVSim.EmulatedEntrypoint.Matching;
|
|
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;
|
|
private readonly IMatchContextBuilder _matchContextBuilder;
|
|
private readonly IMatchingResolver _resolver;
|
|
|
|
public ArenaTwoPickBattleController(
|
|
IArenaTwoPickService svc,
|
|
IMatchContextBuilder matchContextBuilder,
|
|
IMatchingResolver resolver)
|
|
{
|
|
_svc = svc;
|
|
_matchContextBuilder = matchContextBuilder;
|
|
_resolver = resolver;
|
|
}
|
|
|
|
[HttpPost("do_matching")]
|
|
public async Task<IActionResult> DoMatching(
|
|
[FromBody] DoMatchingRequest req,
|
|
CancellationToken ct = default)
|
|
{
|
|
if (!TryGetViewerId(out var vid)) return Unauthorized();
|
|
try
|
|
{
|
|
var ctx = await _matchContextBuilder.BuildForTwoPickAsync(vid);
|
|
var r = await _resolver.ResolveAsync("arena_two_pick_battle", new BattlePlayer(vid, ctx), ct);
|
|
return Ok(new DoMatchingResponseDto
|
|
{
|
|
MatchingState = r.MatchingState,
|
|
BattleId = r.BattleId,
|
|
NodeServerUrl = r.NodeServerUrl,
|
|
});
|
|
}
|
|
catch (ArenaTwoPickException ex)
|
|
{
|
|
return BadRequest(new { error_code = ex.ErrorCode });
|
|
}
|
|
}
|
|
|
|
[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 });
|
|
}
|
|
}
|
|
}
|