feat(spot-card-exchange): /spot_card_exchange/{top,exchange} + SpotPoints currency
Final shop family. Schema additions:
- ViewerCurrency.SpotPoints (ulong) — new currency column on Viewers.
- SpotCardExchangeEntry — catalog (distinct from the pre-existing
SpotCardEntry, which is the /load/index rental-cost concept).
- ViewerSpotCardExchange — standalone composite-PK table tracking
(viewer, card, exchanged_at, is_pre_release_snapshot). Standalone
avoids cartesian-explode on viewer-graph reads.
RewardGrantService gains a SpotCardPoint=12 currency case mirroring
the RedEther/Crystal pattern. Doc comment refreshed; SpotCard=11 and
SpotCardOnlyLatestCardPack=13 remain unimplemented with explanatory
NotSupportedException — captures show emitters always use Card=5 with
the spot-card-specific id.
Controller:
- /top: emits exactly 9 clan buckets [{"1": [cards]}, ...] matching
prod's arbitrary single-key shape. exchange_status per-card (0=
available, 1=already-exchanged, 2=LimitOver after pre-release cap).
pre_relase_info WIRE TYPO PRESERVED ("relase" not "release").
- /exchange: server-authoritative price (client-supplied
exchange_point ignored); debits SpotPoints with post-state-total
reward_list entry; grants card via RewardGrantService.ApplyAsync
(cosmetic cascade included); persists ViewerSpotCardExchange row.
Insufficient points / already-exchanged / pre-release-limit all
return 400 without partial state.
LoadController now populates /load/index spot_point from
viewer.Currency.SpotPoints (was always 0).
PreReleaseLimit hardcoded to 2 matching capture; promote to GameConfig
when captures show variance.
504 tests pass (was 496; +8 spot-card-exchange tests).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
3733
SVSim.Bootstrap/Data/seeds/spot-card-exchange.json
Normal file
3733
SVSim.Bootstrap/Data/seeds/spot-card-exchange.json
Normal file
File diff suppressed because it is too large
Load Diff
55
SVSim.Bootstrap/Importers/SpotCardExchangeImporter.cs
Normal file
55
SVSim.Bootstrap/Importers/SpotCardExchangeImporter.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SVSim.Bootstrap.Models.Seed;
|
||||
using SVSim.Database;
|
||||
using SVSim.Database.Models;
|
||||
|
||||
namespace SVSim.Bootstrap.Importers;
|
||||
|
||||
/// <summary>
|
||||
/// Idempotent upsert of the spot card exchange catalog from <c>seeds/spot-card-exchange.json</c>.
|
||||
/// Source is the wire <c>/spot_card_exchange/top</c> response, extracted via
|
||||
/// <c>data_dumps/extract/extract-spot-card-exchange.py</c>. Rows missing from the seed are
|
||||
/// LEFT INTACT.
|
||||
/// </summary>
|
||||
public class SpotCardExchangeImporter
|
||||
{
|
||||
public async Task<int> ImportAsync(SVSimDbContext context, string seedDir)
|
||||
{
|
||||
string path = Path.Combine(seedDir, "spot-card-exchange.json");
|
||||
var seed = SeedLoader.LoadList<SpotCardExchangeSeed>(path);
|
||||
if (seed.Count == 0)
|
||||
{
|
||||
Console.WriteLine("[SpotCardExchangeImporter] No seed rows; skipping.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
var existing = await context.SpotCardExchangeCatalog.ToDictionaryAsync(e => e.Id);
|
||||
int created = 0, updated = 0;
|
||||
|
||||
foreach (var s in seed)
|
||||
{
|
||||
if (s.CardId == 0) continue;
|
||||
|
||||
var entry = existing.TryGetValue(s.CardId, out var ex)
|
||||
? ex : new SpotCardExchangeEntry { Id = s.CardId };
|
||||
|
||||
entry.ClassId = s.ClassId;
|
||||
entry.ExchangePoint = s.ExchangePoint;
|
||||
entry.TsRotationId = s.TsRotationId;
|
||||
entry.IsPreRelease = s.IsPreRelease;
|
||||
entry.IsEnabled = true;
|
||||
|
||||
if (ex is null)
|
||||
{
|
||||
context.SpotCardExchangeCatalog.Add(entry);
|
||||
existing[s.CardId] = entry;
|
||||
created++;
|
||||
}
|
||||
else updated++;
|
||||
}
|
||||
|
||||
await context.SaveChangesAsync();
|
||||
Console.WriteLine($"[SpotCardExchangeImporter] +{created}/~{updated}");
|
||||
return created + updated;
|
||||
}
|
||||
}
|
||||
12
SVSim.Bootstrap/Models/Seed/SpotCardExchangeSeed.cs
Normal file
12
SVSim.Bootstrap/Models/Seed/SpotCardExchangeSeed.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace SVSim.Bootstrap.Models.Seed;
|
||||
|
||||
public sealed class SpotCardExchangeSeed
|
||||
{
|
||||
[JsonPropertyName("card_id")] public long CardId { get; set; }
|
||||
[JsonPropertyName("class")] public int ClassId { get; set; }
|
||||
[JsonPropertyName("exchange_point")] public int ExchangePoint { get; set; }
|
||||
[JsonPropertyName("ts_rotation_id")] public long TsRotationId { get; set; }
|
||||
[JsonPropertyName("is_pre_release")] public bool IsPreRelease { get; set; }
|
||||
}
|
||||
@@ -101,6 +101,7 @@ public static class Program
|
||||
await new SleeveShopImporter().ImportAsync(context, opts.SeedDir);
|
||||
await new ItemPurchaseImporter().ImportAsync(context, opts.SeedDir);
|
||||
await new LeaderSkinShopImporter().ImportAsync(context, opts.SeedDir);
|
||||
await new SpotCardExchangeImporter().ImportAsync(context, opts.SeedDir);
|
||||
var puzzleImporter = new PuzzleImporter();
|
||||
await puzzleImporter.ImportGroupsAsync(context, opts.SeedDir);
|
||||
await puzzleImporter.ImportPuzzlesAsync(context, opts.SeedDir);
|
||||
|
||||
Reference in New Issue
Block a user