Files
SVSimServer/SVSim.EmulatedEntrypoint/Services/DbCardPoolProvider.cs
gamer147 27ebb5114c fix(pack): tutorial flow display + open end-to-end
Four targeted fixes that together let /tutorial/pack_info display
the legendary starter at index 0, let /tutorial/pack_open succeed
on it, and let the pack drop out of the shop after.

1. /pack/info now loads viewer.Items into a Dictionary<long,int>
   and threads it through ToDto so child_gacha_info.item_number
   reflects the viewer's actual owned count of item_id. Previously
   defaulted to 0 for every pack, so the legendary pack 99047
   reported item_number=0 immediately after the gift granted 1×
   ticket id=90001. Verified against the prod tutorial capture.

2. PackRepository.GetActivePacks now orders parent_gacha_id DESC
   to match prod's /pack/info wire order (99047, 92001, 80047,
   16015...10001). The tutorial pack UI runs with controls locked
   and auto-selects index 0 via GachaUI.GetCurrentLegendPackId
   (FirstOrDefault on IsLegendPackId), so the legendary starter
   needs to be the first legend pack in the list.

3. DbCardPoolProvider.GetPool falls back to all in-rotation cards
   when a LegendCardPack's base set has no rows. Pack 99047's
   base_pack_id is 90001, a synthetic "Throwback Rotation" category
   that doesn't correspond to a real card_set in the prod card
   master — its real pool is curated across older rotation sets
   (Altersphere through Colosseum). We don't have that membership
   map captured yet; the rotation fallback is broader than prod
   but produces a valid 8-card draw, which is what the tutorial
   needs to advance to step 100. TODO in code points at the
   real fix.

4. PackController.Open's tutorial path now consumes the granted
   ticket (decrement viewer.Items by packNumber for child.ItemId)
   and emits the post-state count in reward_list as
   {reward_type:4, reward_id:item_id, reward_num:post_count}.
   Without this, the pack stayed at item_number=1 forever, the
   shop kept showing it post-tutorial, and the next click hit
   /pack/open (not /tutorial/pack_open) which 501s on type_detail=5.

Also: docstring on PackConfigDto.SalesPeriodInfo flags the deferred
wire-fidelity fix (prod emits {"sales_period_time": "<complete_date>"}
for limited windows, [] for evergreens; we always emit {}) and the
retype from Dictionary<string,string?> to a typed
PackSalesPeriodInfoDto. Doesn't affect tutorial flow, deferred for
the pack-system rework.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-28 18:04:13 -04:00

62 lines
2.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Microsoft.EntityFrameworkCore;
using SVSim.Database;
using SVSim.Database.Enums;
using SVSim.Database.Models;
namespace SVSim.EmulatedEntrypoint.Services;
public class DbCardPoolProvider : ICardPoolProvider
{
private readonly SVSimDbContext _db;
public DbCardPoolProvider(SVSimDbContext db) { _db = db; }
public IReadOnlyList<ShadowverseCardEntry> GetPool(PackConfigEntry pack)
{
switch (pack.PackCategory)
{
case PackCategory.None:
case PackCategory.LegendCardPack:
{
var pool = _db.CardSets
.Where(s => s.Id == pack.BasePackId)
.SelectMany(s => s.Cards)
.Where(c => !c.IsFoil)
.ToList();
if (pool.Count > 0) return pool;
// BasePackId 90001 (and the 9xxxx range generally) is a synthetic "Throwback
// Rotation" category that doesn't have a corresponding real card_set in the
// prod card master — its real pool is a curated subset of rotation-eligible
// older sets (AltersphereColosseum for 99047; see the gacha_detail string).
// We don't have that membership map, so fall back to all in-rotation cards.
// Broader pool than prod but produces a valid 8-card draw, which is what the
// tutorial flow needs to advance to step 100.
// TODO: import the real Throwback Rotation card-set membership and key the
// pool off that. Source data is in the client's pack-pool master, not yet
// captured.
return _db.CardSets
.Where(s => s.IsInRotation)
.SelectMany(s => s.Cards)
.Where(c => !c.IsFoil)
.Distinct()
.ToList();
}
case PackCategory.SpecialCardPack:
case PackCategory.LimitedSpecialCardPack:
return _db.CardSets
.Where(s => s.IsInRotation)
.SelectMany(s => s.Cards)
.Where(c => !c.IsFoil)
.Distinct()
.ToList();
default:
return Array.Empty<ShadowverseCardEntry>();
}
}
public ShadowverseCardEntry? TryGetFoilTwin(long baseCardId) =>
_db.Cards.FirstOrDefault(c => c.Id == baseCardId + 1 && c.IsFoil);
}