From 39b38e3c803ba6764b5477b801a71a4b2a74d36a Mon Sep 17 00:00:00 2001 From: gamer147 Date: Thu, 28 May 2026 00:54:46 -0400 Subject: [PATCH] Battlepass fix --- .../Services/BattlePassService.cs | 5 +++- .../BattlePassControllerInfoTests.cs | 27 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/SVSim.EmulatedEntrypoint/Services/BattlePassService.cs b/SVSim.EmulatedEntrypoint/Services/BattlePassService.cs index 91a8ce1..0a10e66 100644 --- a/SVSim.EmulatedEntrypoint/Services/BattlePassService.cs +++ b/SVSim.EmulatedEntrypoint/Services/BattlePassService.cs @@ -71,7 +71,10 @@ public sealed class BattlePassService : IBattlePassService MaxLevel = Inv(season.MaxLevel), StartDate = FormatWireDate(season.StartDate), EndDate = FormatWireDate(season.EndDate), - CanPurchase = season.CanPurchase, + // Client uses can_purchase as the sole "show buy button / use normal-pass icon" + // signal on the home BP screen (Wizard/BattlePass.cs:56,84 + BattlePassHeader.cs:51); + // it must flip to false once the viewer owns the pass, or the button persists. + CanPurchase = season.CanPurchase && !progress.IsPremium, }, RewardInfo = new BattlePassRewardInfoDto { diff --git a/SVSim.UnitTests/Controllers/BattlePassControllerInfoTests.cs b/SVSim.UnitTests/Controllers/BattlePassControllerInfoTests.cs index 8b08e48..e3060d8 100644 --- a/SVSim.UnitTests/Controllers/BattlePassControllerInfoTests.cs +++ b/SVSim.UnitTests/Controllers/BattlePassControllerInfoTests.cs @@ -105,6 +105,33 @@ public class BattlePassControllerInfoTests Assert.That(premiumReward.GetProperty("is_received").GetBoolean(), Is.False); } + [Test] + public async Task Info_can_purchase_is_false_when_viewer_already_premium() + { + using var factory = new SVSimTestFactory(); + long viewerId = await factory.SeedViewerAsync(); + await SeedSeason23WithRewards(factory); + + using (var scope = factory.Services.CreateScope()) + { + var db = scope.ServiceProvider.GetRequiredService(); + db.ViewerBattlePassProgress.Add(new ViewerBattlePassProgressEntry + { + ViewerId = viewerId, SeasonId = 23, CurrentPoint = 0, IsPremium = true, + }); + await db.SaveChangesAsync(); + } + + using var client = factory.CreateAuthenticatedClient(viewerId); + var response = await client.PostAsync("/battle_pass/info", JsonBody(EmptyAuthBody)); + var body = await response.Content.ReadAsStringAsync(); + using var doc = JsonDocument.Parse(body); + + Assert.That(doc.RootElement.GetProperty("season_info").GetProperty("can_purchase").GetBoolean(), + Is.False, + "premium owners must see can_purchase=false (client uses it as the sole hide-buy-button signal)"); + } + [Test] public async Task Info_returns_empty_payload_outside_any_season_window() {