Pack opening
This commit is contained in:
42
SVSim.EmulatedEntrypoint/Services/DbCardPoolProvider.cs
Normal file
42
SVSim.EmulatedEntrypoint/Services/DbCardPoolProvider.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
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:
|
||||
// Standard pack — pool comes from the card set whose id equals base_pack_id.
|
||||
return _db.CardSets
|
||||
.Include(s => s.Cards)
|
||||
.Where(s => s.Id == pack.BasePackId)
|
||||
.SelectMany(s => s.Cards)
|
||||
.ToList();
|
||||
|
||||
case PackCategory.SpecialCardPack:
|
||||
case PackCategory.LimitedSpecialCardPack:
|
||||
// Legendary-special packs pull from all rotation sets. The slot-8 forced-Legendary
|
||||
// rule in PackOpenService delivers the "at least one legendary" promise.
|
||||
return _db.CardSets
|
||||
.Where(s => s.IsInRotation)
|
||||
.Include(s => s.Cards)
|
||||
.SelectMany(s => s.Cards)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
||||
default:
|
||||
// Skin / starter / leader-skin packs aren't drawn in v1 — controller rejects earlier.
|
||||
return Array.Empty<ShadowverseCardEntry>();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user