Additional card content

This commit is contained in:
gamer147
2026-05-24 17:07:05 -04:00
parent 12fb2f4801
commit 34bcc579a5
18 changed files with 53025 additions and 16 deletions

View File

@@ -30,6 +30,34 @@ internal class SqliteFriendlyModelCustomizer : ModelCustomizer
shortUdidProperty.ValueGenerated = ValueGenerated.Never;
AssignClientSideKeyGenerators(modelBuilder.Model);
StripCardCosmeticRewardSeed(modelBuilder.Model);
}
/// <summary>
/// CardCosmeticReward rows have an FK to Cards.Id, and the production model HasData-seeds
/// 1068 rows from card_cosmetic_rewards.csv (chunk A.2). In production those rows have
/// matching cards inserted by the CardImporter before runtime. The unit-test factory uses
/// SQLite + EnsureCreated + a minimal 3-card seed — most of the cosmetic-reward rows have
/// no matching Cards row, and EnsureCreated's FK-deferred batch insert throws SqliteException
/// "FOREIGN KEY constraint failed" at host construction time. Strip the seed in tests; the
/// test fixture inserts CardCosmeticReward rows ad-hoc when a specific scenario needs them.
///
/// HasData seed is stored in the internal EntityType._data field (no public API). Clear it
/// via reflection. The clear runs after base.Customize so the HasData call inside Seed()
/// has populated the list before we wipe it.
/// </summary>
private static void StripCardCosmeticRewardSeed(IMutableModel model)
{
var entityType = model.FindEntityType(typeof(CardCosmeticReward));
if (entityType is null) return;
// EntityType._data is a List<IDictionary<string, object>>? — null when empty.
var dataField = entityType.GetType().GetField(
"_data",
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
if (dataField is null) return;
var list = dataField.GetValue(entityType) as System.Collections.IList;
list?.Clear();
}
/// <summary>