diff --git a/SVSim.EmulatedEntrypoint/Services/GachaPointService.cs b/SVSim.EmulatedEntrypoint/Services/GachaPointService.cs index 9ab0eb4..a8a07df 100644 --- a/SVSim.EmulatedEntrypoint/Services/GachaPointService.cs +++ b/SVSim.EmulatedEntrypoint/Services/GachaPointService.cs @@ -160,8 +160,7 @@ public sealed class GachaPointService : IGachaPointService int threshold = pack.GachaPointConfig.ExchangeablePoint; var balance = viewer.GachaPointBalances.FirstOrDefault(b => b.PackId == packId); - int currentPoints = balance?.Points ?? 0; - if (currentPoints < threshold) + if (balance is null || balance.Points < threshold) return ExchangeOutcome.Fail("insufficient_gacha_points"); // Validate the card is in the catalog by re-running GetRewardsAsync. This re-uses the @@ -176,8 +175,8 @@ public sealed class GachaPointService : IGachaPointService if (viewer.GachaPointReceived.Any(r => r.PackId == packId && r.CardId == cardId)) return ExchangeOutcome.Fail("already_received"); - // Debit balance + mark received. - balance!.Points -= threshold; + // Debit balance + mark received. (`balance` is non-null past the earlier guard.) + balance.Points -= threshold; viewer.GachaPointReceived.Add(new ViewerGachaPointReceived { PackId = packId, CardId = cardId, ReceivedAt = DateTime.UtcNow,