fix(pack): include all pack legendaries in gacha-point catalog + correct class_id
This commit is contained in:
@@ -478,6 +478,93 @@ public class GachaPointServiceTests
|
||||
Is.True, "card grant missing");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetRewards_emits_correct_class_id_for_non_neutral_cards()
|
||||
{
|
||||
using var factory = new SVSimTestFactory();
|
||||
long viewerId = await factory.SeedViewerAsync();
|
||||
using var scope = factory.Services.CreateScope();
|
||||
var db = scope.ServiceProvider.GetRequiredService<SVSimDbContext>();
|
||||
|
||||
// Use the pre-seeded Forestcraft (Id=1) and Havencraft (Id=7) classes from ReferenceDataImporter.
|
||||
var forest = await db.Classes.FirstAsync(c => c.Id == 1);
|
||||
var haven = await db.Classes.FirstAsync(c => c.Id == 7);
|
||||
|
||||
var set = new ShadowverseCardSetEntry { Id = 10008, IsInRotation = true };
|
||||
db.CardSets.Add(set);
|
||||
set.Cards.AddRange(new[]
|
||||
{
|
||||
new ShadowverseCardEntry
|
||||
{
|
||||
Id = 108141010, Name = "leg-forest", Rarity = Rarity.Legendary,
|
||||
Class = forest, IsFoil = false,
|
||||
},
|
||||
new ShadowverseCardEntry
|
||||
{
|
||||
Id = 108741010, Name = "leg-haven", Rarity = Rarity.Legendary,
|
||||
Class = haven, IsFoil = false,
|
||||
},
|
||||
});
|
||||
db.CardCosmeticRewards.AddRange(
|
||||
new CardCosmeticReward { CardId = 108141010, Type = CosmeticType.Emblem, CosmeticId = 1081410100 },
|
||||
new CardCosmeticReward { CardId = 108741010, Type = CosmeticType.Emblem, CosmeticId = 1087410100 });
|
||||
db.Packs.Add(new PackConfigEntry
|
||||
{
|
||||
Id = 10008, BasePackId = 10008, PackCategory = PackCategory.LegendCardPack,
|
||||
CommenceDate = DateTime.UtcNow.AddDays(-1), CompleteDate = DateTime.UtcNow.AddDays(30),
|
||||
GachaPointConfig = new PackGachaPointConfig { ExchangeablePoint = 400, IncreaseGachaPoint = 1 },
|
||||
});
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
var svc = scope.ServiceProvider.GetRequiredService<IGachaPointService>();
|
||||
var result = await svc.GetRewardsAsync(10008, viewerId);
|
||||
|
||||
// Cards must surface with their REAL class id, not the "0" neutral fallback caused
|
||||
// by the pool provider not Including Class.
|
||||
Assert.That(result, Has.Count.EqualTo(2));
|
||||
var forestEntry = result.Single(r => r.CardId == 108141010);
|
||||
var havenEntry = result.Single(r => r.CardId == 108741010);
|
||||
Assert.That(forestEntry.ClassId, Is.EqualTo("1"));
|
||||
Assert.That(havenEntry.ClassId, Is.EqualTo("7"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetRewards_includes_legendaries_without_emblem_cosmetics()
|
||||
{
|
||||
using var factory = new SVSimTestFactory();
|
||||
long viewerId = await factory.SeedViewerAsync();
|
||||
using var scope = factory.Services.CreateScope();
|
||||
var db = scope.ServiceProvider.GetRequiredService<SVSimDbContext>();
|
||||
|
||||
// Pack 10001 simulation: a legendary with NO CardCosmeticReward rows at all.
|
||||
// Must still appear in the catalog (per user spec — all pack legendaries are
|
||||
// exchangeable, regardless of whether we have captured emblem mappings).
|
||||
// Use a unique card-set id (10099) because SVSimTestFactory already seeds a
|
||||
// minimal CardSet at Id=10001.
|
||||
var set = new ShadowverseCardSetEntry { Id = 10099, IsInRotation = true };
|
||||
db.CardSets.Add(set);
|
||||
set.Cards.Add(new ShadowverseCardEntry
|
||||
{
|
||||
Id = 101141020, Name = "old-leg", Rarity = Rarity.Legendary,
|
||||
Class = null, IsFoil = false,
|
||||
});
|
||||
db.Packs.Add(new PackConfigEntry
|
||||
{
|
||||
Id = 10099, BasePackId = 10099, PackCategory = PackCategory.LegendCardPack,
|
||||
CommenceDate = DateTime.UtcNow.AddDays(-1), CompleteDate = DateTime.UtcNow.AddDays(30),
|
||||
GachaPointConfig = new PackGachaPointConfig { ExchangeablePoint = 400, IncreaseGachaPoint = 1 },
|
||||
});
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
var svc = scope.ServiceProvider.GetRequiredService<IGachaPointService>();
|
||||
var result = await svc.GetRewardsAsync(10099, viewerId);
|
||||
|
||||
Assert.That(result, Has.Count.EqualTo(1));
|
||||
Assert.That(result[0].CardId, Is.EqualTo(101141020));
|
||||
Assert.That(result[0].RewardList, Is.Empty,
|
||||
"legendary without emblem rows emits empty reward_list — the catalog declaration is just the card itself");
|
||||
}
|
||||
|
||||
private static void SeedPackWithOneLegendary(SVSimDbContext db, int packId, int threshold)
|
||||
{
|
||||
var cls = db.Classes.Find(0) ?? new ClassEntry { Id = 0, Name = "Neutral" };
|
||||
|
||||
Reference in New Issue
Block a user