feat(config): wire /config/update + /config/update_challenge_config (closes family 4/4)

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>
This commit is contained in:
gamer147
2026-06-13 11:25:40 -04:00
parent b5e13551cd
commit 715dd4dea8
17 changed files with 4860 additions and 16 deletions

View File

@@ -39,4 +39,29 @@ public class ConfigController : SVSimController
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();
}
}

View File

@@ -248,8 +248,10 @@ public class LoadController : SVSimController
}).ToList(),
ArenaConfig = new ArenaConfig
{
UseChallengePickTwoPremiumCard = challenge.UseTwoPickPremiumCard ? 1 : 0,
ChallengePickTwoCardSleeve = (int)challenge.TwoPickSleeveId,
UseChallengePickTwoPremiumCard = viewer.Info.UseChallengeTwoPickPremiumCard ? 1 : 0,
ChallengePickTwoCardSleeve = (int)(viewer.Info.ChallengeTwoPickSleeveId != 0
? viewer.Info.ChallengeTwoPickSleeveId
: defaultLoadout.SleeveId),
},
ArenaInfos = await BuildArenaInfosAsync(viewer.Id),
RotationSets = rotationSets,
@@ -257,6 +259,7 @@ public class LoadController : SVSimController
{
IsFoilPreferred = viewer.Info.IsFoilPreferred ? 1 : 0,
IsPrizePreferred = viewer.Info.IsPrizePreferred ? 1 : 0,
IsSkipGachaEffect = viewer.Info.IsSkipGachaEffect ? 1 : 0,
},
OpenBattlefieldIds = (await _globalsRepository.GetBattlefields(true))
.Select(bf => bf.Id.ToString()).ToList(),

View File

@@ -115,6 +115,7 @@ public class MyPageController : SVSimController
{
IsFoilPreferred = viewer.Info.IsFoilPreferred ? 1 : 0,
IsPrizePreferred = viewer.Info.IsPrizePreferred ? 1 : 0,
IsSkipGachaEffect = viewer.Info.IsSkipGachaEffect ? 1 : 0,
},
Quest = new Quest(), // TODO(mypage-stub): active Quest event + viewer flags
MasterPointRankingPeriod = BuildMasterPointRankingPeriod(masterPointPeriod),

View File

@@ -0,0 +1,16 @@
using MessagePack;
using System.Text.Json.Serialization;
namespace SVSim.EmulatedEntrypoint.Models.Dtos.Requests;
[MessagePackObject]
public class ConfigUpdateChallengeConfigRequest : BaseRequest
{
[JsonPropertyName("use_challenge_two_pick_premium_card")]
[Key("use_challenge_two_pick_premium_card")]
public int UseChallengeTwoPickPremiumCard { get; set; }
[JsonPropertyName("challenge_two_pick_sleeve_id")]
[Key("challenge_two_pick_sleeve_id")]
public long ChallengeTwoPickSleeveId { get; set; }
}

View File

@@ -0,0 +1,12 @@
using MessagePack;
using System.Text.Json.Serialization;
namespace SVSim.EmulatedEntrypoint.Models.Dtos.Requests;
[MessagePackObject]
public class ConfigUpdateRequest : BaseRequest
{
[JsonPropertyName("is_skip_gacha_effect")]
[Key("is_skip_gacha_effect")]
public int IsSkipGachaEffect { get; set; }
}

View File

@@ -27,4 +27,7 @@ public class UserConfig
[JsonPropertyName("is_prize_preferred")]
[Key("is_prize_preferred")]
public int IsPrizePreferred { get; set; }
[JsonPropertyName("is_skip_gacha_effect")]
[Key("is_skip_gacha_effect")]
public int IsSkipGachaEffect { get; set; }
}

View File

@@ -39,7 +39,6 @@ public class MatchContextBuilder : IMatchContextBuilder
var viewer = await _viewers.LoadForMatchContextAsync(viewerId)
?? throw new ArenaTwoPickException("arena_two_pick_no_active_run");
var challenge = _config.Get<ChallengeConfig>();
var defaults = _config.Get<DefaultLoadoutConfig>();
var emblemId = viewer.Info.SelectedEmblem.Id != 0
@@ -51,6 +50,11 @@ public class MatchContextBuilder : IMatchContextBuilder
var charaId = run.LeaderSkinId != 0
? run.LeaderSkinId.ToString()
: run.ClassId.ToString();
// TK2-specific cosmetic source; falls back to the global default sleeve if the
// viewer hasn't set a challenge-specific one via /config/update_challenge_config.
var twoPickSleeveId = viewer.Info.ChallengeTwoPickSleeveId != 0
? viewer.Info.ChallengeTwoPickSleeveId
: defaults.SleeveId;
return new MatchContext(
SelfDeckCardIds: deck,
@@ -61,7 +65,7 @@ public class MatchContextBuilder : IMatchContextBuilder
CountryCode: viewer.Info.CountryCode ?? string.Empty,
UserName: viewer.DisplayName,
// TK2-specific cosmetic source; other modes will use the deck row's SleeveId.
SleeveId: challenge.TwoPickSleeveId.ToString(),
SleeveId: twoPickSleeveId.ToString(),
EmblemId: emblemId,
DegreeId: degreeId,
// Hardcoded v1; needs equipped-MyPageBackground lookup (see spec §Deferred).