is_skip_gacha_effect, use_challenge_two_pick_premium_card, and challenge_two_pick_sleeve_id all persist on ViewerInfo and round-trip through /load/index. The two challenge fields move from the global ChallengeConfig section to ViewerInfo — they're viewer preferences, not server-wide policy. Premium card defaults to 0; sleeve falls back to DefaultLoadoutConfig.SleeveId (3000011) when unset. MatchContextBuilder's TK2 sleeve read switches to the same viewer-scoped path. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
68 lines
2.8 KiB
C#
68 lines
2.8 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using SVSim.Database;
|
|
using SVSim.EmulatedEntrypoint.Models.Dtos.Common;
|
|
using SVSim.EmulatedEntrypoint.Models.Dtos.Requests;
|
|
|
|
namespace SVSim.EmulatedEntrypoint.Controllers;
|
|
|
|
/// <summary>
|
|
/// /config/* — viewer-scoped preference toggles. Persists to ViewerInfo; reads back through
|
|
/// /load/index + /mypage/index user_config.
|
|
/// </summary>
|
|
public class ConfigController : SVSimController
|
|
{
|
|
private readonly SVSimDbContext _db;
|
|
|
|
public ConfigController(SVSimDbContext db) => _db = db;
|
|
|
|
[HttpPost("update_foil_preferred")]
|
|
public async Task<ActionResult<EmptyResponse>> UpdateFoilPreferred(
|
|
ConfigUpdateFoilPreferredRequest request, CancellationToken ct)
|
|
{
|
|
if (!TryGetViewerId(out long viewerId)) return Unauthorized();
|
|
var viewer = await _db.Viewers.FirstOrDefaultAsync(v => v.Id == viewerId, ct);
|
|
if (viewer is null) return Unauthorized();
|
|
viewer.Info.IsFoilPreferred = request.IsFoilPreferred != 0;
|
|
await _db.SaveChangesAsync(ct);
|
|
return new EmptyResponse();
|
|
}
|
|
|
|
[HttpPost("update_prize_preferred")]
|
|
public async Task<ActionResult<EmptyResponse>> UpdatePrizePreferred(
|
|
ConfigUpdatePrizePreferredRequest request, CancellationToken ct)
|
|
{
|
|
if (!TryGetViewerId(out long viewerId)) return Unauthorized();
|
|
var viewer = await _db.Viewers.FirstOrDefaultAsync(v => v.Id == viewerId, ct);
|
|
if (viewer is null) return Unauthorized();
|
|
viewer.Info.IsPrizePreferred = request.IsPrizePreferred != 0;
|
|
await _db.SaveChangesAsync(ct);
|
|
return new EmptyResponse();
|
|
}
|
|
|
|
[HttpPost("update")]
|
|
public async Task<ActionResult<EmptyResponse>> Update(
|
|
ConfigUpdateRequest request, CancellationToken ct)
|
|
{
|
|
if (!TryGetViewerId(out long viewerId)) return Unauthorized();
|
|
var viewer = await _db.Viewers.FirstOrDefaultAsync(v => v.Id == viewerId, ct);
|
|
if (viewer is null) return Unauthorized();
|
|
viewer.Info.IsSkipGachaEffect = request.IsSkipGachaEffect != 0;
|
|
await _db.SaveChangesAsync(ct);
|
|
return new EmptyResponse();
|
|
}
|
|
|
|
[HttpPost("update_challenge_config")]
|
|
public async Task<ActionResult<EmptyResponse>> UpdateChallengeConfig(
|
|
ConfigUpdateChallengeConfigRequest request, CancellationToken ct)
|
|
{
|
|
if (!TryGetViewerId(out long viewerId)) return Unauthorized();
|
|
var viewer = await _db.Viewers.FirstOrDefaultAsync(v => v.Id == viewerId, ct);
|
|
if (viewer is null) return Unauthorized();
|
|
viewer.Info.UseChallengeTwoPickPremiumCard = request.UseChallengeTwoPickPremiumCard != 0;
|
|
viewer.Info.ChallengeTwoPickSleeveId = request.ChallengeTwoPickSleeveId;
|
|
await _db.SaveChangesAsync(ct);
|
|
return new EmptyResponse();
|
|
}
|
|
}
|