feat(packs): wire PackDrawTableImporter; retire ICardPoolProvider

Bootstrap Program.cs now calls PackDrawTableImporter after PackImporter.
Delete DbCardPoolProvider, ICardPoolProvider, and the DbCardPoolProvider
tests — the new IPackDrawTableRepository covers what GachaPointService
needed (legendary-tier card_ids per pack) and PackOpenService takes the
draw table directly.

GachaPointService now resolves the legendary catalog from
PackDrawTable.CardWeights filtered by Tier==Legendary, instead of
ICardPoolProvider.GetPool then a rarity filter. Same end set, no DB pool
walk.

Test fallout: tests that fabricate custom card sets for gacha-point
tests now call factory.SeedPackDrawTableFromSetAsync(packId, setId)
to install a matching legendary-tier stub. Full suite: 647/647 green.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-05-30 22:45:02 -04:00
parent 1c386b5ed0
commit 517f855112
9 changed files with 60 additions and 239 deletions

View File

@@ -3,6 +3,7 @@ using Microsoft.EntityFrameworkCore;
using SVSim.Database;
using SVSim.Database.Enums;
using SVSim.Database.Models;
using SVSim.Database.Repositories.PackDrawTables;
using SVSim.Database.Services;
using SVSim.EmulatedEntrypoint.Models.Dtos;
@@ -11,13 +12,13 @@ namespace SVSim.EmulatedEntrypoint.Services;
public sealed class GachaPointService : IGachaPointService
{
private readonly SVSimDbContext _db;
private readonly ICardPoolProvider _pools;
private readonly IPackDrawTableRepository _drawTables;
private readonly RewardGrantService _grants;
public GachaPointService(SVSimDbContext db, ICardPoolProvider pools, RewardGrantService grants)
public GachaPointService(SVSimDbContext db, IPackDrawTableRepository drawTables, RewardGrantService grants)
{
_db = db;
_pools = pools;
_drawTables = drawTables;
_grants = grants;
}
@@ -26,7 +27,8 @@ public sealed class GachaPointService : IGachaPointService
var pack = await _db.Packs.FirstOrDefaultAsync(p => p.Id == packId);
if (pack?.GachaPointConfig is null) return Array.Empty<GachaPointRewardDto>();
var pool = _pools.GetPool(pack);
var drawTable = await _drawTables.GetAsync(packId);
if (drawTable is null) return Array.Empty<GachaPointRewardDto>();
// EF Core 8 has no ToHashSetAsync on IQueryable — materialize via ToListAsync then hash.
var receivedCardIds = (await _db.Viewers
@@ -36,9 +38,11 @@ public sealed class GachaPointService : IGachaPointService
.Select(r => r.CardId)
.ToListAsync()).ToHashSet();
var legendaryCardIds = pool
.Where(c => c.Rarity == Rarity.Legendary && !c.IsFoil)
.Select(c => c.Id)
// Legendaries in the pack's draw table — exchange ignores foils (the alt-art foil
// printing is gated separately) and tiers other than Legendary.
var legendaryCardIds = drawTable.CardWeights
.Where(w => w.Tier == DrawTier.Legendary && !w.IsAltArt)
.Select(w => w.CardId)
.ToHashSet();
// Re-query legendaries with Class loaded — pool provider doesn't include navs,