refactor(pack): type PackChildGachaEntry.TypeDetail as CardPackType enum

This commit is contained in:
gamer147
2026-06-09 08:48:16 -04:00
parent 833bd85d36
commit 7118b92522
10 changed files with 84 additions and 58 deletions

View File

@@ -48,7 +48,7 @@ public class FreeplayInvariantTests
}
/// <summary>
/// Seeds a crystal pack (parent gacha 10001, child gacha_id 100002, TypeDetail=2, cost=100)
/// Seeds a crystal pack (parent gacha 10001, child gacha_id 100002, TypeDetail = CardPackType.CrystalMulti, cost=100)
/// with the viewer broke (0 crystals). Mirrors the pack shape from
/// PackControllerOpenTests.Open_with_crystals_deducts_crystals — the only difference is
/// Crystals=0 instead of 250, so without freeplay this open would be refused.
@@ -63,7 +63,7 @@ public class FreeplayInvariantTests
Id = 10001, BasePackId = baseId, PackCategory = PackCategory.None,
CommenceDate = DateTime.UtcNow.AddDays(-1), CompleteDate = DateTime.UtcNow.AddDays(30),
GachaType = 1, GachaDetail = "test",
ChildGachas = { new PackChildGachaEntry { GachaId = 100002, TypeDetail = 2, Cost = 100, CardCount = 8 } },
ChildGachas = { new PackChildGachaEntry { GachaId = 100002, TypeDetail = CardPackType.CrystalMulti, Cost = 100, CardCount = 8 } },
});
var v = await db.Viewers.FirstAsync(x => x.Id == viewerId);
v.Currency.Crystals = 0;

View File

@@ -25,7 +25,7 @@ public class PackControllerInfoTests
Id = parentId, BasePackId = baseId, PackCategory = cat,
CommenceDate = DateTime.UtcNow.AddDays(-1), CompleteDate = DateTime.UtcNow.AddDays(30),
GachaType = 1, GachaDetail = "test",
ChildGachas = { new PackChildGachaEntry { GachaId = parentId * 10 + 7, TypeDetail = 7, Cost = 100, CardCount = 8 } },
ChildGachas = { new PackChildGachaEntry { GachaId = parentId * 10 + 7, TypeDetail = CardPackType.RupyMulti, Cost = 100, CardCount = 8 } },
});
await db.SaveChangesAsync();
}
@@ -112,7 +112,7 @@ public class PackControllerInfoTests
CommenceDate = DateTime.UtcNow.AddDays(-1), CompleteDate = DateTime.UtcNow.AddDays(30),
GachaType = 1, GachaDetail = "legendary special", SleeveId = 5090001,
GachaPointConfig = null,
ChildGachas = { new PackChildGachaEntry { GachaId = 920002, TypeDetail = 5, Cost = 1, CardCount = 8, ItemId = 92001 } },
ChildGachas = { new PackChildGachaEntry { GachaId = 920002, TypeDetail = CardPackType.TicketMulti, Cost = 1, CardCount = 8, ItemId = 92001 } },
});
await db.SaveChangesAsync();
}
@@ -149,7 +149,7 @@ public class PackControllerInfoTests
{
// Must include at least one non-ticket child so this pack is NOT ticket-only
// and remains visible with a gacha_point block.
new PackChildGachaEntry { GachaId = 100087, TypeDetail = 7, Cost = 100, CardCount = 8 },
new PackChildGachaEntry { GachaId = 100087, TypeDetail = CardPackType.RupyMulti, Cost = 100, CardCount = 8 },
},
});
var viewer = await db.Viewers
@@ -190,7 +190,7 @@ public class PackControllerInfoTests
GachaPointConfig = new PackGachaPointConfig { ExchangeablePoint = 400, IncreaseGachaPoint = 1 },
ChildGachas =
{
new PackChildGachaEntry { GachaId = 990475, TypeDetail = 5, Cost = 0, CardCount = 8 },
new PackChildGachaEntry { GachaId = 990475, TypeDetail = CardPackType.TicketMulti, Cost = 0, CardCount = 8 },
},
});
await db.SaveChangesAsync();
@@ -227,10 +227,10 @@ public class PackControllerInfoTests
GachaType = 1, GachaDetail = "throwback test", SleeveId = 5090001,
ChildGachas =
{
new PackChildGachaEntry { GachaId = 800032, TypeDetail = 5, Cost = 1, CardCount = 8, ItemId = 80001 },
new PackChildGachaEntry { GachaId = 800032, TypeDetail = CardPackType.TicketMulti, Cost = 1, CardCount = 8, ItemId = 80001 },
new PackChildGachaEntry
{
GachaId = 780032, TypeDetail = 10, Cost = 1, CardCount = 8,
GachaId = 780032, TypeDetail = CardPackType.FreePacks, Cost = 1, CardCount = 8,
PurchaseLimitCount = 1, DailyFreeGachaCount = 1,
FreeGachaCampaignId = 49, CampaignName = "Test Campaign",
},
@@ -272,10 +272,10 @@ public class PackControllerInfoTests
GachaType = 1, GachaDetail = "throwback test", SleeveId = 5090001,
ChildGachas =
{
new PackChildGachaEntry { GachaId = 800033, TypeDetail = 5, Cost = 1, CardCount = 8, ItemId = 80001 },
new PackChildGachaEntry { GachaId = 800033, TypeDetail = CardPackType.TicketMulti, Cost = 1, CardCount = 8, ItemId = 80001 },
new PackChildGachaEntry
{
GachaId = 780033, TypeDetail = 10, Cost = 1, CardCount = 8,
GachaId = 780033, TypeDetail = CardPackType.FreePacks, Cost = 1, CardCount = 8,
DailyFreeGachaCount = 1, FreeGachaCampaignId = 50, CampaignName = "X",
},
},

View File

@@ -32,7 +32,7 @@ public class PackControllerOpenTests
CommenceDate = DateTime.UtcNow.AddDays(-1), CompleteDate = DateTime.UtcNow.AddDays(30),
GachaType = 1, GachaDetail = "test", SleeveId = 3000011,
ChildGachas = {
new PackChildGachaEntry { GachaId = 400002, TypeDetail = 7, Cost = 100, CardCount = 8 },
new PackChildGachaEntry { GachaId = 400002, TypeDetail = CardPackType.RupyMulti, Cost = 100, CardCount = 8 },
},
});
var v = await db.Viewers.FirstAsync(x => x.Id == viewerId);
@@ -142,7 +142,7 @@ public class PackControllerOpenTests
Id = 70001, BasePackId = 70001, PackCategory = PackCategory.LeaderSkinPack,
CommenceDate = DateTime.UtcNow.AddDays(-1), CompleteDate = DateTime.UtcNow.AddDays(30),
GachaType = 1, GachaDetail = "skin pack",
ChildGachas = { new PackChildGachaEntry { GachaId = 700017, TypeDetail = 7, Cost = 100, CardCount = 8 } },
ChildGachas = { new PackChildGachaEntry { GachaId = 700017, TypeDetail = CardPackType.RupyMulti, Cost = 100, CardCount = 8 } },
});
await db.SaveChangesAsync();
}
@@ -186,7 +186,7 @@ public class PackControllerOpenTests
Id = 10001, BasePackId = baseId, PackCategory = PackCategory.None,
CommenceDate = DateTime.UtcNow.AddDays(-1), CompleteDate = DateTime.UtcNow.AddDays(30),
GachaType = 1, GachaDetail = "test",
ChildGachas = { new PackChildGachaEntry { GachaId = 100002, TypeDetail = 2, Cost = 100, CardCount = 8 } },
ChildGachas = { new PackChildGachaEntry { GachaId = 100002, TypeDetail = CardPackType.CrystalMulti, Cost = 100, CardCount = 8 } },
});
var v = await db.Viewers.FirstAsync(x => x.Id == viewerId);
v.Currency.Crystals = 250;
@@ -223,7 +223,7 @@ public class PackControllerOpenTests
CommenceDate = DateTime.UtcNow.AddDays(-1), CompleteDate = DateTime.UtcNow.AddDays(30),
GachaType = 1, GachaDetail = "crystal single",
// type_detail=1 (CRYSTAL single-pack) — new path added 2026-05-31.
ChildGachas = { new PackChildGachaEntry { GachaId = 100012, TypeDetail = 1, Cost = 120, CardCount = 8 } },
ChildGachas = { new PackChildGachaEntry { GachaId = 100012, TypeDetail = CardPackType.Crystal, Cost = 120, CardCount = 8 } },
});
var v = await db.Viewers.FirstAsync(x => x.Id == viewerId);
v.Currency.Crystals = 200;
@@ -254,7 +254,7 @@ public class PackControllerOpenTests
Id = 10001, BasePackId = baseId, PackCategory = PackCategory.None,
CommenceDate = DateTime.UtcNow.AddDays(-1), CompleteDate = DateTime.UtcNow.AddDays(30),
GachaType = 1, GachaDetail = "rupy single",
ChildGachas = { new PackChildGachaEntry { GachaId = 600006, TypeDetail = 6, Cost = 100, CardCount = 8 } },
ChildGachas = { new PackChildGachaEntry { GachaId = 600006, TypeDetail = CardPackType.Rupy, Cost = 100, CardCount = 8 } },
});
var v = await db.Viewers.FirstAsync(x => x.Id == viewerId);
v.Currency.Rupees = 250;
@@ -289,7 +289,7 @@ public class PackControllerOpenTests
CommenceDate = DateTime.UtcNow.AddDays(-1), CompleteDate = DateTime.UtcNow.AddDays(30),
GachaType = 1, GachaDetail = "ticket pack",
// type_detail=4 (TICKET single) — 1 ticket per pack.
ChildGachas = { new PackChildGachaEntry { GachaId = 100014, TypeDetail = 4, Cost = 1, CardCount = 8, ItemId = TicketItemId } },
ChildGachas = { new PackChildGachaEntry { GachaId = 100014, TypeDetail = CardPackType.Ticket, Cost = 1, CardCount = 8, ItemId = TicketItemId } },
});
await db.SaveChangesAsync();
}
@@ -344,7 +344,7 @@ public class PackControllerOpenTests
GachaType = 1, GachaDetail = "10-pack ticket",
// type_detail=5 (TICKET_MULTI 10-pack) — cost=1 ticket per pack, packNumber=10
// => 10 tickets consumed total.
ChildGachas = { new PackChildGachaEntry { GachaId = 100015, TypeDetail = 5, Cost = 1, CardCount = 8, ItemId = TicketItemId } },
ChildGachas = { new PackChildGachaEntry { GachaId = 100015, TypeDetail = CardPackType.TicketMulti, Cost = 1, CardCount = 8, ItemId = TicketItemId } },
});
await db.SaveChangesAsync();
}
@@ -383,7 +383,7 @@ public class PackControllerOpenTests
Id = 10001, BasePackId = baseId, PackCategory = PackCategory.None,
CommenceDate = DateTime.UtcNow.AddDays(-1), CompleteDate = DateTime.UtcNow.AddDays(30),
GachaType = 1, GachaDetail = "ticket pack",
ChildGachas = { new PackChildGachaEntry { GachaId = 100014, TypeDetail = 4, Cost = 1, CardCount = 8, ItemId = TicketItemId } },
ChildGachas = { new PackChildGachaEntry { GachaId = 100014, TypeDetail = CardPackType.Ticket, Cost = 1, CardCount = 8, ItemId = TicketItemId } },
});
await db.SaveChangesAsync();
}
@@ -411,7 +411,7 @@ public class PackControllerOpenTests
Id = 10001, BasePackId = baseId, PackCategory = PackCategory.None,
CommenceDate = DateTime.UtcNow.AddDays(-1), CompleteDate = DateTime.UtcNow.AddDays(30),
GachaType = 1, GachaDetail = "daily test",
ChildGachas = { new PackChildGachaEntry { GachaId = 200001, TypeDetail = 3, Cost = 0, CardCount = 1, IsDailySingle = true } },
ChildGachas = { new PackChildGachaEntry { GachaId = 200001, TypeDetail = CardPackType.Daily, Cost = 0, CardCount = 1, IsDailySingle = true } },
});
await db.SaveChangesAsync();
}
@@ -604,7 +604,7 @@ public class PackControllerOpenTests
CommenceDate = DateTime.UtcNow.AddDays(-1), CompleteDate = DateTime.UtcNow.AddDays(30),
GachaType = 1, GachaDetail = "single-leader test", SleeveId = 3000099,
ChildGachas = {
new PackChildGachaEntry { GachaId = ParentGachaId * 100 + 2, TypeDetail = 7, Cost = 100, CardCount = 8 },
new PackChildGachaEntry { GachaId = ParentGachaId * 100 + 2, TypeDetail = CardPackType.RupyMulti, Cost = 100, CardCount = 8 },
},
});
await db.SaveChangesAsync();
@@ -664,7 +664,7 @@ public class PackControllerOpenTests
{
new PackChildGachaEntry
{
GachaId = 100087, TypeDetail = 7, Cost = 100, CardCount = 8,
GachaId = 100087, TypeDetail = CardPackType.RupyMulti, Cost = 100, CardCount = 8,
OverrideIncreaseGachaPoint = 0,
},
},
@@ -746,7 +746,7 @@ public class PackControllerOpenTests
{
new PackChildGachaEntry
{
GachaId = 990475, TypeDetail = 5, Cost = 0, CardCount = 8,
GachaId = 990475, TypeDetail = CardPackType.TicketMulti, Cost = 0, CardCount = 8,
ItemId = 90001,
},
},
@@ -802,7 +802,7 @@ public class PackControllerOpenTests
{
new PackChildGachaEntry
{
GachaId = 780032, TypeDetail = 10, Cost = 1, CardCount = 8,
GachaId = 780032, TypeDetail = CardPackType.FreePacks, Cost = 1, CardCount = 8,
DailyFreeGachaCount = 1, PurchaseLimitCount = 1,
FreeGachaCampaignId = 49, CampaignName = "Season Bonus",
},

View File

@@ -40,9 +40,10 @@ public class PackSeedingPipelineTests
var children = pack.ChildGachas.OrderBy(c => c.GachaId).ToList();
Assert.That(children.Count, Is.EqualTo(3));
Assert.That(children.Select(c => c.TypeDetail), Is.EqualTo(new[] { 2, 3, 7 }));
Assert.That(children.Select(c => c.TypeDetail),
Is.EqualTo(new[] { CardPackType.CrystalMulti, CardPackType.Daily, CardPackType.RupyMulti }));
Assert.That(children.Select(c => c.Cost), Is.EqualTo(new[] { 100, 50, 100 }));
Assert.That(children.Single(c => c.TypeDetail == 3).IsDailySingle, Is.True);
Assert.That(children.Single(c => c.TypeDetail == CardPackType.Daily).IsDailySingle, Is.True);
}
[Test]
@@ -68,7 +69,7 @@ public class PackSeedingPipelineTests
using var scope = factory.Services.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<SVSimDbContext>();
var pack = await db.Packs.AsNoTracking().FirstAsync(p => p.Id == 80032);
var freeChild = pack.ChildGachas.Single(c => c.TypeDetail == 10);
var freeChild = pack.ChildGachas.Single(c => c.TypeDetail == CardPackType.FreePacks);
Assert.That(freeChild.DailyFreeGachaCount, Is.EqualTo(1));
Assert.That(freeChild.PurchaseLimitCount, Is.EqualTo(1));

View File

@@ -20,7 +20,7 @@ public class PackRepositoryTests
Id = parentId, BasePackId = baseId, PackCategory = cat,
CommenceDate = commence, CompleteDate = complete,
GachaType = 1, GachaDetail = "test",
ChildGachas = { new PackChildGachaEntry { GachaId = parentId * 10, TypeDetail = 7, Cost = 100, CardCount = 8 } },
ChildGachas = { new PackChildGachaEntry { GachaId = parentId * 10, TypeDetail = CardPackType.RupyMulti, Cost = 100, CardCount = 8 } },
});
await db.SaveChangesAsync();
}

View File

@@ -249,7 +249,7 @@ public class GachaPointServiceTests
{
new PackChildGachaEntry
{
GachaId = 100081, TypeDetail = 2, Cost = 100, CardCount = 8,
GachaId = 100081, TypeDetail = CardPackType.CrystalMulti, Cost = 100, CardCount = 8,
OverrideIncreaseGachaPoint = 0,
},
},
@@ -287,7 +287,7 @@ public class GachaPointServiceTests
{
new PackChildGachaEntry
{
GachaId = 100085, TypeDetail = 5, Cost = 0, CardCount = 8,
GachaId = 100085, TypeDetail = CardPackType.TicketMulti, Cost = 0, CardCount = 8,
OverrideIncreaseGachaPoint = 3,
},
},
@@ -318,7 +318,7 @@ public class GachaPointServiceTests
Id = 99047, BasePackId = 99047, PackCategory = PackCategory.LegendCardPack,
CommenceDate = DateTime.UtcNow.AddDays(-1), CompleteDate = DateTime.UtcNow.AddDays(30),
GachaPointConfig = null,
ChildGachas = { new PackChildGachaEntry { GachaId = 990475, TypeDetail = 5, Cost = 0, CardCount = 8 } },
ChildGachas = { new PackChildGachaEntry { GachaId = 990475, TypeDetail = CardPackType.TicketMulti, Cost = 0, CardCount = 8 } },
});
await db.SaveChangesAsync();
@@ -347,7 +347,7 @@ public class GachaPointServiceTests
GachaPointConfig = new PackGachaPointConfig { ExchangeablePoint = 400, IncreaseGachaPoint = 1 },
ChildGachas =
{
new PackChildGachaEntry { GachaId = 100087, TypeDetail = 7, Cost = 100, CardCount = 8 },
new PackChildGachaEntry { GachaId = 100087, TypeDetail = CardPackType.RupyMulti, Cost = 100, CardCount = 8 },
},
});
await db.SaveChangesAsync();