feat(mypage): /mypage/finish_battle (returns check=0 — no in-flight state yet)
This commit is contained in:
@@ -10,7 +10,9 @@ using SVSim.EmulatedEntrypoint.Constants;
|
||||
using SVSim.EmulatedEntrypoint.Infrastructure;
|
||||
using SVSim.EmulatedEntrypoint.Models.Dtos;
|
||||
using SVSim.EmulatedEntrypoint.Models.Dtos.Requests;
|
||||
using SVSim.EmulatedEntrypoint.Models.Dtos.Requests.MyPage;
|
||||
using SVSim.EmulatedEntrypoint.Models.Dtos.Responses;
|
||||
using SVSim.EmulatedEntrypoint.Models.Dtos.Responses.MyPage;
|
||||
using SVSim.EmulatedEntrypoint.Services;
|
||||
|
||||
namespace SVSim.EmulatedEntrypoint.Controllers;
|
||||
@@ -361,4 +363,11 @@ public class MyPageController : SVSimController
|
||||
EndTime = row.EndTime.ToString(WireDateFormat, CultureInfo.InvariantCulture),
|
||||
};
|
||||
}
|
||||
|
||||
[HttpPost("finish_battle")]
|
||||
public ActionResult<MyPageFinishBattleResponse> FinishBattle([FromBody] MyPageFinishBattleRequest _)
|
||||
{
|
||||
if (!TryGetViewerId(out long __)) return Unauthorized();
|
||||
return new MyPageFinishBattleResponse { CheckUnfinishedBattle = 0 };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using MessagePack;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace SVSim.EmulatedEntrypoint.Models.Dtos.Requests.MyPage;
|
||||
|
||||
[MessagePackObject]
|
||||
public class MyPageFinishBattleRequest : BaseRequest
|
||||
{
|
||||
// Wire key is uppercase "SDTRB" — verbatim from
|
||||
// PlayerPrefsWrapper.SELF_DISCONNECT_OPEN_STATUS_TO_REPLACE_LOG.
|
||||
[JsonPropertyName("SDTRB")]
|
||||
[Key("SDTRB")]
|
||||
public int Sdtrb { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using MessagePack;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace SVSim.EmulatedEntrypoint.Models.Dtos.Responses.MyPage;
|
||||
|
||||
/// <summary>
|
||||
/// Spec source: docs/api-spec/endpoints/post-login/mypage-finish-battle.md.
|
||||
/// We always emit check_unfinished_battle=0 because no in-flight battle state
|
||||
/// is tracked server-side yet. When that lands, branch to is_win + class/rank refresh.
|
||||
/// </summary>
|
||||
[MessagePackObject]
|
||||
public class MyPageFinishBattleResponse
|
||||
{
|
||||
[JsonPropertyName("check_unfinished_battle")]
|
||||
[Key("check_unfinished_battle")]
|
||||
public int CheckUnfinishedBattle { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using NUnit.Framework;
|
||||
using SVSim.UnitTests.Infrastructure;
|
||||
|
||||
namespace SVSim.UnitTests.Controllers;
|
||||
|
||||
public class MyPageControllerFinishBattleTests
|
||||
{
|
||||
[Test]
|
||||
public async Task FinishBattle_returns_check_zero()
|
||||
{
|
||||
using var factory = new SVSimTestFactory();
|
||||
long viewerId = await factory.SeedViewerAsync(tutorialState: 0);
|
||||
using var client = factory.CreateAuthenticatedClient(viewerId);
|
||||
|
||||
var requestJson = """{"SDTRB":0,"viewer_id":"0","steam_id":0,"steam_session_ticket":""}""";
|
||||
var response = await client.PostAsync("/mypage/finish_battle",
|
||||
new StringContent(requestJson, Encoding.UTF8, "application/json"));
|
||||
|
||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||
|
||||
var body = await response.Content.ReadAsStringAsync();
|
||||
using var doc = JsonDocument.Parse(body);
|
||||
Assert.That(doc.RootElement.GetProperty("check_unfinished_battle").GetInt32(), Is.EqualTo(0));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user