More features
This commit is contained in:
@@ -1,11 +1,5 @@
|
||||
using System.Buffers.Text;
|
||||
using System.Text;
|
||||
using MessagePack;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using SVSim.Database.Models;
|
||||
using SVSim.Database.Repositories.Viewer;
|
||||
using SVSim.EmulatedEntrypoint.Extensions;
|
||||
@@ -13,64 +7,68 @@ using SVSim.EmulatedEntrypoint.Models.Dtos;
|
||||
using SVSim.EmulatedEntrypoint.Models.Dtos.Requests;
|
||||
using SVSim.EmulatedEntrypoint.Models.Dtos.Responses;
|
||||
|
||||
namespace SVSim.EmulatedEntrypoint.Controllers
|
||||
namespace SVSim.EmulatedEntrypoint.Controllers;
|
||||
|
||||
public class CheckController : SVSimController
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class CheckController : SVSimController
|
||||
private readonly ILogger _logger;
|
||||
private readonly IViewerRepository _viewerRepository;
|
||||
|
||||
public CheckController(ILogger<CheckController> logger, IViewerRepository viewerRepository)
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IViewerRepository _viewerRepository;
|
||||
|
||||
public CheckController(ILogger<CheckController> logger, IViewerRepository viewerRepository)
|
||||
{
|
||||
_logger = logger;
|
||||
_viewerRepository = viewerRepository;
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost("special_title")]
|
||||
public async Task<SpecialTitleCheckResponse> SpecialTitleCheck(SpecialTitleCheckRequest request)
|
||||
{
|
||||
int titleId = Random.Shared.Next(8, 33);
|
||||
var res = new SpecialTitleCheckResponse
|
||||
{
|
||||
TitleImageId = titleId,
|
||||
TitleSoundId = titleId
|
||||
};
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
[HttpPost("game_start")]
|
||||
public async Task<GameStartResponse> GameStart(GameStartRequest request)
|
||||
{
|
||||
Viewer? viewer = await _viewerRepository.GetViewerWithSocials(HttpContext.GetViewer().Id);
|
||||
return new GameStartResponse()
|
||||
{
|
||||
IsSetTransitionPassword = true,
|
||||
KorAuthorityId = default,
|
||||
KorAuthorityState = default,
|
||||
NowRank = new Dictionary<string, string>()
|
||||
{
|
||||
{ "1", "RankName_010" },
|
||||
{ "2", "RankName_010" },
|
||||
{ "4", "RankName_017" }
|
||||
},
|
||||
NowName = viewer.DisplayName,
|
||||
PolicyState = default,
|
||||
PolicyId = default,
|
||||
NowTutorialStep = "100",
|
||||
NowViewerId = viewer.Id,
|
||||
TosId = default,
|
||||
TosState = default,
|
||||
TransitionAccountData = viewer.SocialAccountConnections.Select(sac => new TransitionAccountData
|
||||
{
|
||||
ConnectedViewerId = viewer.Id.ToString(),
|
||||
SocialAccountId = sac.AccountId.ToString(),
|
||||
SocialAccountType = ((int)sac.AccountType).ToString()
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
_logger = logger;
|
||||
_viewerRepository = viewerRepository;
|
||||
}
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost("special_title")]
|
||||
public Task<SpecialTitleCheckResponse> SpecialTitleCheck(SpecialTitleCheckRequest request)
|
||||
{
|
||||
return Task.FromResult(new SpecialTitleCheckResponse
|
||||
{
|
||||
TitleImageId = "0"
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: spec lists this as anonymous (identity from SHORT_UDID), but the base controller's
|
||||
// [Authorize] still applies. For now requires a Steam-linked viewer; new-user bootstrap (where
|
||||
// the server creates a viewer + returns rewrite_viewer_id) is deferred until the boot flow is
|
||||
// exercised end-to-end with a real client.
|
||||
[HttpPost("game_start")]
|
||||
public async Task<GameStartResponse> GameStart(GameStartRequest request)
|
||||
{
|
||||
Viewer viewer = HttpContext.GetViewer()
|
||||
?? throw new InvalidOperationException("Auth handler must set viewer in context.");
|
||||
Viewer fullViewer = await _viewerRepository.GetViewerWithSocials(viewer.Id) ?? viewer;
|
||||
|
||||
return new GameStartResponse
|
||||
{
|
||||
NowViewerId = fullViewer.Id,
|
||||
NowName = fullViewer.DisplayName,
|
||||
NowTutorialStep = fullViewer.MissionData.TutorialState.ToString(),
|
||||
IsSetTransitionPassword = true,
|
||||
// Stub rank map until per-format ranks are persisted (prod observed: "1"/"2"/"4"
|
||||
// keys mapping to RankName_010 / RankName_017). Empty dict here may be safe but
|
||||
// we don't yet know which client paths read this — match prod stub.
|
||||
NowRank = new Dictionary<string, string>
|
||||
{
|
||||
{ "1", "RankName_010" },
|
||||
{ "2", "RankName_010" },
|
||||
{ "4", "RankName_017" }
|
||||
},
|
||||
TransitionAccountData = fullViewer.SocialAccountConnections
|
||||
.Select(sac => new TransitionAccountData
|
||||
{
|
||||
SocialAccountId = sac.AccountId.ToString(),
|
||||
SocialAccountType = ((int)sac.AccountType).ToString(),
|
||||
ConnectedViewerId = fullViewer.Id.ToString()
|
||||
}).ToList(),
|
||||
TosState = 1,
|
||||
PolicyState = 1,
|
||||
KorAuthorityState = 0,
|
||||
TosId = 1,
|
||||
PolicyId = 1,
|
||||
KorAuthorityId = 0
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user