diff --git a/SVSim.EmulatedEntrypoint/Program.cs b/SVSim.EmulatedEntrypoint/Program.cs index 43391b8..524916c 100644 --- a/SVSim.EmulatedEntrypoint/Program.cs +++ b/SVSim.EmulatedEntrypoint/Program.cs @@ -84,6 +84,8 @@ public class Program builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped await new PackImporter().ImportAsync(ctx, seedDir); } + /// + /// Enables Freeplay mode by writing the GameConfigs DB row (tier-1 of GameConfigService). + /// Call before issuing the request under test. Idempotent. + /// + public async Task EnableFreeplayAsync(ulong currencyAmount = 99999, int cardCopies = 3) + { + using var scope = Services.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + var json = System.Text.Json.JsonSerializer.Serialize(new + { + Enabled = true, + CurrencyAmount = currencyAmount, + CardCopies = cardCopies, + }); + var existing = await db.GameConfigs.FirstOrDefaultAsync(s => s.SectionName == "Freeplay"); + if (existing is null) + db.GameConfigs.Add(new GameConfigSection { SectionName = "Freeplay", ValueJson = json }); + else + existing.ValueJson = json; + await db.SaveChangesAsync(); + } + /// Convenience: bake the X-Test-Viewer-Id header into a fresh client. public HttpClient CreateAuthenticatedClient(long viewerId) {