diff --git a/SVSim.Bootstrap/Importers/ColosseumCuratedDeckImporterBase.cs b/SVSim.Bootstrap/Importers/ColosseumCuratedDeckImporterBase.cs new file mode 100644 index 00000000..09d0f978 --- /dev/null +++ b/SVSim.Bootstrap/Importers/ColosseumCuratedDeckImporterBase.cs @@ -0,0 +1,86 @@ +using Microsoft.EntityFrameworkCore; +using SVSim.Database; +using SVSim.Database.Models; + +namespace SVSim.Bootstrap.Importers; + +/// +/// Shared upsert path for the three Colosseum curated-deck pools. Each subclass binds the +/// EF entity type + the seed filename; the load + key + diff logic lives here. Empty seed +/// files are non-fatal — the pools ship empty by default per the plan (admins fill them +/// per-event). +/// +public abstract class ColosseumCuratedDeckImporterBase + where TEntity : class, IColosseumCuratedDeck, new() +{ + protected abstract string SeedFileName { get; } + + public async Task ImportAsync(SVSimDbContext context, string seedDir) + { + var path = Path.Combine(seedDir, SeedFileName); + if (!File.Exists(path)) + { + Console.WriteLine($"[{GetType().Name}] missing {path}; skipping."); + return 0; + } + + var seeds = SeedLoader.LoadList(path); + var set = context.Set(); + var existing = await set.ToDictionaryAsync(d => d.DeckNo); + + int upserted = 0; + foreach (var s in seeds) + { + if (existing.TryGetValue(s.DeckNo, out var row)) + { + row.ClassId = s.ClassId; + row.CardListJson = s.CardListJson; + row.SleeveId = s.SleeveId; + row.LeaderSkinId = s.LeaderSkinId; + row.DisplayOrder = s.DisplayOrder; + } + else + { + set.Add(new TEntity + { + DeckNo = s.DeckNo, + ClassId = s.ClassId, + CardListJson = s.CardListJson, + SleeveId = s.SleeveId, + LeaderSkinId = s.LeaderSkinId, + DisplayOrder = s.DisplayOrder, + }); + } + upserted++; + } + + await context.SaveChangesAsync(); + Console.WriteLine($"[{GetType().Name}] upserted={upserted}"); + return upserted; + } +} + +public sealed class ColosseumCuratedDeckSeed +{ + public int DeckNo { get; set; } + public int ClassId { get; set; } + public string CardListJson { get; set; } = "[]"; + public long SleeveId { get; set; } + public long LeaderSkinId { get; set; } + public int DisplayOrder { get; set; } +} + +public sealed class ColosseumHofDecksImporter : ColosseumCuratedDeckImporterBase +{ + protected override string SeedFileName => "colosseum-hof-decks.json"; +} + +public sealed class ColosseumWindFallDecksImporter : ColosseumCuratedDeckImporterBase +{ + protected override string SeedFileName => "colosseum-windfall-decks.json"; +} + +public sealed class ColosseumAvatarDecksImporter : ColosseumCuratedDeckImporterBase +{ + protected override string SeedFileName => "colosseum-avatar-decks.json"; +} diff --git a/SVSim.Bootstrap/Program.cs b/SVSim.Bootstrap/Program.cs index 403126c1..34110eb1 100644 --- a/SVSim.Bootstrap/Program.cs +++ b/SVSim.Bootstrap/Program.cs @@ -85,6 +85,9 @@ public static class Program await new AvatarAbilityImporter().ImportAsync(context, opts.SeedDir); await new ArenaSeasonImporter().ImportAsync(context, opts.SeedDir); await new ArenaTwoPickRewardImporter().ImportAsync(context, opts.SeedDir); + await new ColosseumHofDecksImporter().ImportAsync(context, opts.SeedDir); + await new ColosseumWindFallDecksImporter().ImportAsync(context, opts.SeedDir); + await new ColosseumAvatarDecksImporter().ImportAsync(context, opts.SeedDir); await new BattlePassImporter().ImportAsync(context, opts.SeedDir); await new BattlePassSeasonImporter().ImportAsync(context, opts.SeedDir); await new BattlePassRewardImporter().ImportAsync(context, opts.SeedDir); diff --git a/SVSim.Database/Migrations/20260613155613_AddArenaColosseumRun.Designer.cs b/SVSim.Database/Migrations/20260613155613_AddArenaColosseumRun.Designer.cs new file mode 100644 index 00000000..563e288a --- /dev/null +++ b/SVSim.Database/Migrations/20260613155613_AddArenaColosseumRun.Designer.cs @@ -0,0 +1,4761 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using SVSim.Database; + +#nullable disable + +namespace SVSim.Database.Migrations +{ + [DbContext(typeof(SVSimDbContext))] + [Migration("20260613155613_AddArenaColosseumRun")] + partial class AddArenaColosseumRun + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.HasSequence("ShortUdidSequence") + .StartsAt(400000000L); + + modelBuilder.Entity("DegreeEntryViewer", b => + { + b.Property("DegreesId") + .HasColumnType("integer"); + + b.Property("ViewersId") + .HasColumnType("bigint"); + + b.HasKey("DegreesId", "ViewersId"); + + b.HasIndex("ViewersId"); + + b.ToTable("DegreeEntryViewer"); + }); + + modelBuilder.Entity("EmblemEntryViewer", b => + { + b.Property("EmblemsId") + .HasColumnType("integer"); + + b.Property("ViewersId") + .HasColumnType("bigint"); + + b.HasKey("EmblemsId", "ViewersId"); + + b.HasIndex("ViewersId"); + + b.ToTable("EmblemEntryViewer"); + }); + + modelBuilder.Entity("LeaderSkinEntryViewer", b => + { + b.Property("LeaderSkinsId") + .HasColumnType("integer"); + + b.Property("ViewersId") + .HasColumnType("bigint"); + + b.HasKey("LeaderSkinsId", "ViewersId"); + + b.HasIndex("ViewersId"); + + b.ToTable("LeaderSkinEntryViewer"); + }); + + modelBuilder.Entity("MyPageBackgroundEntryViewer", b => + { + b.Property("MyPageBackgroundsId") + .HasColumnType("integer"); + + b.Property("ViewersId") + .HasColumnType("bigint"); + + b.HasKey("MyPageBackgroundsId", "ViewersId"); + + b.HasIndex("ViewersId"); + + b.ToTable("MyPageBackgroundEntryViewer"); + }); + + modelBuilder.Entity("SVSim.Database.Entities.Story.SpecialBattleSetting", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("BanishEffectOverride") + .IsRequired() + .HasColumnType("text"); + + b.Property("ClassDestroyEffectOverride") + .HasColumnType("integer"); + + b.Property("EnemyAttachSkill") + .IsRequired() + .HasColumnType("text"); + + b.Property("EnemyStartLife") + .HasColumnType("integer"); + + b.Property("EnemyStartPp") + .HasColumnType("integer"); + + b.Property("IdOverrideInBattleLog") + .IsRequired() + .HasColumnType("text"); + + b.Property("Note") + .HasColumnType("text"); + + b.Property("PlayerAttachSkill") + .IsRequired() + .HasColumnType("text"); + + b.Property("PlayerFirstTurn") + .HasColumnType("integer"); + + b.Property("PlayerStartLife") + .HasColumnType("integer"); + + b.Property("PlayerStartPp") + .HasColumnType("integer"); + + b.Property("ResultSkip") + .HasColumnType("integer"); + + b.Property("SpecialTokenDrawEffectOverride") + .IsRequired() + .HasColumnType("text"); + + b.Property("TokenDrawEffectOverride") + .IsRequired() + .HasColumnType("text"); + + b.Property("VsEffectOverride") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("SpecialBattleSettings"); + }); + + modelBuilder.Entity("SVSim.Database.Entities.Story.StoryChapter", b => + { + b.Property("StoryId") + .HasColumnType("integer"); + + b.Property("Battle3dFieldId") + .HasColumnType("integer"); + + b.Property("BattleExists") + .HasColumnType("boolean"); + + b.Property("BgFileName") + .IsRequired() + .HasColumnType("text"); + + b.Property("BgmId") + .IsRequired() + .HasColumnType("text"); + + b.Property("ChapterClearTextId") + .HasColumnType("text"); + + b.Property("ChapterEffectPath") + .HasColumnType("text"); + + b.Property("ChapterId") + .IsRequired() + .HasColumnType("text"); + + b.Property("CharaId") + .HasColumnType("integer"); + + b.Property("EnemyAiId") + .HasColumnType("integer"); + + b.Property("EnemyCharaId") + .HasColumnType("integer"); + + b.Property("EnemyClass") + .HasColumnType("integer"); + + b.Property("IsCameraMovable") + .HasColumnType("integer"); + + b.Property("IsMaintenanceChapter") + .HasColumnType("boolean"); + + b.Property("IsPlayAnotherEndAppearanceAnimation") + .HasColumnType("boolean"); + + b.Property("IsReleasedAnotherEnd") + .HasColumnType("boolean"); + + b.Property("IsSkipEnabled") + .HasColumnType("boolean"); + + b.Property("NextChapterId") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReleasePoint") + .HasColumnType("integer"); + + b.Property("RequiredChapterId") + .HasColumnType("text"); + + b.Property("SectionId") + .HasColumnType("integer"); + + b.Property("SelectionDisplayPosition") + .HasColumnType("text"); + + b.Property("SelectionTextId") + .HasColumnType("text"); + + b.Property("ShowCoordinate") + .HasColumnType("integer"); + + b.Property("ShowSubtitles") + .HasColumnType("integer"); + + b.Property("SpecialBattleSettingId") + .HasColumnType("integer"); + + b.Property("UnlockText") + .HasColumnType("text"); + + b.Property("XCoordinate") + .HasColumnType("numeric"); + + b.Property("YCoordinate") + .HasColumnType("numeric"); + + b.HasKey("StoryId"); + + b.HasIndex("NextChapterId"); + + b.HasIndex("SpecialBattleSettingId"); + + b.HasIndex("SectionId", "CharaId", "ChapterId"); + + b.ToTable("StoryChapters"); + }); + + modelBuilder.Entity("SVSim.Database.Entities.Story.StorySection", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("AllStoryOrderId") + .HasColumnType("integer"); + + b.Property("BackGroundId") + .HasColumnType("integer"); + + b.Property("ChapterSelectType") + .HasColumnType("integer"); + + b.Property("ImageName") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsLeaderSelect") + .HasColumnType("boolean"); + + b.Property("IsPlayAnotherEndAppearanceAnimation") + .HasColumnType("boolean"); + + b.Property("IsSpoiler") + .HasColumnType("integer"); + + b.Property("IsUnderMaintenance") + .HasColumnType("boolean"); + + b.Property("NameTextKey") + .IsRequired() + .HasColumnType("text"); + + b.Property("OrderId") + .HasColumnType("integer"); + + b.Property("SpoilerMessage") + .IsRequired() + .HasColumnType("text"); + + b.Property("StoryApiType") + .HasColumnType("integer"); + + b.Property("StoryTypeOverwrite") + .HasColumnType("integer"); + + b.Property("WorldId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("WorldId"); + + b.ToTable("StorySections"); + }); + + modelBuilder.Entity("SVSim.Database.Entities.Story.StoryWorld", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("PanelImageName") + .IsRequired() + .HasColumnType("text"); + + b.Property("RibbonText") + .IsRequired() + .HasColumnType("text"); + + b.Property("TitleTextKey") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("StoryWorlds"); + }); + + modelBuilder.Entity("SVSim.Database.Entities.Story.ViewerStoryBranchUnlock", b => + { + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.Property("StoryId") + .HasColumnType("integer"); + + b.Property("UnlockedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("ViewerId", "StoryId"); + + b.ToTable("ViewerStoryBranchUnlocks"); + }); + + modelBuilder.Entity("SVSim.Database.Entities.Story.ViewerStoryProgress", b => + { + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.Property("StoryId") + .HasColumnType("integer"); + + b.Property("FinishedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("IsFinish") + .HasColumnType("boolean"); + + b.Property("IsSkipped") + .HasColumnType("boolean"); + + b.Property("SkippedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("ViewerId", "StoryId"); + + b.ToTable("ViewerStoryProgress"); + }); + + modelBuilder.Entity("SVSim.Database.Models.AchievementCatalogEntry", b => + { + b.Property("AchievementType") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("EventArg") + .HasColumnType("integer"); + + b.Property("EventType") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("OrderNum") + .HasColumnType("integer"); + + b.Property("RequireNumber") + .HasColumnType("integer"); + + b.Property("RewardDetailId") + .HasColumnType("bigint"); + + b.Property("RewardNumber") + .HasColumnType("integer"); + + b.Property("RewardType") + .HasColumnType("integer"); + + b.HasKey("AchievementType", "Level"); + + b.HasIndex("AchievementType"); + + b.HasIndex("EventType", "EventArg"); + + b.ToTable("AchievementCatalog"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ArenaSeasonConfig", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("Cost") + .HasColumnType("numeric(20,0)"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("Enable") + .HasColumnType("integer"); + + b.Property("FormatInfo") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("IsJoin") + .HasColumnType("boolean"); + + b.Property("Mode") + .HasColumnType("integer"); + + b.Property("RupyCost") + .HasColumnType("numeric(20,0)"); + + b.Property("TicketCost") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("ArenaSeasons"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ArenaTwoPickReward", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("RewardGroup") + .HasColumnType("integer"); + + b.Property("RewardId") + .HasColumnType("bigint"); + + b.Property("RewardNum") + .HasColumnType("integer"); + + b.Property("RewardType") + .HasColumnType("integer"); + + b.Property("Weight") + .HasColumnType("integer"); + + b.Property("WinCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("WinCount"); + + b.HasIndex("WinCount", "RewardGroup", "RewardType", "RewardId", "RewardNum") + .IsUnique(); + + b.ToTable("ArenaTwoPickRewards"); + }); + + modelBuilder.Entity("SVSim.Database.Models.AvatarAbilityEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("Ability") + .IsRequired() + .HasColumnType("text"); + + b.Property("AbilityCost") + .IsRequired() + .HasColumnType("text"); + + b.Property("AbilityDesc") + .IsRequired() + .HasColumnType("text"); + + b.Property("BattleStartFirstPlayerTurnBp") + .HasColumnType("integer"); + + b.Property("BattleStartMaxLife") + .HasColumnType("integer"); + + b.Property("BattleStartSecondPlayerTurnBp") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("LeaderSkinId") + .HasColumnType("integer"); + + b.Property("PassiveAbility") + .IsRequired() + .HasColumnType("text"); + + b.Property("PassiveAbilityDesc") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("AvatarAbilities"); + }); + + modelBuilder.Entity("SVSim.Database.Models.BannerEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("ChangeTime") + .HasColumnType("integer"); + + b.Property("Click") + .IsRequired() + .HasColumnType("text"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("ImageName") + .IsRequired() + .HasColumnType("text"); + + b.Property("ImagePaths") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("RemainingTime") + .HasColumnType("integer"); + + b.Property("Status") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Banners"); + }); + + modelBuilder.Entity("SVSim.Database.Models.BattlePassLevelEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("RequiredPoint") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("BattlePassLevels"); + }); + + modelBuilder.Entity("SVSim.Database.Models.BattlePassMonthlyMissionEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BattlePassPoint") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("EventArg") + .HasColumnType("integer"); + + b.Property("EventType") + .HasColumnType("text"); + + b.Property("Month") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("OrderNum") + .HasColumnType("integer"); + + b.Property("RequireNumber") + .HasColumnType("integer"); + + b.Property("RewardDetailId") + .HasColumnType("bigint"); + + b.Property("RewardNumber") + .HasColumnType("integer"); + + b.Property("RewardType") + .HasColumnType("integer"); + + b.Property("Year") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Year", "Month"); + + b.HasIndex("Year", "Month", "OrderNum") + .IsUnique(); + + b.ToTable("BattlePassMonthlyMissions"); + }); + + modelBuilder.Entity("SVSim.Database.Models.BattlePassRewardEntry", b => + { + b.Property("Id") + .HasColumnType("bigint"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("IsAppealExclusion") + .HasColumnType("boolean"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("RewardDetailId") + .HasColumnType("bigint"); + + b.Property("RewardNumber") + .HasColumnType("integer"); + + b.Property("RewardType") + .HasColumnType("integer"); + + b.Property("SeasonId") + .HasColumnType("integer"); + + b.Property("Track") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("SeasonId", "Track", "Level") + .IsUnique(); + + b.ToTable("BattlePassRewards"); + }); + + modelBuilder.Entity("SVSim.Database.Models.BattlePassSeasonEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("CanPurchase") + .HasColumnType("boolean"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("EndDate") + .HasColumnType("timestamp with time zone"); + + b.Property("MaxLevel") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("PriceCrystal") + .HasColumnType("integer"); + + b.Property("StartDate") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("StartDate", "EndDate"); + + b.ToTable("BattlePassSeasons"); + }); + + modelBuilder.Entity("SVSim.Database.Models.BattlefieldEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("IsOpen") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Battlefields"); + }); + + modelBuilder.Entity("SVSim.Database.Models.BotRosterEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("AiId") + .HasColumnType("integer"); + + b.Property("BattlePoint") + .HasColumnType("integer"); + + b.Property("CharaId") + .HasColumnType("integer"); + + b.Property("ClassId") + .HasColumnType("integer"); + + b.Property("CountryCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("DegreeId") + .HasColumnType("integer"); + + b.Property("EmblemId") + .HasColumnType("integer"); + + b.Property("FieldId") + .HasColumnType("integer"); + + b.Property("IsMasterRank") + .HasColumnType("integer"); + + b.Property("IsOfficial") + .HasColumnType("integer"); + + b.Property("MasterPoint") + .HasColumnType("integer"); + + b.Property("Rank") + .HasColumnType("integer"); + + b.Property("SleeveId") + .HasColumnType("integer"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("BotRoster"); + }); + + modelBuilder.Entity("SVSim.Database.Models.BuildDeckProductEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("DeckCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("FeaturedCardId") + .HasColumnType("bigint"); + + b.Property("IntroPriceCrystal") + .HasColumnType("integer"); + + b.Property("IntroPriceRupy") + .HasColumnType("integer"); + + b.Property("IsEnabled") + .HasColumnType("boolean"); + + b.Property("LeaderId") + .HasColumnType("integer"); + + b.Property("ProductNameKey") + .IsRequired() + .HasColumnType("text"); + + b.Property("PurchaseNumMax") + .HasColumnType("integer"); + + b.Property("RegularPriceCrystal") + .HasColumnType("integer"); + + b.Property("RegularPriceRupy") + .HasColumnType("integer"); + + b.Property("SeriesId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("SeriesId"); + + b.ToTable("BuildDeckProducts"); + }); + + modelBuilder.Entity("SVSim.Database.Models.BuildDeckSeriesEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("DrumrollPath") + .IsRequired() + .HasColumnType("text"); + + b.Property("IntroKey") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsEnabled") + .HasColumnType("boolean"); + + b.Property("IsNew") + .HasColumnType("boolean"); + + b.Property("NameKey") + .IsRequired() + .HasColumnType("text"); + + b.Property("OrderIndex") + .HasColumnType("integer"); + + b.Property("TitlePath") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("BuildDeckSeries"); + }); + + modelBuilder.Entity("SVSim.Database.Models.CardCosmeticReward", b => + { + b.Property("CardId") + .HasColumnType("bigint"); + + b.Property("Type") + .HasColumnType("integer"); + + b.Property("CosmeticId") + .HasColumnType("bigint"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.HasKey("CardId", "Type", "CosmeticId"); + + b.HasIndex("CardId"); + + b.ToTable("CardCosmeticRewards"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ClassEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Classes"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ClassExpEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("NecessaryExp") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("ClassExpCurve"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ColosseumConfig", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("CardPoolName") + .IsRequired() + .HasColumnType("text"); + + b.Property("ColosseumId") + .IsRequired() + .HasColumnType("text"); + + b.Property("ColosseumName") + .IsRequired() + .HasColumnType("text"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("DeckFormat") + .IsRequired() + .HasColumnType("text"); + + b.Property("EndTime") + .HasColumnType("timestamp with time zone"); + + b.Property("IsAllCardEnabled") + .HasColumnType("integer"); + + b.Property("IsColosseumPeriod") + .HasColumnType("boolean"); + + b.Property("IsDisplayTips") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsNormalTwoPick") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRoundPeriod") + .HasColumnType("boolean"); + + b.Property("IsSpecialMode") + .IsRequired() + .HasColumnType("text"); + + b.Property("NowRound") + .IsRequired() + .HasColumnType("text"); + + b.Property("SalesPeriodInfo") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("StartTime") + .HasColumnType("timestamp with time zone"); + + b.Property("TipsId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Colosseums"); + }); + + modelBuilder.Entity("SVSim.Database.Models.DailyLoginBonusEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("BonusData") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("BonusId") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("DailyLoginBonuses"); + }); + + modelBuilder.Entity("SVSim.Database.Models.DefaultDeckEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("CardIdArray") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("ClassId") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("DeckName") + .IsRequired() + .HasColumnType("text"); + + b.Property("DeckNo") + .HasColumnType("integer"); + + b.Property("LeaderSkinId") + .HasColumnType("integer"); + + b.Property("SleeveId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.ToTable("DefaultDecks"); + }); + + modelBuilder.Entity("SVSim.Database.Models.DegreeEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("Degrees"); + }); + + modelBuilder.Entity("SVSim.Database.Models.EmblemEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("Emblems"); + }); + + modelBuilder.Entity("SVSim.Database.Models.FeatureMaintenanceEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("Data") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("FeatureKey") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("FeatureMaintenances"); + }); + + modelBuilder.Entity("SVSim.Database.Models.GameConfigSection", b => + { + b.Property("SectionName") + .HasColumnType("text"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("ValueJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.HasKey("SectionName"); + + b.ToTable("GameConfigs"); + }); + + modelBuilder.Entity("SVSim.Database.Models.HomeDialogEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("BeginTime") + .HasColumnType("timestamp with time zone"); + + b.Property("ButtonListJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("EndTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Image") + .IsRequired() + .HasColumnType("text"); + + b.Property("Priority") + .HasColumnType("integer"); + + b.Property("TitleTextId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("HomeDialogEntries"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ItemEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ThumbnailPath") + .IsRequired() + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Items"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ItemPurchaseCatalogEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("IsEnabled") + .HasColumnType("boolean"); + + b.Property("IsMonthlyReset") + .HasColumnType("boolean"); + + b.Property("PurchaseItemId") + .HasColumnType("bigint"); + + b.Property("PurchaseItemNum") + .HasColumnType("integer"); + + b.Property("PurchaseItemType") + .HasColumnType("integer"); + + b.Property("PurchaseLimit") + .HasColumnType("integer"); + + b.Property("PurchaseName") + .IsRequired() + .HasColumnType("text"); + + b.Property("RequireItemId") + .HasColumnType("bigint"); + + b.Property("RequireItemNum") + .HasColumnType("integer"); + + b.Property("RequireItemType") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("ItemPurchaseCatalog"); + }); + + modelBuilder.Entity("SVSim.Database.Models.LeaderSkinEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("ClassId") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("EmoteId") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ClassId"); + + b.ToTable("LeaderSkins"); + }); + + modelBuilder.Entity("SVSim.Database.Models.LeaderSkinShopProductEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("CvNameKey") + .IsRequired() + .HasColumnType("text"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("IntroductionKey") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsEnabled") + .HasColumnType("boolean"); + + b.Property("LeaderSkinId") + .HasColumnType("integer"); + + b.Property("ProductNameKey") + .IsRequired() + .HasColumnType("text"); + + b.Property("SeriesId") + .HasColumnType("integer"); + + b.Property("SinglePriceCrystal") + .HasColumnType("integer"); + + b.Property("SinglePriceRupy") + .HasColumnType("integer"); + + b.Property("SinglePriceTicket") + .HasColumnType("integer"); + + b.Property("TicketItemId") + .HasColumnType("bigint"); + + b.Property("TicketNumber") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("SeriesId"); + + b.ToTable("LeaderSkinShopProducts"); + }); + + modelBuilder.Entity("SVSim.Database.Models.LeaderSkinShopSeriesEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("IsEnabled") + .HasColumnType("boolean"); + + b.Property("IsNew") + .HasColumnType("boolean"); + + b.Property("SetCompletionRewardStatus") + .HasColumnType("integer"); + + b.Property("SetPriceCrystal") + .HasColumnType("integer"); + + b.Property("SetPriceRupy") + .HasColumnType("integer"); + + b.Property("SetPriceTicket") + .HasColumnType("integer"); + + b.Property("SetPriceTicketId") + .HasColumnType("bigint"); + + b.Property("SetSalesStatus") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("LeaderSkinShopSeries"); + }); + + modelBuilder.Entity("SVSim.Database.Models.LoadingExclusionCardEntry", b => + { + b.Property("Id") + .HasColumnType("bigint"); + + b.Property("CardId") + .HasColumnType("bigint"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("LoadingExclusionCards"); + }); + + modelBuilder.Entity("SVSim.Database.Models.MaintenanceCardEntry", b => + { + b.Property("Id") + .HasColumnType("bigint"); + + b.Property("CardId") + .HasColumnType("bigint"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("MaintenanceCards"); + }); + + modelBuilder.Entity("SVSim.Database.Models.MasterPointRankingPeriodEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("BeginTime") + .HasColumnType("timestamp with time zone"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("EndTime") + .HasColumnType("timestamp with time zone"); + + b.Property("NecessaryScore") + .HasColumnType("bigint"); + + b.Property("PeriodNum") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("MasterPointRankingPeriods"); + }); + + modelBuilder.Entity("SVSim.Database.Models.MissionCatalogEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("BattlePassPoint") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("DefaultFlag") + .HasColumnType("boolean"); + + b.Property("EndTime") + .HasColumnType("bigint"); + + b.Property("EventArg") + .HasColumnType("integer"); + + b.Property("EventType") + .HasColumnType("text"); + + b.Property("LotType") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RequireNumber") + .HasColumnType("integer"); + + b.Property("RewardDetailId") + .HasColumnType("bigint"); + + b.Property("RewardNumber") + .HasColumnType("integer"); + + b.Property("RewardType") + .HasColumnType("integer"); + + b.Property("StartTime") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("LotType"); + + b.HasIndex("EventType", "EventArg"); + + b.ToTable("MissionCatalog"); + }); + + modelBuilder.Entity("SVSim.Database.Models.MyPageBackgroundEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("MyPageBackgrounds"); + }); + + modelBuilder.Entity("SVSim.Database.Models.MyRotationAbilityEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("AbilityId") + .HasColumnType("integer"); + + b.Property("Data") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("MyRotationAbilities"); + }); + + modelBuilder.Entity("SVSim.Database.Models.MyRotationSettingEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("AbilitiesCsv") + .IsRequired() + .HasColumnType("text"); + + b.Property("CardSetIdsCsv") + .IsRequired() + .HasColumnType("text"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("ReprintedCardIds") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("RestrictedCardIds") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("RotationId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("MyRotationSettings"); + }); + + modelBuilder.Entity("SVSim.Database.Models.PackConfigEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("BasePackId") + .HasColumnType("integer"); + + b.Property("CommenceDate") + .HasColumnType("timestamp with time zone"); + + b.Property("CompleteDate") + .HasColumnType("timestamp with time zone"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("GachaDetail") + .IsRequired() + .HasColumnType("text"); + + b.Property("GachaType") + .HasColumnType("integer"); + + b.Property("IsEnabled") + .HasColumnType("boolean"); + + b.Property("IsHide") + .HasColumnType("boolean"); + + b.Property("IsNew") + .HasColumnType("boolean"); + + b.Property("IsPreRelease") + .HasColumnType("boolean"); + + b.Property("OpenCountLimit") + .HasColumnType("integer"); + + b.Property("OverrideDrawEffectPackId") + .HasColumnType("integer"); + + b.Property("OverrideUiEffectPackId") + .HasColumnType("integer"); + + b.Property("PackCategory") + .HasColumnType("integer"); + + b.Property("PosterType") + .HasColumnType("integer"); + + b.Property("SalesPeriodTime") + .HasColumnType("timestamp with time zone"); + + b.Property("SleeveId") + .HasColumnType("integer"); + + b.Property("SpecialSleeveId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Packs"); + }); + + modelBuilder.Entity("SVSim.Database.Models.PackDrawCardWeightEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CardId") + .HasColumnType("bigint"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("IsAltArt") + .HasColumnType("boolean"); + + b.Property("IsLeader") + .HasColumnType("boolean"); + + b.Property("PackId") + .HasColumnType("integer"); + + b.Property("RatePct") + .HasColumnType("double precision"); + + b.Property("Slot") + .HasColumnType("integer"); + + b.Property("Tier") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("PackId", "Slot", "Tier"); + + b.ToTable("PackDrawCardWeights"); + }); + + modelBuilder.Entity("SVSim.Database.Models.PackDrawConfigEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("AnimationRatePct") + .HasColumnType("double precision"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("HasBonusSlot") + .HasColumnType("boolean"); + + b.Property("ShortCode") + .HasColumnType("text"); + + b.Property("SpecialKind") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("PackDrawConfigs"); + }); + + modelBuilder.Entity("SVSim.Database.Models.PackDrawSlotRateEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("PackId") + .HasColumnType("integer"); + + b.Property("RatePct") + .HasColumnType("double precision"); + + b.Property("Slot") + .HasColumnType("integer"); + + b.Property("Tier") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("PackId", "Slot", "Tier") + .IsUnique(); + + b.ToTable("PackDrawSlotRates"); + }); + + modelBuilder.Entity("SVSim.Database.Models.PaymentItemEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("ChargeCrystalNum") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("EndTime") + .HasColumnType("timestamp with time zone"); + + b.Property("FreeCrystalNum") + .HasColumnType("integer"); + + b.Property("ImageName") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsResaleProduct") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("numeric"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("PurchaseLimit") + .HasColumnType("integer"); + + b.Property("RemainingTime") + .HasColumnType("integer"); + + b.Property("ResaleStartDate") + .HasColumnType("timestamp with time zone"); + + b.Property("SpecialShopFlag") + .HasColumnType("integer"); + + b.Property("StartTime") + .HasColumnType("timestamp with time zone"); + + b.Property("StoreProductId") + .HasColumnType("bigint"); + + b.Property("Text") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("PaymentItems"); + }); + + modelBuilder.Entity("SVSim.Database.Models.PracticeOpponentEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("AiDeckLevel") + .HasColumnType("integer"); + + b.Property("AiLogicLevel") + .HasColumnType("integer"); + + b.Property("AiMaxLife") + .HasColumnType("integer"); + + b.Property("Battle3dFieldId") + .IsRequired() + .HasColumnType("text"); + + b.Property("CharaId") + .HasColumnType("integer"); + + b.Property("ClassId") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("DegreeId") + .HasColumnType("integer"); + + b.Property("IsCampaignPractice") + .HasColumnType("boolean"); + + b.Property("IsMaintenance") + .HasColumnType("boolean"); + + b.Property("PracticeId") + .HasColumnType("integer"); + + b.Property("TextId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("PracticeOpponents"); + }); + + modelBuilder.Entity("SVSim.Database.Models.PreReleaseInfo", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("CardMasterId") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("DefaultCardMasterId") + .IsRequired() + .HasColumnType("text"); + + b.Property("DisplayEndTime") + .HasColumnType("timestamp with time zone"); + + b.Property("EndTime") + .HasColumnType("timestamp with time zone"); + + b.Property("FreeMatchStartTime") + .HasColumnType("timestamp with time zone"); + + b.Property("IsPreRotationFreeMatchTerm") + .HasColumnType("boolean"); + + b.Property("LatestReprintedBaseCardIds") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("NextCardSetId") + .IsRequired() + .HasColumnType("text"); + + b.Property("PreReleaseCardMasterId") + .IsRequired() + .HasColumnType("text"); + + b.Property("PreReleaseId") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReprintedBaseCardIds") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("RotationCardSetIdList") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("StartTime") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("PreReleaseInfos"); + }); + + modelBuilder.Entity("SVSim.Database.Models.PuzzleEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("GroupId") + .HasColumnType("integer"); + + b.Property("IsAdditional") + .HasColumnType("boolean"); + + b.Property("IsPlayable") + .HasColumnType("boolean"); + + b.Property("PuzzleDifficulty") + .HasColumnType("integer"); + + b.Property("PuzzleId") + .HasColumnType("integer"); + + b.Property("ReleaseConditionTextId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("GroupId"); + + b.ToTable("Puzzles"); + }); + + modelBuilder.Entity("SVSim.Database.Models.PuzzleGroupEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("BasicTitleTextId") + .IsRequired() + .HasColumnType("text"); + + b.Property("CharaId") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("DifficultyNameListJson") + .IsRequired() + .HasColumnType("text"); + + b.Property("PuzzleCharaId") + .HasColumnType("integer"); + + b.Property("PuzzleMasterId") + .HasColumnType("integer"); + + b.Property("SortType") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("PuzzleGroups"); + }); + + modelBuilder.Entity("SVSim.Database.Models.PuzzleMissionEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("AchievedMessage") + .IsRequired() + .HasColumnType("text"); + + b.Property("CampaignCommenceTime") + .HasColumnType("bigint"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("MissionName") + .IsRequired() + .HasColumnType("text"); + + b.Property("OrderId") + .HasColumnType("integer"); + + b.Property("RequireNumber") + .HasColumnType("integer"); + + b.Property("RewardDetailId") + .HasColumnType("bigint"); + + b.Property("RewardNumber") + .HasColumnType("integer"); + + b.Property("RewardType") + .HasColumnType("integer"); + + b.Property("TargetPuzzleGroupId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("PuzzleMissions"); + }); + + modelBuilder.Entity("SVSim.Database.Models.RankInfoEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("AccumulateMasterPoint") + .HasColumnType("integer"); + + b.Property("AccumulatePoint") + .HasColumnType("integer"); + + b.Property("BaseAddBp") + .HasColumnType("integer"); + + b.Property("BaseDropBp") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("IsPromotionWar") + .HasColumnType("integer"); + + b.Property("LoseBonus") + .HasColumnType("double precision"); + + b.Property("LowerLimitPoint") + .HasColumnType("integer"); + + b.Property("MatchCount") + .HasColumnType("integer"); + + b.Property("MaxLoseBonus") + .HasColumnType("integer"); + + b.Property("MaxWinBonus") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NecessaryPoint") + .HasColumnType("integer"); + + b.Property("NecessaryWin") + .HasColumnType("integer"); + + b.Property("ResetLose") + .HasColumnType("integer"); + + b.Property("StreakBonusPt") + .HasColumnType("integer"); + + b.Property("WinBonus") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.ToTable("RankInfo"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ReprintedCardEntry", b => + { + b.Property("Id") + .HasColumnType("bigint"); + + b.Property("CardId") + .HasColumnType("bigint"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("ReprintedCards"); + }); + + modelBuilder.Entity("SVSim.Database.Models.SealedConfig", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("CrystalCost") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("DeckUsingNumMin") + .HasColumnType("integer"); + + b.Property("Enable") + .HasColumnType("integer"); + + b.Property("IsDeckCodeMaintenance") + .HasColumnType("boolean"); + + b.Property("IsJoin") + .HasColumnType("boolean"); + + b.Property("PackInfo") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("RupyCost") + .HasColumnType("integer"); + + b.Property("SalesPeriodInfo") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("ScheduleId") + .HasColumnType("integer"); + + b.Property("TicketCost") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("SealedSeasons"); + }); + + modelBuilder.Entity("SVSim.Database.Models.SerialCodeEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("EndAt") + .HasColumnType("timestamp with time zone"); + + b.Property("IsEnabled") + .HasColumnType("boolean"); + + b.Property("Message") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("StartAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("SerialCodes"); + }); + + modelBuilder.Entity("SVSim.Database.Models.SerialCodeRewardEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("RewardCount") + .HasColumnType("integer"); + + b.Property("RewardDetailId") + .HasColumnType("bigint"); + + b.Property("RewardType") + .HasColumnType("integer"); + + b.Property("SerialCodeId") + .HasColumnType("integer"); + + b.Property("Slot") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("SerialCodeId", "Slot"); + + b.ToTable("SerialCodeRewards"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ShadowverseCardEntry", b => + { + b.Property("Id") + .HasColumnType("bigint"); + + b.Property("Attack") + .HasColumnType("integer"); + + b.Property("ClassId") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("Defense") + .HasColumnType("integer"); + + b.Property("IsFoil") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("PrimaryResourceCost") + .HasColumnType("integer"); + + b.Property("Rarity") + .HasColumnType("integer"); + + b.Property("ShadowverseCardSetEntryId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ClassId"); + + b.HasIndex("ShadowverseCardSetEntryId"); + + b.ToTable("Cards"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ShadowverseCardSetEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("IsBasic") + .HasColumnType("boolean"); + + b.Property("IsInRotation") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("CardSets"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ShadowverseDeckEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ClassId") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("Format") + .HasColumnType("integer"); + + b.Property("LeaderSkinId") + .HasColumnType("integer"); + + b.Property("MyRotationId") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Number") + .HasColumnType("integer"); + + b.Property("RandomLeaderSkin") + .HasColumnType("boolean"); + + b.Property("SleeveId") + .HasColumnType("integer"); + + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ClassId"); + + b.HasIndex("LeaderSkinId"); + + b.HasIndex("SleeveId"); + + b.HasIndex("ViewerId"); + + b.ToTable("Decks"); + }); + + modelBuilder.Entity("SVSim.Database.Models.SleeveEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("Sleeves"); + }); + + modelBuilder.Entity("SVSim.Database.Models.SleeveShopProductEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("IsEnabled") + .HasColumnType("boolean"); + + b.Property("NameKey") + .IsRequired() + .HasColumnType("text"); + + b.Property("PriceCrystal") + .HasColumnType("integer"); + + b.Property("PriceRupy") + .HasColumnType("integer"); + + b.Property("SeriesId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("SeriesId"); + + b.ToTable("SleeveShopProducts"); + }); + + modelBuilder.Entity("SVSim.Database.Models.SleeveShopSeriesEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("IsEnabled") + .HasColumnType("boolean"); + + b.Property("IsNew") + .HasColumnType("boolean"); + + b.HasKey("Id"); + + b.ToTable("SleeveShopSeries"); + }); + + modelBuilder.Entity("SVSim.Database.Models.SpecialDeckFormatEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("DeckFormat") + .IsRequired() + .HasColumnType("text"); + + b.Property("EndTime") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("SpecialDeckFormats"); + }); + + modelBuilder.Entity("SVSim.Database.Models.SpotCardEntry", b => + { + b.Property("Id") + .HasColumnType("bigint"); + + b.Property("CardId") + .HasColumnType("bigint"); + + b.Property("Cost") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("SpotCards"); + }); + + modelBuilder.Entity("SVSim.Database.Models.SpotCardExchangeEntry", b => + { + b.Property("Id") + .HasColumnType("bigint"); + + b.Property("CardId") + .HasColumnType("bigint"); + + b.Property("ClassId") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("ExchangePoint") + .HasColumnType("integer"); + + b.Property("IsEnabled") + .HasColumnType("boolean"); + + b.Property("IsPreRelease") + .HasColumnType("boolean"); + + b.Property("TsRotationId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.ToTable("SpotCardExchangeCatalog"); + }); + + modelBuilder.Entity("SVSim.Database.Models.StoryDeckEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("ClassId") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("DeckFormat") + .HasColumnType("integer"); + + b.Property("DeckName") + .IsRequired() + .HasColumnType("text"); + + b.Property("DeckNo") + .HasColumnType("integer"); + + b.Property("EntryNo") + .HasColumnType("integer"); + + b.Property("IsRecommend") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("integer"); + + b.Property("LeaderSkinId") + .HasColumnType("integer"); + + b.Property("OrderNum") + .HasColumnType("integer"); + + b.Property("SleeveId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("StoryDecks"); + }); + + modelBuilder.Entity("SVSim.Database.Models.TutorialPresentEntry", b => + { + b.Property("PresentId") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ItemType") + .HasColumnType("integer"); + + b.Property("Message") + .IsRequired() + .HasColumnType("text"); + + b.Property("RewardCount") + .HasColumnType("bigint"); + + b.Property("RewardDetailId") + .HasColumnType("bigint"); + + b.Property("RewardType") + .HasColumnType("integer"); + + b.HasKey("PresentId"); + + b.ToTable("TutorialPresentEntries"); + }); + + modelBuilder.Entity("SVSim.Database.Models.UnlimitedRestrictionEntry", b => + { + b.Property("Id") + .HasColumnType("bigint"); + + b.Property("CardId") + .HasColumnType("bigint"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("RestrictionValue") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("UnlimitedRestrictions"); + }); + + modelBuilder.Entity("SVSim.Database.Models.Viewer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnType("text"); + + b.Property("LastLogin") + .HasColumnType("timestamp with time zone"); + + b.Property("MyPageBgId") + .HasColumnType("integer"); + + b.Property("MyPageBgSelectType") + .HasColumnType("integer"); + + b.Property("ShortUdid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasDefaultValueSql("nextval('\"ShortUdidSequence\"')"); + + NpgsqlPropertyBuilderExtensions.UseSequence(b.Property("ShortUdid"), "ShortUdidSequence"); + + b.Property("Udid") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ShortUdid"); + + b.HasIndex("Udid") + .IsUnique(); + + b.ToTable("Viewers"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerAchievement", b => + { + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.Property("AchievementType") + .HasColumnType("integer"); + + b.Property("AchievementStatus") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("NowAchievedLevel") + .HasColumnType("integer"); + + b.Property("ResultAnnounceSawLevel") + .HasColumnType("integer"); + + b.HasKey("ViewerId", "AchievementType"); + + b.ToTable("ViewerAchievements"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerAcquireHistoryEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AcquireTime") + .HasColumnType("timestamp with time zone"); + + b.Property("AcquireType") + .HasColumnType("integer"); + + b.Property("Message") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("RewardCount") + .HasColumnType("integer"); + + b.Property("RewardDetailId") + .HasColumnType("bigint"); + + b.Property("RewardType") + .HasColumnType("integer"); + + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ViewerId", "AcquireTime", "Id"); + + b.ToTable("ViewerAcquireHistory"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerArenaColosseumRun", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BattleCountThisRound") + .HasColumnType("integer"); + + b.Property("BreakthroughNumberThisRound") + .HasColumnType("integer"); + + b.Property("CandidateClassIdsJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("ChaosId") + .HasColumnType("integer"); + + b.Property("ClassId") + .HasColumnType("integer"); + + b.Property("ConsumeItemType") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeckFormat") + .HasColumnType("integer"); + + b.Property("EntryId") + .HasColumnType("bigint"); + + b.Property("IsChampion") + .HasColumnType("boolean"); + + b.Property("IsPublished") + .HasColumnType("boolean"); + + b.Property("IsRankMatching") + .HasColumnType("boolean"); + + b.Property("IsSelectCompleted") + .HasColumnType("boolean"); + + b.Property("LeaderSkinId") + .HasColumnType("bigint"); + + b.Property("LossCount") + .HasColumnType("integer"); + + b.Property("MaxBattleCountThisRound") + .HasColumnType("integer"); + + b.Property("NextCandidateId") + .HasColumnType("bigint"); + + b.Property("PendingPickSetsJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("RegisteredDeckNoListJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("RestEntryNum") + .HasColumnType("integer"); + + b.Property("ResultListJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("RoundId") + .HasColumnType("integer"); + + b.Property("SeasonId") + .HasColumnType("integer"); + + b.Property("SelectTurn") + .HasColumnType("integer"); + + b.Property("SelectedCardIdsJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.Property("WinCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ViewerId") + .IsUnique(); + + b.ToTable("ViewerArenaColosseumRuns"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerArenaTwoPickRun", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CandidateClassIdsJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("ChallengeId") + .HasColumnType("integer"); + + b.Property("ClassId") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("EntryId") + .HasColumnType("bigint"); + + b.Property("IsRetire") + .HasColumnType("boolean"); + + b.Property("IsSelectCompleted") + .HasColumnType("boolean"); + + b.Property("LeaderSkinId") + .HasColumnType("bigint"); + + b.Property("LossCount") + .HasColumnType("integer"); + + b.Property("MaxBattleCount") + .HasColumnType("integer"); + + b.Property("NextCandidateId") + .HasColumnType("bigint"); + + b.Property("PendingPickSetsJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("ResultListJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("RewardScheduleId") + .HasColumnType("integer"); + + b.Property("SelectTurn") + .HasColumnType("integer"); + + b.Property("SelectedCardIdsJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.Property("WinCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ViewerId") + .IsUnique(); + + b.ToTable("ViewerArenaTwoPickRuns"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerBattleHistory", b => + { + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.Property("BattleId") + .HasColumnType("bigint"); + + b.Property("BattleStartTime") + .HasColumnType("timestamp with time zone"); + + b.Property("BattleType") + .HasColumnType("integer"); + + b.Property("CreateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("DeckFormat") + .HasColumnType("integer"); + + b.Property("IsLimitTurn") + .HasColumnType("integer"); + + b.Property("IsWin") + .HasColumnType("boolean"); + + b.Property("OpponentCharaId") + .HasColumnType("integer"); + + b.Property("OpponentClassId") + .HasColumnType("integer"); + + b.Property("OpponentCountryCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("OpponentDegreeId") + .HasColumnType("bigint"); + + b.Property("OpponentEmblemId") + .HasColumnType("bigint"); + + b.Property("OpponentName") + .IsRequired() + .HasColumnType("text"); + + b.Property("OpponentRotationId") + .IsRequired() + .HasColumnType("text"); + + b.Property("OpponentSubClassId") + .HasColumnType("integer"); + + b.Property("SelfCharaId") + .HasColumnType("integer"); + + b.Property("SelfClassId") + .HasColumnType("integer"); + + b.Property("SelfRotationId") + .IsRequired() + .HasColumnType("text"); + + b.Property("SelfSubClassId") + .HasColumnType("integer"); + + b.Property("TwoPickType") + .HasColumnType("integer"); + + b.HasKey("ViewerId", "BattleId"); + + b.HasIndex("ViewerId", "CreateTime") + .HasDatabaseName("IX_ViewerBattleHistories_ViewerId_CreateTime"); + + b.ToTable("ViewerBattleHistories"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerBattlePassClaimEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("SeasonId") + .HasColumnType("integer"); + + b.Property("Track") + .HasColumnType("integer"); + + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ViewerId", "SeasonId"); + + b.HasIndex("ViewerId", "SeasonId", "Track", "Level") + .IsUnique(); + + b.ToTable("ViewerBattlePassClaims"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerBattlePassProgressEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CurrentPoint") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("IsPremium") + .HasColumnType("boolean"); + + b.Property("SeasonId") + .HasColumnType("integer"); + + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.Property("WeeklyPeriodStart") + .HasColumnType("timestamp with time zone"); + + b.Property("WeeklyPoints") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ViewerId", "SeasonId") + .IsUnique(); + + b.ToTable("ViewerBattlePassProgress"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerEventCounter", b => + { + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.Property("EventKey") + .HasColumnType("text"); + + b.Property("Period") + .HasColumnType("text"); + + b.Property("Count") + .HasColumnType("integer"); + + b.HasKey("ViewerId", "EventKey", "Period"); + + b.HasIndex("ViewerId", "Period"); + + b.ToTable("ViewerEventCounters"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerFriend", b => + { + b.Property("OwnerViewerId") + .HasColumnType("bigint"); + + b.Property("FriendViewerId") + .HasColumnType("bigint"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("OwnerViewerId", "FriendViewerId"); + + b.HasIndex("FriendViewerId"); + + b.HasIndex("OwnerViewerId", "CreatedAt"); + + b.ToTable("ViewerFriends"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerFriendApply", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("FromViewerId") + .HasColumnType("bigint"); + + b.Property("MissionType") + .HasColumnType("integer"); + + b.Property("ToViewerId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ToViewerId"); + + b.HasIndex("FromViewerId", "ToViewerId") + .IsUnique(); + + b.ToTable("ViewerFriendApplies"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerLeaderSkinSetClaim", b => + { + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.Property("SeriesId") + .HasColumnType("integer"); + + b.Property("ClaimedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("ViewerId", "SeriesId"); + + b.HasIndex("ViewerId"); + + b.ToTable("ViewerLeaderSkinSetClaims"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerMission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssignedAt") + .HasColumnType("bigint"); + + b.Property("ClaimedAt") + .HasColumnType("bigint"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("MissionCatalogId") + .HasColumnType("integer"); + + b.Property("MissionStatus") + .HasColumnType("integer"); + + b.Property("Slot") + .HasColumnType("integer"); + + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ViewerId"); + + b.HasIndex("ViewerId", "Slot") + .IsUnique(); + + b.ToTable("ViewerMissions"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerPlayedTogether", b => + { + b.Property("OwnerViewerId") + .HasColumnType("bigint"); + + b.Property("OpponentViewerId") + .HasColumnType("bigint"); + + b.Property("BattleType") + .HasColumnType("integer"); + + b.Property("DeckFormat") + .HasColumnType("integer"); + + b.Property("PlayedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("PlayedMode") + .HasColumnType("integer"); + + b.Property("TwoPickType") + .HasColumnType("integer"); + + b.HasKey("OwnerViewerId", "OpponentViewerId"); + + b.HasIndex("OwnerViewerId", "PlayedAt"); + + b.ToTable("ViewerPlayedTogethers"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerPresent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ConditionNumber") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ItemType") + .HasColumnType("integer"); + + b.Property("Message") + .IsRequired() + .HasColumnType("text"); + + b.Property("PresentId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("PresentLimitType") + .HasColumnType("integer"); + + b.Property("RewardCount") + .HasColumnType("bigint"); + + b.Property("RewardDetailId") + .HasColumnType("bigint"); + + b.Property("RewardLimitTime") + .HasColumnType("bigint"); + + b.Property("RewardType") + .HasColumnType("integer"); + + b.Property("Source") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ViewerId", "PresentId") + .IsUnique(); + + b.HasIndex("ViewerId", "Status", "CreatedAt"); + + b.ToTable("ViewerPresents"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerPuzzleClear", b => + { + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.Property("PuzzleId") + .HasColumnType("integer"); + + b.Property("BestRetryCount") + .HasColumnType("integer"); + + b.Property("ClearedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("ViewerId", "PuzzleId"); + + b.ToTable("ViewerPuzzleClears"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerSerialCodeRedemption", b => + { + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.Property("SerialCodeId") + .HasColumnType("integer"); + + b.Property("RedeemedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("ViewerId", "SerialCodeId"); + + b.HasIndex("SerialCodeId"); + + b.ToTable("ViewerSerialCodeRedemptions"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerSpotCardExchange", b => + { + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.Property("CardId") + .HasColumnType("bigint"); + + b.Property("ExchangedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("IsPreRelease") + .HasColumnType("boolean"); + + b.HasKey("ViewerId", "CardId"); + + b.HasIndex("ViewerId"); + + b.ToTable("ViewerSpotCardExchanges"); + }); + + modelBuilder.Entity("SleeveEntryViewer", b => + { + b.Property("SleevesId") + .HasColumnType("integer"); + + b.Property("ViewersId") + .HasColumnType("bigint"); + + b.HasKey("SleevesId", "ViewersId"); + + b.HasIndex("ViewersId"); + + b.ToTable("SleeveEntryViewer"); + }); + + modelBuilder.Entity("DegreeEntryViewer", b => + { + b.HasOne("SVSim.Database.Models.DegreeEntry", null) + .WithMany() + .HasForeignKey("DegreesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany() + .HasForeignKey("ViewersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("EmblemEntryViewer", b => + { + b.HasOne("SVSim.Database.Models.EmblemEntry", null) + .WithMany() + .HasForeignKey("EmblemsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany() + .HasForeignKey("ViewersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LeaderSkinEntryViewer", b => + { + b.HasOne("SVSim.Database.Models.LeaderSkinEntry", null) + .WithMany() + .HasForeignKey("LeaderSkinsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany() + .HasForeignKey("ViewersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MyPageBackgroundEntryViewer", b => + { + b.HasOne("SVSim.Database.Models.MyPageBackgroundEntry", null) + .WithMany() + .HasForeignKey("MyPageBackgroundsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany() + .HasForeignKey("ViewersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("SVSim.Database.Entities.Story.StoryChapter", b => + { + b.HasOne("SVSim.Database.Entities.Story.StorySection", "Section") + .WithMany() + .HasForeignKey("SectionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SVSim.Database.Entities.Story.SpecialBattleSetting", "SpecialBattleSetting") + .WithMany() + .HasForeignKey("SpecialBattleSettingId"); + + b.OwnsMany("SVSim.Database.Entities.Story.StoryChapterBattleSetting", "BattleSettings", b1 => + { + b1.Property("StoryId") + .HasColumnType("integer"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("Battle3dFieldIdOverride") + .HasColumnType("integer"); + + b1.Property("BgmIdOverride") + .HasColumnType("integer"); + + b1.Property("DeckClassId") + .HasColumnType("integer"); + + b1.Property("DeckSkinIdOverride") + .HasColumnType("integer"); + + b1.Property("EnemyEmotionOverride") + .HasColumnType("integer"); + + b1.Property("PlayerEmotionOverride") + .HasColumnType("integer"); + + b1.Property("SkinIdOverride") + .HasColumnType("integer"); + + b1.HasKey("StoryId", "Id"); + + b1.ToTable("StoryChapterBattleSetting"); + + b1.WithOwner() + .HasForeignKey("StoryId"); + }); + + b.OwnsMany("SVSim.Database.Entities.Story.StoryChapterReward", "Rewards", b1 => + { + b1.Property("StoryId") + .HasColumnType("integer"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("RewardDetailId") + .HasColumnType("bigint"); + + b1.Property("RewardNumber") + .HasColumnType("integer"); + + b1.Property("RewardType") + .HasColumnType("integer"); + + b1.HasKey("StoryId", "Id"); + + b1.ToTable("StoryChapterReward"); + + b1.WithOwner() + .HasForeignKey("StoryId"); + }); + + b.OwnsMany("SVSim.Database.Entities.Story.StorySubChapter", "SubChapters", b1 => + { + b1.Property("StoryId") + .HasColumnType("integer"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("IsMaintenanceChapter") + .HasColumnType("boolean"); + + b1.Property("SubChapterId") + .HasColumnType("integer"); + + b1.Property("SubChapterStoryId") + .HasColumnType("integer"); + + b1.HasKey("StoryId", "Id"); + + b1.ToTable("StorySubChapter"); + + b1.WithOwner() + .HasForeignKey("StoryId"); + }); + + b.Navigation("BattleSettings"); + + b.Navigation("Rewards"); + + b.Navigation("Section"); + + b.Navigation("SpecialBattleSetting"); + + b.Navigation("SubChapters"); + }); + + modelBuilder.Entity("SVSim.Database.Entities.Story.StorySection", b => + { + b.HasOne("SVSim.Database.Entities.Story.StoryWorld", "World") + .WithMany() + .HasForeignKey("WorldId"); + + b.Navigation("World"); + }); + + modelBuilder.Entity("SVSim.Database.Models.BattlePassRewardEntry", b => + { + b.HasOne("SVSim.Database.Models.BattlePassSeasonEntry", "Season") + .WithMany("Rewards") + .HasForeignKey("SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("SVSim.Database.Models.BuildDeckProductEntry", b => + { + b.HasOne("SVSim.Database.Models.BuildDeckSeriesEntry", "Series") + .WithMany("Products") + .HasForeignKey("SeriesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("SVSim.Database.Models.BuildDeckProductCardEntry", "Cards", b1 => + { + b1.Property("BuildDeckProductEntryId") + .HasColumnType("integer"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("CardId") + .HasColumnType("bigint"); + + b1.Property("IsSpot") + .HasColumnType("boolean"); + + b1.Property("Number") + .HasColumnType("integer"); + + b1.HasKey("BuildDeckProductEntryId", "Id"); + + b1.ToTable("BuildDeckProductCardEntry"); + + b1.WithOwner() + .HasForeignKey("BuildDeckProductEntryId"); + }); + + b.OwnsMany("SVSim.Database.Models.BuildDeckProductRewardEntry", "Rewards", b1 => + { + b1.Property("BuildDeckProductEntryId") + .HasColumnType("integer"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("MessageId") + .HasColumnType("integer"); + + b1.Property("RewardDetailId") + .HasColumnType("bigint"); + + b1.Property("RewardIndex") + .HasColumnType("integer"); + + b1.Property("RewardNumber") + .HasColumnType("integer"); + + b1.Property("RewardType") + .HasColumnType("integer"); + + b1.HasKey("BuildDeckProductEntryId", "Id"); + + b1.ToTable("BuildDeckProductRewardEntry"); + + b1.WithOwner() + .HasForeignKey("BuildDeckProductEntryId"); + }); + + b.Navigation("Cards"); + + b.Navigation("Rewards"); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("SVSim.Database.Models.BuildDeckSeriesEntry", b => + { + b.OwnsMany("SVSim.Database.Models.BuildDeckSeriesRewardEntry", "SeriesRewards", b1 => + { + b1.Property("BuildDeckSeriesEntryId") + .HasColumnType("integer"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("ItemIndex") + .HasColumnType("integer"); + + b1.Property("MessageId") + .HasColumnType("integer"); + + b1.Property("RewardDetailId") + .HasColumnType("bigint"); + + b1.Property("RewardNumber") + .HasColumnType("integer"); + + b1.Property("RewardType") + .HasColumnType("integer"); + + b1.Property("TierIndex") + .HasColumnType("integer"); + + b1.HasKey("BuildDeckSeriesEntryId", "Id"); + + b1.ToTable("BuildDeckSeriesRewardEntry"); + + b1.WithOwner() + .HasForeignKey("BuildDeckSeriesEntryId"); + }); + + b.Navigation("SeriesRewards"); + }); + + modelBuilder.Entity("SVSim.Database.Models.CardCosmeticReward", b => + { + b.HasOne("SVSim.Database.Models.ShadowverseCardEntry", "Card") + .WithMany() + .HasForeignKey("CardId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Card"); + }); + + modelBuilder.Entity("SVSim.Database.Models.LeaderSkinEntry", b => + { + b.HasOne("SVSim.Database.Models.ClassEntry", "Class") + .WithMany("LeaderSkins") + .HasForeignKey("ClassId"); + + b.Navigation("Class"); + }); + + modelBuilder.Entity("SVSim.Database.Models.LeaderSkinShopProductEntry", b => + { + b.HasOne("SVSim.Database.Models.LeaderSkinShopSeriesEntry", "Series") + .WithMany("Products") + .HasForeignKey("SeriesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("SVSim.Database.Models.LeaderSkinShopProductRewardEntry", "Rewards", b1 => + { + b1.Property("LeaderSkinShopProductEntryId") + .HasColumnType("integer"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("OrderIndex") + .HasColumnType("integer"); + + b1.Property("RewardDetailId") + .HasColumnType("bigint"); + + b1.Property("RewardNumber") + .HasColumnType("integer"); + + b1.Property("RewardType") + .HasColumnType("integer"); + + b1.HasKey("LeaderSkinShopProductEntryId", "Id"); + + b1.ToTable("LeaderSkinShopProductRewardEntry"); + + b1.WithOwner() + .HasForeignKey("LeaderSkinShopProductEntryId"); + }); + + b.Navigation("Rewards"); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("SVSim.Database.Models.LeaderSkinShopSeriesEntry", b => + { + b.OwnsMany("SVSim.Database.Models.LeaderSkinShopSeriesRewardEntry", "SetCompletionRewards", b1 => + { + b1.Property("LeaderSkinShopSeriesEntryId") + .HasColumnType("integer"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("OrderIndex") + .HasColumnType("integer"); + + b1.Property("RewardDetailId") + .HasColumnType("bigint"); + + b1.Property("RewardNumber") + .HasColumnType("integer"); + + b1.Property("RewardType") + .HasColumnType("integer"); + + b1.HasKey("LeaderSkinShopSeriesEntryId", "Id"); + + b1.ToTable("LeaderSkinShopSeriesRewardEntry"); + + b1.WithOwner() + .HasForeignKey("LeaderSkinShopSeriesEntryId"); + }); + + b.Navigation("SetCompletionRewards"); + }); + + modelBuilder.Entity("SVSim.Database.Models.PackConfigEntry", b => + { + b.OwnsMany("SVSim.Database.Models.PackBannerEntry", "Banners", b1 => + { + b1.Property("PackConfigEntryId") + .HasColumnType("integer"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("BannerName") + .IsRequired() + .HasColumnType("text"); + + b1.Property("DialogTitle") + .IsRequired() + .HasColumnType("text"); + + b1.HasKey("PackConfigEntryId", "Id"); + + b1.ToTable("PackBannerEntry"); + + b1.WithOwner() + .HasForeignKey("PackConfigEntryId"); + }); + + b.OwnsMany("SVSim.Database.Models.PackChildGachaEntry", "ChildGachas", b1 => + { + b1.Property("PackConfigEntryId") + .HasColumnType("integer"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("CampaignName") + .HasColumnType("text"); + + b1.Property("CardCount") + .HasColumnType("integer"); + + b1.Property("Cost") + .HasColumnType("integer"); + + b1.Property("DailyFreeGachaCount") + .HasColumnType("integer"); + + b1.Property("FreeGachaCampaignId") + .HasColumnType("integer"); + + b1.Property("GachaId") + .HasColumnType("integer"); + + b1.Property("IsDailySingle") + .HasColumnType("boolean"); + + b1.Property("ItemId") + .HasColumnType("bigint"); + + b1.Property("OverrideIncreaseGachaPoint") + .HasColumnType("integer"); + + b1.Property("PurchaseLimitCount") + .HasColumnType("integer"); + + b1.Property("TypeDetail") + .HasColumnType("integer"); + + b1.HasKey("PackConfigEntryId", "Id"); + + b1.ToTable("PackChildGachaEntry"); + + b1.WithOwner() + .HasForeignKey("PackConfigEntryId"); + }); + + b.OwnsOne("SVSim.Database.Models.PackGachaPointConfig", "GachaPointConfig", b1 => + { + b1.Property("PackConfigEntryId") + .HasColumnType("integer"); + + b1.Property("ExchangeablePoint") + .HasColumnType("integer"); + + b1.Property("IncreaseGachaPoint") + .HasColumnType("integer"); + + b1.HasKey("PackConfigEntryId"); + + b1.ToTable("Packs"); + + b1.WithOwner() + .HasForeignKey("PackConfigEntryId"); + }); + + b.Navigation("Banners"); + + b.Navigation("ChildGachas"); + + b.Navigation("GachaPointConfig"); + }); + + modelBuilder.Entity("SVSim.Database.Models.PuzzleEntry", b => + { + b.HasOne("SVSim.Database.Models.PuzzleGroupEntry", "Group") + .WithMany("Puzzles") + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("SVSim.Database.Models.SerialCodeRewardEntry", b => + { + b.HasOne("SVSim.Database.Models.SerialCodeEntry", null) + .WithMany("Rewards") + .HasForeignKey("SerialCodeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("SVSim.Database.Models.ShadowverseCardEntry", b => + { + b.HasOne("SVSim.Database.Models.ClassEntry", "Class") + .WithMany() + .HasForeignKey("ClassId"); + + b.HasOne("SVSim.Database.Models.ShadowverseCardSetEntry", null) + .WithMany("Cards") + .HasForeignKey("ShadowverseCardSetEntryId"); + + b.OwnsOne("SVSim.Database.Models.CardCollectionInfo", "CollectionInfo", b1 => + { + b1.Property("ShadowverseCardEntryId") + .HasColumnType("bigint"); + + b1.Property("CraftCost") + .HasColumnType("integer"); + + b1.Property("DustReward") + .HasColumnType("integer"); + + b1.HasKey("ShadowverseCardEntryId"); + + b1.ToTable("Cards"); + + b1.WithOwner() + .HasForeignKey("ShadowverseCardEntryId"); + }); + + b.Navigation("Class"); + + b.Navigation("CollectionInfo"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ShadowverseDeckEntry", b => + { + b.HasOne("SVSim.Database.Models.ClassEntry", "Class") + .WithMany() + .HasForeignKey("ClassId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SVSim.Database.Models.LeaderSkinEntry", "LeaderSkin") + .WithMany() + .HasForeignKey("LeaderSkinId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SVSim.Database.Models.SleeveEntry", "Sleeve") + .WithMany() + .HasForeignKey("SleeveId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany("Decks") + .HasForeignKey("ViewerId"); + + b.OwnsMany("SVSim.Database.Models.DeckCard", "Cards", b1 => + { + b1.Property("ShadowverseDeckEntryId") + .HasColumnType("uuid"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("CardId") + .HasColumnType("bigint"); + + b1.Property("Count") + .HasColumnType("integer"); + + b1.HasKey("ShadowverseDeckEntryId", "Id"); + + b1.HasIndex("CardId"); + + b1.ToTable("DeckCard"); + + b1.HasOne("SVSim.Database.Models.ShadowverseCardEntry", "Card") + .WithMany() + .HasForeignKey("CardId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.WithOwner() + .HasForeignKey("ShadowverseDeckEntryId"); + + b1.Navigation("Card"); + }); + + b.Navigation("Cards"); + + b.Navigation("Class"); + + b.Navigation("LeaderSkin"); + + b.Navigation("Sleeve"); + }); + + modelBuilder.Entity("SVSim.Database.Models.SleeveShopProductEntry", b => + { + b.HasOne("SVSim.Database.Models.SleeveShopSeriesEntry", "Series") + .WithMany("Products") + .HasForeignKey("SeriesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("SVSim.Database.Models.SleeveShopProductRewardEntry", "Rewards", b1 => + { + b1.Property("SleeveShopProductEntryId") + .HasColumnType("integer"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("OrderIndex") + .HasColumnType("integer"); + + b1.Property("RewardDetailId") + .HasColumnType("bigint"); + + b1.Property("RewardNumber") + .HasColumnType("integer"); + + b1.Property("RewardType") + .HasColumnType("integer"); + + b1.HasKey("SleeveShopProductEntryId", "Id"); + + b1.ToTable("SleeveShopProductRewardEntry"); + + b1.WithOwner() + .HasForeignKey("SleeveShopProductEntryId"); + }); + + b.Navigation("Rewards"); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("SVSim.Database.Models.Viewer", b => + { + b.OwnsMany("SVSim.Database.Models.MyPageBgRotationEntry", "MyPageBgRotation", b1 => + { + b1.Property("ViewerId") + .HasColumnType("bigint"); + + b1.Property("Slot") + .HasColumnType("integer"); + + b1.Property("BgId") + .HasColumnType("integer"); + + b1.HasKey("ViewerId", "Slot"); + + b1.ToTable("ViewerMyPageBgRotation", (string)null); + + b1.WithOwner() + .HasForeignKey("ViewerId"); + }); + + b.OwnsMany("SVSim.Database.Models.OwnedCardEntry", "Cards", b1 => + { + b1.Property("ViewerId") + .HasColumnType("bigint"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("CardId") + .HasColumnType("bigint"); + + b1.Property("Count") + .HasColumnType("integer"); + + b1.Property("IsProtected") + .HasColumnType("boolean"); + + b1.HasKey("ViewerId", "Id"); + + b1.HasIndex("CardId"); + + b1.HasIndex("ViewerId", "CardId") + .IsUnique(); + + b1.ToTable("OwnedCardEntry"); + + b1.HasOne("SVSim.Database.Models.ShadowverseCardEntry", "Card") + .WithMany() + .HasForeignKey("CardId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.WithOwner() + .HasForeignKey("ViewerId"); + + b1.Navigation("Card"); + }); + + b.OwnsMany("SVSim.Database.Models.OwnedItemEntry", "Items", b1 => + { + b1.Property("ViewerId") + .HasColumnType("bigint"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("Count") + .HasColumnType("integer"); + + b1.Property("ItemId") + .HasColumnType("integer"); + + b1.HasKey("ViewerId", "Id"); + + b1.HasIndex("ItemId"); + + b1.HasIndex("ViewerId", "ItemId") + .IsUnique(); + + b1.ToTable("OwnedItemEntry"); + + b1.HasOne("SVSim.Database.Models.ItemEntry", "Item") + .WithMany() + .HasForeignKey("ItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.WithOwner("Viewer") + .HasForeignKey("ViewerId"); + + b1.Navigation("Item"); + + b1.Navigation("Viewer"); + }); + + b.OwnsMany("SVSim.Database.Models.SocialAccountConnection", "SocialAccountConnections", b1 => + { + b1.Property("ViewerId") + .HasColumnType("bigint"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("AccountId") + .HasColumnType("numeric(20,0)"); + + b1.Property("AccountType") + .HasColumnType("integer"); + + b1.HasKey("ViewerId", "Id"); + + b1.HasIndex("AccountType", "AccountId") + .IsUnique(); + + b1.ToTable("SocialAccountConnection"); + + b1.WithOwner("Viewer") + .HasForeignKey("ViewerId"); + + b1.Navigation("Viewer"); + }); + + b.OwnsMany("SVSim.Database.Models.ViewerBuildDeckProductPurchase", "BuildDeckPurchases", b1 => + { + b1.Property("ViewerId") + .HasColumnType("bigint"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("ProductId") + .HasColumnType("integer"); + + b1.Property("PurchaseCount") + .HasColumnType("integer"); + + b1.HasKey("ViewerId", "Id"); + + b1.HasIndex("ViewerId", "ProductId") + .IsUnique(); + + b1.ToTable("ViewerBuildDeckProductPurchase"); + + b1.WithOwner() + .HasForeignKey("ViewerId"); + }); + + b.OwnsMany("SVSim.Database.Models.ViewerClassData", "Classes", b1 => + { + b1.Property("ViewerId") + .HasColumnType("bigint"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("ClassId") + .HasColumnType("integer"); + + b1.Property("Exp") + .HasColumnType("integer"); + + b1.Property("IsRandomLeaderSkin") + .HasColumnType("boolean"); + + b1.Property("LeaderSkinId") + .HasColumnType("integer"); + + b1.Property("Level") + .HasColumnType("integer"); + + b1.HasKey("ViewerId", "Id"); + + b1.HasIndex("ClassId"); + + b1.HasIndex("LeaderSkinId"); + + b1.ToTable("ViewerClassData"); + + b1.HasOne("SVSim.Database.Models.ClassEntry", "Class") + .WithMany() + .HasForeignKey("ClassId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.HasOne("SVSim.Database.Models.LeaderSkinEntry", "LeaderSkin") + .WithMany() + .HasForeignKey("LeaderSkinId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.WithOwner("Viewer") + .HasForeignKey("ViewerId"); + + b1.Navigation("Class"); + + b1.Navigation("LeaderSkin"); + + b1.Navigation("Viewer"); + }); + + b.OwnsOne("SVSim.Database.Models.ViewerCurrency", "Currency", b1 => + { + b1.Property("ViewerId") + .HasColumnType("bigint"); + + b1.Property("AndroidCrystals") + .HasColumnType("numeric(20,0)"); + + b1.Property("Crystals") + .HasColumnType("numeric(20,0)"); + + b1.Property("DmmCrystals") + .HasColumnType("numeric(20,0)"); + + b1.Property("FreeCrystals") + .HasColumnType("numeric(20,0)"); + + b1.Property("IosCrystals") + .HasColumnType("numeric(20,0)"); + + b1.Property("LifeTotalCrystals") + .HasColumnType("numeric(20,0)"); + + b1.Property("RedEther") + .HasColumnType("numeric(20,0)"); + + b1.Property("Rupees") + .HasColumnType("numeric(20,0)"); + + b1.Property("SpotPoints") + .HasColumnType("numeric(20,0)"); + + b1.Property("SteamCrystals") + .HasColumnType("numeric(20,0)"); + + b1.HasKey("ViewerId"); + + b1.ToTable("Viewers"); + + b1.WithOwner() + .HasForeignKey("ViewerId"); + }); + + b.OwnsMany("SVSim.Database.Models.ViewerFreePackClaim", "FreePackClaims", b1 => + { + b1.Property("ViewerId") + .HasColumnType("bigint"); + + b1.Property("FreeGachaCampaignId") + .HasColumnType("integer"); + + b1.Property("ClaimCount") + .HasColumnType("integer"); + + b1.Property("LastClaimedAt") + .HasColumnType("timestamp with time zone"); + + b1.HasKey("ViewerId", "FreeGachaCampaignId"); + + b1.ToTable("ViewerFreePackClaim"); + + b1.WithOwner() + .HasForeignKey("ViewerId"); + }); + + b.OwnsMany("SVSim.Database.Models.ViewerGachaPointBalance", "GachaPointBalances", b1 => + { + b1.Property("ViewerId") + .HasColumnType("bigint"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("PackId") + .HasColumnType("integer"); + + b1.Property("Points") + .HasColumnType("integer"); + + b1.HasKey("ViewerId", "Id"); + + b1.HasIndex("ViewerId", "PackId") + .IsUnique(); + + b1.ToTable("ViewerGachaPointBalance"); + + b1.WithOwner() + .HasForeignKey("ViewerId"); + }); + + b.OwnsMany("SVSim.Database.Models.ViewerGachaPointReceived", "GachaPointReceived", b1 => + { + b1.Property("ViewerId") + .HasColumnType("bigint"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("CardId") + .HasColumnType("bigint"); + + b1.Property("PackId") + .HasColumnType("integer"); + + b1.Property("ReceivedAt") + .HasColumnType("timestamp with time zone"); + + b1.HasKey("ViewerId", "Id"); + + b1.HasIndex("ViewerId", "PackId", "CardId") + .IsUnique(); + + b1.ToTable("ViewerGachaPointReceived"); + + b1.WithOwner() + .HasForeignKey("ViewerId"); + }); + + b.OwnsOne("SVSim.Database.Models.ViewerInfo", "Info", b1 => + { + b1.Property("ViewerId") + .HasColumnType("bigint"); + + b1.Property("BirthDate") + .HasColumnType("timestamp with time zone"); + + b1.Property("ChallengeTwoPickSleeveId") + .HasColumnType("bigint"); + + b1.Property("CountryCode") + .IsRequired() + .HasColumnType("text"); + + b1.Property("IsFoilPreferred") + .HasColumnType("boolean"); + + b1.Property("IsOfficial") + .HasColumnType("boolean"); + + b1.Property("IsOfficialMarkDisplayed") + .HasColumnType("boolean"); + + b1.Property("IsPrizePreferred") + .HasColumnType("boolean"); + + b1.Property("IsSkipGachaEffect") + .HasColumnType("boolean"); + + b1.Property("MaxFriends") + .HasColumnType("integer"); + + b1.Property("SelectedDegreeId") + .HasColumnType("integer"); + + b1.Property("SelectedEmblemId") + .HasColumnType("integer"); + + b1.Property("UseChallengeTwoPickPremiumCard") + .HasColumnType("boolean"); + + b1.HasKey("ViewerId"); + + b1.HasIndex("SelectedDegreeId"); + + b1.HasIndex("SelectedEmblemId"); + + b1.ToTable("Viewers"); + + b1.HasOne("SVSim.Database.Models.DegreeEntry", "SelectedDegree") + .WithMany() + .HasForeignKey("SelectedDegreeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.HasOne("SVSim.Database.Models.EmblemEntry", "SelectedEmblem") + .WithMany() + .HasForeignKey("SelectedEmblemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.WithOwner() + .HasForeignKey("ViewerId"); + + b1.Navigation("SelectedDegree"); + + b1.Navigation("SelectedEmblem"); + }); + + b.OwnsOne("SVSim.Database.Models.ViewerMissionData", "MissionData", b1 => + { + b1.Property("ViewerId") + .HasColumnType("bigint"); + + b1.Property("HasReceivedPickTwoMission") + .HasColumnType("boolean"); + + b1.Property("MissionChangeTime") + .HasColumnType("timestamp with time zone"); + + b1.Property("MissionReceiveType") + .HasColumnType("integer"); + + b1.Property("TutorialState") + .HasColumnType("integer"); + + b1.HasKey("ViewerId"); + + b1.ToTable("Viewers"); + + b1.WithOwner() + .HasForeignKey("ViewerId"); + }); + + b.OwnsMany("SVSim.Database.Models.ViewerPackOpenCount", "PackOpenCounts", b1 => + { + b1.Property("ViewerId") + .HasColumnType("bigint"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("LastDailyFreeAt") + .HasColumnType("timestamp with time zone"); + + b1.Property("OpenCount") + .HasColumnType("integer"); + + b1.Property("PackId") + .HasColumnType("integer"); + + b1.HasKey("ViewerId", "Id"); + + b1.ToTable("ViewerPackOpenCount"); + + b1.WithOwner() + .HasForeignKey("ViewerId"); + }); + + b.Navigation("BuildDeckPurchases"); + + b.Navigation("Cards"); + + b.Navigation("Classes"); + + b.Navigation("Currency") + .IsRequired(); + + b.Navigation("FreePackClaims"); + + b.Navigation("GachaPointBalances"); + + b.Navigation("GachaPointReceived"); + + b.Navigation("Info") + .IsRequired(); + + b.Navigation("Items"); + + b.Navigation("MissionData") + .IsRequired(); + + b.Navigation("MyPageBgRotation"); + + b.Navigation("PackOpenCounts"); + + b.Navigation("SocialAccountConnections"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerAchievement", b => + { + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany("Achievements") + .HasForeignKey("ViewerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerAcquireHistoryEntry", b => + { + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany() + .HasForeignKey("ViewerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerEventCounter", b => + { + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany("EventCounters") + .HasForeignKey("ViewerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerFriend", b => + { + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany() + .HasForeignKey("FriendViewerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany() + .HasForeignKey("OwnerViewerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerFriendApply", b => + { + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany() + .HasForeignKey("FromViewerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany() + .HasForeignKey("ToViewerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerMission", b => + { + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany("Missions") + .HasForeignKey("ViewerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerPlayedTogether", b => + { + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany() + .HasForeignKey("OwnerViewerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerPresent", b => + { + b.HasOne("SVSim.Database.Models.Viewer", "Viewer") + .WithMany() + .HasForeignKey("ViewerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viewer"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerSerialCodeRedemption", b => + { + b.HasOne("SVSim.Database.Models.SerialCodeEntry", null) + .WithMany() + .HasForeignKey("SerialCodeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany() + .HasForeignKey("ViewerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("SleeveEntryViewer", b => + { + b.HasOne("SVSim.Database.Models.SleeveEntry", null) + .WithMany() + .HasForeignKey("SleevesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany() + .HasForeignKey("ViewersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("SVSim.Database.Models.BattlePassSeasonEntry", b => + { + b.Navigation("Rewards"); + }); + + modelBuilder.Entity("SVSim.Database.Models.BuildDeckSeriesEntry", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ClassEntry", b => + { + b.Navigation("LeaderSkins"); + }); + + modelBuilder.Entity("SVSim.Database.Models.LeaderSkinShopSeriesEntry", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("SVSim.Database.Models.PuzzleGroupEntry", b => + { + b.Navigation("Puzzles"); + }); + + modelBuilder.Entity("SVSim.Database.Models.SerialCodeEntry", b => + { + b.Navigation("Rewards"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ShadowverseCardSetEntry", b => + { + b.Navigation("Cards"); + }); + + modelBuilder.Entity("SVSim.Database.Models.SleeveShopSeriesEntry", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("SVSim.Database.Models.Viewer", b => + { + b.Navigation("Achievements"); + + b.Navigation("Decks"); + + b.Navigation("EventCounters"); + + b.Navigation("Missions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/SVSim.Database/Migrations/20260613155613_AddArenaColosseumRun.cs b/SVSim.Database/Migrations/20260613155613_AddArenaColosseumRun.cs new file mode 100644 index 00000000..f34e470b --- /dev/null +++ b/SVSim.Database/Migrations/20260613155613_AddArenaColosseumRun.cs @@ -0,0 +1,69 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace SVSim.Database.Migrations +{ + /// + public partial class AddArenaColosseumRun : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "ViewerArenaColosseumRuns", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + ViewerId = table.Column(type: "bigint", nullable: false), + EntryId = table.Column(type: "bigint", nullable: false), + SeasonId = table.Column(type: "integer", nullable: false), + RoundId = table.Column(type: "integer", nullable: false), + DeckFormat = table.Column(type: "integer", nullable: false), + LeaderSkinId = table.Column(type: "bigint", nullable: false), + ConsumeItemType = table.Column(type: "integer", nullable: false), + CandidateClassIdsJson = table.Column(type: "jsonb", nullable: false), + SelectTurn = table.Column(type: "integer", nullable: false), + IsSelectCompleted = table.Column(type: "boolean", nullable: false), + SelectedCardIdsJson = table.Column(type: "jsonb", nullable: false), + PendingPickSetsJson = table.Column(type: "jsonb", nullable: false), + NextCandidateId = table.Column(type: "bigint", nullable: false), + ClassId = table.Column(type: "integer", nullable: false), + ChaosId = table.Column(type: "integer", nullable: false), + ResultListJson = table.Column(type: "jsonb", nullable: false), + WinCount = table.Column(type: "integer", nullable: false), + LossCount = table.Column(type: "integer", nullable: false), + BattleCountThisRound = table.Column(type: "integer", nullable: false), + MaxBattleCountThisRound = table.Column(type: "integer", nullable: false), + BreakthroughNumberThisRound = table.Column(type: "integer", nullable: false), + RestEntryNum = table.Column(type: "integer", nullable: false), + IsRankMatching = table.Column(type: "boolean", nullable: false), + IsChampion = table.Column(type: "boolean", nullable: false), + RegisteredDeckNoListJson = table.Column(type: "jsonb", nullable: false), + IsPublished = table.Column(type: "boolean", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ViewerArenaColosseumRuns", x => x.Id); + }); + + migrationBuilder.CreateIndex( + name: "IX_ViewerArenaColosseumRuns_ViewerId", + table: "ViewerArenaColosseumRuns", + column: "ViewerId", + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ViewerArenaColosseumRuns"); + } + } +} diff --git a/SVSim.Database/Migrations/20260613164340_AddColosseumCuratedDecks.Designer.cs b/SVSim.Database/Migrations/20260613164340_AddColosseumCuratedDecks.Designer.cs new file mode 100644 index 00000000..f91d4998 --- /dev/null +++ b/SVSim.Database/Migrations/20260613164340_AddColosseumCuratedDecks.Designer.cs @@ -0,0 +1,4866 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using SVSim.Database; + +#nullable disable + +namespace SVSim.Database.Migrations +{ + [DbContext(typeof(SVSimDbContext))] + [Migration("20260613164340_AddColosseumCuratedDecks")] + partial class AddColosseumCuratedDecks + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.HasSequence("ShortUdidSequence") + .StartsAt(400000000L); + + modelBuilder.Entity("DegreeEntryViewer", b => + { + b.Property("DegreesId") + .HasColumnType("integer"); + + b.Property("ViewersId") + .HasColumnType("bigint"); + + b.HasKey("DegreesId", "ViewersId"); + + b.HasIndex("ViewersId"); + + b.ToTable("DegreeEntryViewer"); + }); + + modelBuilder.Entity("EmblemEntryViewer", b => + { + b.Property("EmblemsId") + .HasColumnType("integer"); + + b.Property("ViewersId") + .HasColumnType("bigint"); + + b.HasKey("EmblemsId", "ViewersId"); + + b.HasIndex("ViewersId"); + + b.ToTable("EmblemEntryViewer"); + }); + + modelBuilder.Entity("LeaderSkinEntryViewer", b => + { + b.Property("LeaderSkinsId") + .HasColumnType("integer"); + + b.Property("ViewersId") + .HasColumnType("bigint"); + + b.HasKey("LeaderSkinsId", "ViewersId"); + + b.HasIndex("ViewersId"); + + b.ToTable("LeaderSkinEntryViewer"); + }); + + modelBuilder.Entity("MyPageBackgroundEntryViewer", b => + { + b.Property("MyPageBackgroundsId") + .HasColumnType("integer"); + + b.Property("ViewersId") + .HasColumnType("bigint"); + + b.HasKey("MyPageBackgroundsId", "ViewersId"); + + b.HasIndex("ViewersId"); + + b.ToTable("MyPageBackgroundEntryViewer"); + }); + + modelBuilder.Entity("SVSim.Database.Entities.Story.SpecialBattleSetting", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("BanishEffectOverride") + .IsRequired() + .HasColumnType("text"); + + b.Property("ClassDestroyEffectOverride") + .HasColumnType("integer"); + + b.Property("EnemyAttachSkill") + .IsRequired() + .HasColumnType("text"); + + b.Property("EnemyStartLife") + .HasColumnType("integer"); + + b.Property("EnemyStartPp") + .HasColumnType("integer"); + + b.Property("IdOverrideInBattleLog") + .IsRequired() + .HasColumnType("text"); + + b.Property("Note") + .HasColumnType("text"); + + b.Property("PlayerAttachSkill") + .IsRequired() + .HasColumnType("text"); + + b.Property("PlayerFirstTurn") + .HasColumnType("integer"); + + b.Property("PlayerStartLife") + .HasColumnType("integer"); + + b.Property("PlayerStartPp") + .HasColumnType("integer"); + + b.Property("ResultSkip") + .HasColumnType("integer"); + + b.Property("SpecialTokenDrawEffectOverride") + .IsRequired() + .HasColumnType("text"); + + b.Property("TokenDrawEffectOverride") + .IsRequired() + .HasColumnType("text"); + + b.Property("VsEffectOverride") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("SpecialBattleSettings"); + }); + + modelBuilder.Entity("SVSim.Database.Entities.Story.StoryChapter", b => + { + b.Property("StoryId") + .HasColumnType("integer"); + + b.Property("Battle3dFieldId") + .HasColumnType("integer"); + + b.Property("BattleExists") + .HasColumnType("boolean"); + + b.Property("BgFileName") + .IsRequired() + .HasColumnType("text"); + + b.Property("BgmId") + .IsRequired() + .HasColumnType("text"); + + b.Property("ChapterClearTextId") + .HasColumnType("text"); + + b.Property("ChapterEffectPath") + .HasColumnType("text"); + + b.Property("ChapterId") + .IsRequired() + .HasColumnType("text"); + + b.Property("CharaId") + .HasColumnType("integer"); + + b.Property("EnemyAiId") + .HasColumnType("integer"); + + b.Property("EnemyCharaId") + .HasColumnType("integer"); + + b.Property("EnemyClass") + .HasColumnType("integer"); + + b.Property("IsCameraMovable") + .HasColumnType("integer"); + + b.Property("IsMaintenanceChapter") + .HasColumnType("boolean"); + + b.Property("IsPlayAnotherEndAppearanceAnimation") + .HasColumnType("boolean"); + + b.Property("IsReleasedAnotherEnd") + .HasColumnType("boolean"); + + b.Property("IsSkipEnabled") + .HasColumnType("boolean"); + + b.Property("NextChapterId") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReleasePoint") + .HasColumnType("integer"); + + b.Property("RequiredChapterId") + .HasColumnType("text"); + + b.Property("SectionId") + .HasColumnType("integer"); + + b.Property("SelectionDisplayPosition") + .HasColumnType("text"); + + b.Property("SelectionTextId") + .HasColumnType("text"); + + b.Property("ShowCoordinate") + .HasColumnType("integer"); + + b.Property("ShowSubtitles") + .HasColumnType("integer"); + + b.Property("SpecialBattleSettingId") + .HasColumnType("integer"); + + b.Property("UnlockText") + .HasColumnType("text"); + + b.Property("XCoordinate") + .HasColumnType("numeric"); + + b.Property("YCoordinate") + .HasColumnType("numeric"); + + b.HasKey("StoryId"); + + b.HasIndex("NextChapterId"); + + b.HasIndex("SpecialBattleSettingId"); + + b.HasIndex("SectionId", "CharaId", "ChapterId"); + + b.ToTable("StoryChapters"); + }); + + modelBuilder.Entity("SVSim.Database.Entities.Story.StorySection", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("AllStoryOrderId") + .HasColumnType("integer"); + + b.Property("BackGroundId") + .HasColumnType("integer"); + + b.Property("ChapterSelectType") + .HasColumnType("integer"); + + b.Property("ImageName") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsLeaderSelect") + .HasColumnType("boolean"); + + b.Property("IsPlayAnotherEndAppearanceAnimation") + .HasColumnType("boolean"); + + b.Property("IsSpoiler") + .HasColumnType("integer"); + + b.Property("IsUnderMaintenance") + .HasColumnType("boolean"); + + b.Property("NameTextKey") + .IsRequired() + .HasColumnType("text"); + + b.Property("OrderId") + .HasColumnType("integer"); + + b.Property("SpoilerMessage") + .IsRequired() + .HasColumnType("text"); + + b.Property("StoryApiType") + .HasColumnType("integer"); + + b.Property("StoryTypeOverwrite") + .HasColumnType("integer"); + + b.Property("WorldId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("WorldId"); + + b.ToTable("StorySections"); + }); + + modelBuilder.Entity("SVSim.Database.Entities.Story.StoryWorld", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("PanelImageName") + .IsRequired() + .HasColumnType("text"); + + b.Property("RibbonText") + .IsRequired() + .HasColumnType("text"); + + b.Property("TitleTextKey") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("StoryWorlds"); + }); + + modelBuilder.Entity("SVSim.Database.Entities.Story.ViewerStoryBranchUnlock", b => + { + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.Property("StoryId") + .HasColumnType("integer"); + + b.Property("UnlockedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("ViewerId", "StoryId"); + + b.ToTable("ViewerStoryBranchUnlocks"); + }); + + modelBuilder.Entity("SVSim.Database.Entities.Story.ViewerStoryProgress", b => + { + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.Property("StoryId") + .HasColumnType("integer"); + + b.Property("FinishedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("IsFinish") + .HasColumnType("boolean"); + + b.Property("IsSkipped") + .HasColumnType("boolean"); + + b.Property("SkippedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("ViewerId", "StoryId"); + + b.ToTable("ViewerStoryProgress"); + }); + + modelBuilder.Entity("SVSim.Database.Models.AchievementCatalogEntry", b => + { + b.Property("AchievementType") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("EventArg") + .HasColumnType("integer"); + + b.Property("EventType") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("OrderNum") + .HasColumnType("integer"); + + b.Property("RequireNumber") + .HasColumnType("integer"); + + b.Property("RewardDetailId") + .HasColumnType("bigint"); + + b.Property("RewardNumber") + .HasColumnType("integer"); + + b.Property("RewardType") + .HasColumnType("integer"); + + b.HasKey("AchievementType", "Level"); + + b.HasIndex("AchievementType"); + + b.HasIndex("EventType", "EventArg"); + + b.ToTable("AchievementCatalog"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ArenaSeasonConfig", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("Cost") + .HasColumnType("numeric(20,0)"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("Enable") + .HasColumnType("integer"); + + b.Property("FormatInfo") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("IsJoin") + .HasColumnType("boolean"); + + b.Property("Mode") + .HasColumnType("integer"); + + b.Property("RupyCost") + .HasColumnType("numeric(20,0)"); + + b.Property("TicketCost") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("ArenaSeasons"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ArenaTwoPickReward", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("RewardGroup") + .HasColumnType("integer"); + + b.Property("RewardId") + .HasColumnType("bigint"); + + b.Property("RewardNum") + .HasColumnType("integer"); + + b.Property("RewardType") + .HasColumnType("integer"); + + b.Property("Weight") + .HasColumnType("integer"); + + b.Property("WinCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("WinCount"); + + b.HasIndex("WinCount", "RewardGroup", "RewardType", "RewardId", "RewardNum") + .IsUnique(); + + b.ToTable("ArenaTwoPickRewards"); + }); + + modelBuilder.Entity("SVSim.Database.Models.AvatarAbilityEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("Ability") + .IsRequired() + .HasColumnType("text"); + + b.Property("AbilityCost") + .IsRequired() + .HasColumnType("text"); + + b.Property("AbilityDesc") + .IsRequired() + .HasColumnType("text"); + + b.Property("BattleStartFirstPlayerTurnBp") + .HasColumnType("integer"); + + b.Property("BattleStartMaxLife") + .HasColumnType("integer"); + + b.Property("BattleStartSecondPlayerTurnBp") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("LeaderSkinId") + .HasColumnType("integer"); + + b.Property("PassiveAbility") + .IsRequired() + .HasColumnType("text"); + + b.Property("PassiveAbilityDesc") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("AvatarAbilities"); + }); + + modelBuilder.Entity("SVSim.Database.Models.BannerEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("ChangeTime") + .HasColumnType("integer"); + + b.Property("Click") + .IsRequired() + .HasColumnType("text"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("ImageName") + .IsRequired() + .HasColumnType("text"); + + b.Property("ImagePaths") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("RemainingTime") + .HasColumnType("integer"); + + b.Property("Status") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Banners"); + }); + + modelBuilder.Entity("SVSim.Database.Models.BattlePassLevelEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("RequiredPoint") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("BattlePassLevels"); + }); + + modelBuilder.Entity("SVSim.Database.Models.BattlePassMonthlyMissionEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BattlePassPoint") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("EventArg") + .HasColumnType("integer"); + + b.Property("EventType") + .HasColumnType("text"); + + b.Property("Month") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("OrderNum") + .HasColumnType("integer"); + + b.Property("RequireNumber") + .HasColumnType("integer"); + + b.Property("RewardDetailId") + .HasColumnType("bigint"); + + b.Property("RewardNumber") + .HasColumnType("integer"); + + b.Property("RewardType") + .HasColumnType("integer"); + + b.Property("Year") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Year", "Month"); + + b.HasIndex("Year", "Month", "OrderNum") + .IsUnique(); + + b.ToTable("BattlePassMonthlyMissions"); + }); + + modelBuilder.Entity("SVSim.Database.Models.BattlePassRewardEntry", b => + { + b.Property("Id") + .HasColumnType("bigint"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("IsAppealExclusion") + .HasColumnType("boolean"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("RewardDetailId") + .HasColumnType("bigint"); + + b.Property("RewardNumber") + .HasColumnType("integer"); + + b.Property("RewardType") + .HasColumnType("integer"); + + b.Property("SeasonId") + .HasColumnType("integer"); + + b.Property("Track") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("SeasonId", "Track", "Level") + .IsUnique(); + + b.ToTable("BattlePassRewards"); + }); + + modelBuilder.Entity("SVSim.Database.Models.BattlePassSeasonEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("CanPurchase") + .HasColumnType("boolean"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("EndDate") + .HasColumnType("timestamp with time zone"); + + b.Property("MaxLevel") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("PriceCrystal") + .HasColumnType("integer"); + + b.Property("StartDate") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("StartDate", "EndDate"); + + b.ToTable("BattlePassSeasons"); + }); + + modelBuilder.Entity("SVSim.Database.Models.BattlefieldEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("IsOpen") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Battlefields"); + }); + + modelBuilder.Entity("SVSim.Database.Models.BotRosterEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("AiId") + .HasColumnType("integer"); + + b.Property("BattlePoint") + .HasColumnType("integer"); + + b.Property("CharaId") + .HasColumnType("integer"); + + b.Property("ClassId") + .HasColumnType("integer"); + + b.Property("CountryCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("DegreeId") + .HasColumnType("integer"); + + b.Property("EmblemId") + .HasColumnType("integer"); + + b.Property("FieldId") + .HasColumnType("integer"); + + b.Property("IsMasterRank") + .HasColumnType("integer"); + + b.Property("IsOfficial") + .HasColumnType("integer"); + + b.Property("MasterPoint") + .HasColumnType("integer"); + + b.Property("Rank") + .HasColumnType("integer"); + + b.Property("SleeveId") + .HasColumnType("integer"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("BotRoster"); + }); + + modelBuilder.Entity("SVSim.Database.Models.BuildDeckProductEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("DeckCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("FeaturedCardId") + .HasColumnType("bigint"); + + b.Property("IntroPriceCrystal") + .HasColumnType("integer"); + + b.Property("IntroPriceRupy") + .HasColumnType("integer"); + + b.Property("IsEnabled") + .HasColumnType("boolean"); + + b.Property("LeaderId") + .HasColumnType("integer"); + + b.Property("ProductNameKey") + .IsRequired() + .HasColumnType("text"); + + b.Property("PurchaseNumMax") + .HasColumnType("integer"); + + b.Property("RegularPriceCrystal") + .HasColumnType("integer"); + + b.Property("RegularPriceRupy") + .HasColumnType("integer"); + + b.Property("SeriesId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("SeriesId"); + + b.ToTable("BuildDeckProducts"); + }); + + modelBuilder.Entity("SVSim.Database.Models.BuildDeckSeriesEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("DrumrollPath") + .IsRequired() + .HasColumnType("text"); + + b.Property("IntroKey") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsEnabled") + .HasColumnType("boolean"); + + b.Property("IsNew") + .HasColumnType("boolean"); + + b.Property("NameKey") + .IsRequired() + .HasColumnType("text"); + + b.Property("OrderIndex") + .HasColumnType("integer"); + + b.Property("TitlePath") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("BuildDeckSeries"); + }); + + modelBuilder.Entity("SVSim.Database.Models.CardCosmeticReward", b => + { + b.Property("CardId") + .HasColumnType("bigint"); + + b.Property("Type") + .HasColumnType("integer"); + + b.Property("CosmeticId") + .HasColumnType("bigint"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.HasKey("CardId", "Type", "CosmeticId"); + + b.HasIndex("CardId"); + + b.ToTable("CardCosmeticRewards"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ClassEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Classes"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ClassExpEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("NecessaryExp") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("ClassExpCurve"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ColosseumAvatarDeck", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CardListJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("ClassId") + .HasColumnType("integer"); + + b.Property("DeckNo") + .HasColumnType("integer"); + + b.Property("DisplayOrder") + .HasColumnType("integer"); + + b.Property("LeaderSkinId") + .HasColumnType("bigint"); + + b.Property("SleeveId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("DeckNo") + .IsUnique(); + + b.ToTable("ColosseumAvatarDecks"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ColosseumConfig", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("CardPoolName") + .IsRequired() + .HasColumnType("text"); + + b.Property("ColosseumId") + .IsRequired() + .HasColumnType("text"); + + b.Property("ColosseumName") + .IsRequired() + .HasColumnType("text"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("DeckFormat") + .IsRequired() + .HasColumnType("text"); + + b.Property("EndTime") + .HasColumnType("timestamp with time zone"); + + b.Property("IsAllCardEnabled") + .HasColumnType("integer"); + + b.Property("IsColosseumPeriod") + .HasColumnType("boolean"); + + b.Property("IsDisplayTips") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsNormalTwoPick") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRoundPeriod") + .HasColumnType("boolean"); + + b.Property("IsSpecialMode") + .IsRequired() + .HasColumnType("text"); + + b.Property("NowRound") + .IsRequired() + .HasColumnType("text"); + + b.Property("SalesPeriodInfo") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("StartTime") + .HasColumnType("timestamp with time zone"); + + b.Property("TipsId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Colosseums"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ColosseumHofDeck", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CardListJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("ClassId") + .HasColumnType("integer"); + + b.Property("DeckNo") + .HasColumnType("integer"); + + b.Property("DisplayOrder") + .HasColumnType("integer"); + + b.Property("LeaderSkinId") + .HasColumnType("bigint"); + + b.Property("SleeveId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("DeckNo") + .IsUnique(); + + b.ToTable("ColosseumHofDecks"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ColosseumWindFallDeck", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CardListJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("ClassId") + .HasColumnType("integer"); + + b.Property("DeckNo") + .HasColumnType("integer"); + + b.Property("DisplayOrder") + .HasColumnType("integer"); + + b.Property("LeaderSkinId") + .HasColumnType("bigint"); + + b.Property("SleeveId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("DeckNo") + .IsUnique(); + + b.ToTable("ColosseumWindFallDecks"); + }); + + modelBuilder.Entity("SVSim.Database.Models.DailyLoginBonusEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("BonusData") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("BonusId") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("DailyLoginBonuses"); + }); + + modelBuilder.Entity("SVSim.Database.Models.DefaultDeckEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("CardIdArray") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("ClassId") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("DeckName") + .IsRequired() + .HasColumnType("text"); + + b.Property("DeckNo") + .HasColumnType("integer"); + + b.Property("LeaderSkinId") + .HasColumnType("integer"); + + b.Property("SleeveId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.ToTable("DefaultDecks"); + }); + + modelBuilder.Entity("SVSim.Database.Models.DegreeEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("Degrees"); + }); + + modelBuilder.Entity("SVSim.Database.Models.EmblemEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("Emblems"); + }); + + modelBuilder.Entity("SVSim.Database.Models.FeatureMaintenanceEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("Data") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("FeatureKey") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("FeatureMaintenances"); + }); + + modelBuilder.Entity("SVSim.Database.Models.GameConfigSection", b => + { + b.Property("SectionName") + .HasColumnType("text"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("ValueJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.HasKey("SectionName"); + + b.ToTable("GameConfigs"); + }); + + modelBuilder.Entity("SVSim.Database.Models.HomeDialogEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("BeginTime") + .HasColumnType("timestamp with time zone"); + + b.Property("ButtonListJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("EndTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Image") + .IsRequired() + .HasColumnType("text"); + + b.Property("Priority") + .HasColumnType("integer"); + + b.Property("TitleTextId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("HomeDialogEntries"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ItemEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ThumbnailPath") + .IsRequired() + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Items"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ItemPurchaseCatalogEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("IsEnabled") + .HasColumnType("boolean"); + + b.Property("IsMonthlyReset") + .HasColumnType("boolean"); + + b.Property("PurchaseItemId") + .HasColumnType("bigint"); + + b.Property("PurchaseItemNum") + .HasColumnType("integer"); + + b.Property("PurchaseItemType") + .HasColumnType("integer"); + + b.Property("PurchaseLimit") + .HasColumnType("integer"); + + b.Property("PurchaseName") + .IsRequired() + .HasColumnType("text"); + + b.Property("RequireItemId") + .HasColumnType("bigint"); + + b.Property("RequireItemNum") + .HasColumnType("integer"); + + b.Property("RequireItemType") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("ItemPurchaseCatalog"); + }); + + modelBuilder.Entity("SVSim.Database.Models.LeaderSkinEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("ClassId") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("EmoteId") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ClassId"); + + b.ToTable("LeaderSkins"); + }); + + modelBuilder.Entity("SVSim.Database.Models.LeaderSkinShopProductEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("CvNameKey") + .IsRequired() + .HasColumnType("text"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("IntroductionKey") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsEnabled") + .HasColumnType("boolean"); + + b.Property("LeaderSkinId") + .HasColumnType("integer"); + + b.Property("ProductNameKey") + .IsRequired() + .HasColumnType("text"); + + b.Property("SeriesId") + .HasColumnType("integer"); + + b.Property("SinglePriceCrystal") + .HasColumnType("integer"); + + b.Property("SinglePriceRupy") + .HasColumnType("integer"); + + b.Property("SinglePriceTicket") + .HasColumnType("integer"); + + b.Property("TicketItemId") + .HasColumnType("bigint"); + + b.Property("TicketNumber") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("SeriesId"); + + b.ToTable("LeaderSkinShopProducts"); + }); + + modelBuilder.Entity("SVSim.Database.Models.LeaderSkinShopSeriesEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("IsEnabled") + .HasColumnType("boolean"); + + b.Property("IsNew") + .HasColumnType("boolean"); + + b.Property("SetCompletionRewardStatus") + .HasColumnType("integer"); + + b.Property("SetPriceCrystal") + .HasColumnType("integer"); + + b.Property("SetPriceRupy") + .HasColumnType("integer"); + + b.Property("SetPriceTicket") + .HasColumnType("integer"); + + b.Property("SetPriceTicketId") + .HasColumnType("bigint"); + + b.Property("SetSalesStatus") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("LeaderSkinShopSeries"); + }); + + modelBuilder.Entity("SVSim.Database.Models.LoadingExclusionCardEntry", b => + { + b.Property("Id") + .HasColumnType("bigint"); + + b.Property("CardId") + .HasColumnType("bigint"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("LoadingExclusionCards"); + }); + + modelBuilder.Entity("SVSim.Database.Models.MaintenanceCardEntry", b => + { + b.Property("Id") + .HasColumnType("bigint"); + + b.Property("CardId") + .HasColumnType("bigint"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("MaintenanceCards"); + }); + + modelBuilder.Entity("SVSim.Database.Models.MasterPointRankingPeriodEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("BeginTime") + .HasColumnType("timestamp with time zone"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("EndTime") + .HasColumnType("timestamp with time zone"); + + b.Property("NecessaryScore") + .HasColumnType("bigint"); + + b.Property("PeriodNum") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("MasterPointRankingPeriods"); + }); + + modelBuilder.Entity("SVSim.Database.Models.MissionCatalogEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("BattlePassPoint") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("DefaultFlag") + .HasColumnType("boolean"); + + b.Property("EndTime") + .HasColumnType("bigint"); + + b.Property("EventArg") + .HasColumnType("integer"); + + b.Property("EventType") + .HasColumnType("text"); + + b.Property("LotType") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RequireNumber") + .HasColumnType("integer"); + + b.Property("RewardDetailId") + .HasColumnType("bigint"); + + b.Property("RewardNumber") + .HasColumnType("integer"); + + b.Property("RewardType") + .HasColumnType("integer"); + + b.Property("StartTime") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("LotType"); + + b.HasIndex("EventType", "EventArg"); + + b.ToTable("MissionCatalog"); + }); + + modelBuilder.Entity("SVSim.Database.Models.MyPageBackgroundEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("MyPageBackgrounds"); + }); + + modelBuilder.Entity("SVSim.Database.Models.MyRotationAbilityEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("AbilityId") + .HasColumnType("integer"); + + b.Property("Data") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("MyRotationAbilities"); + }); + + modelBuilder.Entity("SVSim.Database.Models.MyRotationSettingEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("AbilitiesCsv") + .IsRequired() + .HasColumnType("text"); + + b.Property("CardSetIdsCsv") + .IsRequired() + .HasColumnType("text"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("ReprintedCardIds") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("RestrictedCardIds") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("RotationId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("MyRotationSettings"); + }); + + modelBuilder.Entity("SVSim.Database.Models.PackConfigEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("BasePackId") + .HasColumnType("integer"); + + b.Property("CommenceDate") + .HasColumnType("timestamp with time zone"); + + b.Property("CompleteDate") + .HasColumnType("timestamp with time zone"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("GachaDetail") + .IsRequired() + .HasColumnType("text"); + + b.Property("GachaType") + .HasColumnType("integer"); + + b.Property("IsEnabled") + .HasColumnType("boolean"); + + b.Property("IsHide") + .HasColumnType("boolean"); + + b.Property("IsNew") + .HasColumnType("boolean"); + + b.Property("IsPreRelease") + .HasColumnType("boolean"); + + b.Property("OpenCountLimit") + .HasColumnType("integer"); + + b.Property("OverrideDrawEffectPackId") + .HasColumnType("integer"); + + b.Property("OverrideUiEffectPackId") + .HasColumnType("integer"); + + b.Property("PackCategory") + .HasColumnType("integer"); + + b.Property("PosterType") + .HasColumnType("integer"); + + b.Property("SalesPeriodTime") + .HasColumnType("timestamp with time zone"); + + b.Property("SleeveId") + .HasColumnType("integer"); + + b.Property("SpecialSleeveId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Packs"); + }); + + modelBuilder.Entity("SVSim.Database.Models.PackDrawCardWeightEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CardId") + .HasColumnType("bigint"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("IsAltArt") + .HasColumnType("boolean"); + + b.Property("IsLeader") + .HasColumnType("boolean"); + + b.Property("PackId") + .HasColumnType("integer"); + + b.Property("RatePct") + .HasColumnType("double precision"); + + b.Property("Slot") + .HasColumnType("integer"); + + b.Property("Tier") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("PackId", "Slot", "Tier"); + + b.ToTable("PackDrawCardWeights"); + }); + + modelBuilder.Entity("SVSim.Database.Models.PackDrawConfigEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("AnimationRatePct") + .HasColumnType("double precision"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("HasBonusSlot") + .HasColumnType("boolean"); + + b.Property("ShortCode") + .HasColumnType("text"); + + b.Property("SpecialKind") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("PackDrawConfigs"); + }); + + modelBuilder.Entity("SVSim.Database.Models.PackDrawSlotRateEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("PackId") + .HasColumnType("integer"); + + b.Property("RatePct") + .HasColumnType("double precision"); + + b.Property("Slot") + .HasColumnType("integer"); + + b.Property("Tier") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("PackId", "Slot", "Tier") + .IsUnique(); + + b.ToTable("PackDrawSlotRates"); + }); + + modelBuilder.Entity("SVSim.Database.Models.PaymentItemEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("ChargeCrystalNum") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("EndTime") + .HasColumnType("timestamp with time zone"); + + b.Property("FreeCrystalNum") + .HasColumnType("integer"); + + b.Property("ImageName") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsResaleProduct") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("numeric"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("PurchaseLimit") + .HasColumnType("integer"); + + b.Property("RemainingTime") + .HasColumnType("integer"); + + b.Property("ResaleStartDate") + .HasColumnType("timestamp with time zone"); + + b.Property("SpecialShopFlag") + .HasColumnType("integer"); + + b.Property("StartTime") + .HasColumnType("timestamp with time zone"); + + b.Property("StoreProductId") + .HasColumnType("bigint"); + + b.Property("Text") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("PaymentItems"); + }); + + modelBuilder.Entity("SVSim.Database.Models.PracticeOpponentEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("AiDeckLevel") + .HasColumnType("integer"); + + b.Property("AiLogicLevel") + .HasColumnType("integer"); + + b.Property("AiMaxLife") + .HasColumnType("integer"); + + b.Property("Battle3dFieldId") + .IsRequired() + .HasColumnType("text"); + + b.Property("CharaId") + .HasColumnType("integer"); + + b.Property("ClassId") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("DegreeId") + .HasColumnType("integer"); + + b.Property("IsCampaignPractice") + .HasColumnType("boolean"); + + b.Property("IsMaintenance") + .HasColumnType("boolean"); + + b.Property("PracticeId") + .HasColumnType("integer"); + + b.Property("TextId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("PracticeOpponents"); + }); + + modelBuilder.Entity("SVSim.Database.Models.PreReleaseInfo", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("CardMasterId") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("DefaultCardMasterId") + .IsRequired() + .HasColumnType("text"); + + b.Property("DisplayEndTime") + .HasColumnType("timestamp with time zone"); + + b.Property("EndTime") + .HasColumnType("timestamp with time zone"); + + b.Property("FreeMatchStartTime") + .HasColumnType("timestamp with time zone"); + + b.Property("IsPreRotationFreeMatchTerm") + .HasColumnType("boolean"); + + b.Property("LatestReprintedBaseCardIds") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("NextCardSetId") + .IsRequired() + .HasColumnType("text"); + + b.Property("PreReleaseCardMasterId") + .IsRequired() + .HasColumnType("text"); + + b.Property("PreReleaseId") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReprintedBaseCardIds") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("RotationCardSetIdList") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("StartTime") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("PreReleaseInfos"); + }); + + modelBuilder.Entity("SVSim.Database.Models.PuzzleEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("GroupId") + .HasColumnType("integer"); + + b.Property("IsAdditional") + .HasColumnType("boolean"); + + b.Property("IsPlayable") + .HasColumnType("boolean"); + + b.Property("PuzzleDifficulty") + .HasColumnType("integer"); + + b.Property("PuzzleId") + .HasColumnType("integer"); + + b.Property("ReleaseConditionTextId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("GroupId"); + + b.ToTable("Puzzles"); + }); + + modelBuilder.Entity("SVSim.Database.Models.PuzzleGroupEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("BasicTitleTextId") + .IsRequired() + .HasColumnType("text"); + + b.Property("CharaId") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("DifficultyNameListJson") + .IsRequired() + .HasColumnType("text"); + + b.Property("PuzzleCharaId") + .HasColumnType("integer"); + + b.Property("PuzzleMasterId") + .HasColumnType("integer"); + + b.Property("SortType") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("PuzzleGroups"); + }); + + modelBuilder.Entity("SVSim.Database.Models.PuzzleMissionEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("AchievedMessage") + .IsRequired() + .HasColumnType("text"); + + b.Property("CampaignCommenceTime") + .HasColumnType("bigint"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("MissionName") + .IsRequired() + .HasColumnType("text"); + + b.Property("OrderId") + .HasColumnType("integer"); + + b.Property("RequireNumber") + .HasColumnType("integer"); + + b.Property("RewardDetailId") + .HasColumnType("bigint"); + + b.Property("RewardNumber") + .HasColumnType("integer"); + + b.Property("RewardType") + .HasColumnType("integer"); + + b.Property("TargetPuzzleGroupId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("PuzzleMissions"); + }); + + modelBuilder.Entity("SVSim.Database.Models.RankInfoEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("AccumulateMasterPoint") + .HasColumnType("integer"); + + b.Property("AccumulatePoint") + .HasColumnType("integer"); + + b.Property("BaseAddBp") + .HasColumnType("integer"); + + b.Property("BaseDropBp") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("IsPromotionWar") + .HasColumnType("integer"); + + b.Property("LoseBonus") + .HasColumnType("double precision"); + + b.Property("LowerLimitPoint") + .HasColumnType("integer"); + + b.Property("MatchCount") + .HasColumnType("integer"); + + b.Property("MaxLoseBonus") + .HasColumnType("integer"); + + b.Property("MaxWinBonus") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NecessaryPoint") + .HasColumnType("integer"); + + b.Property("NecessaryWin") + .HasColumnType("integer"); + + b.Property("ResetLose") + .HasColumnType("integer"); + + b.Property("StreakBonusPt") + .HasColumnType("integer"); + + b.Property("WinBonus") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.ToTable("RankInfo"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ReprintedCardEntry", b => + { + b.Property("Id") + .HasColumnType("bigint"); + + b.Property("CardId") + .HasColumnType("bigint"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("ReprintedCards"); + }); + + modelBuilder.Entity("SVSim.Database.Models.SealedConfig", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("CrystalCost") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("DeckUsingNumMin") + .HasColumnType("integer"); + + b.Property("Enable") + .HasColumnType("integer"); + + b.Property("IsDeckCodeMaintenance") + .HasColumnType("boolean"); + + b.Property("IsJoin") + .HasColumnType("boolean"); + + b.Property("PackInfo") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("RupyCost") + .HasColumnType("integer"); + + b.Property("SalesPeriodInfo") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("ScheduleId") + .HasColumnType("integer"); + + b.Property("TicketCost") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("SealedSeasons"); + }); + + modelBuilder.Entity("SVSim.Database.Models.SerialCodeEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("EndAt") + .HasColumnType("timestamp with time zone"); + + b.Property("IsEnabled") + .HasColumnType("boolean"); + + b.Property("Message") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("StartAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("SerialCodes"); + }); + + modelBuilder.Entity("SVSim.Database.Models.SerialCodeRewardEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("RewardCount") + .HasColumnType("integer"); + + b.Property("RewardDetailId") + .HasColumnType("bigint"); + + b.Property("RewardType") + .HasColumnType("integer"); + + b.Property("SerialCodeId") + .HasColumnType("integer"); + + b.Property("Slot") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("SerialCodeId", "Slot"); + + b.ToTable("SerialCodeRewards"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ShadowverseCardEntry", b => + { + b.Property("Id") + .HasColumnType("bigint"); + + b.Property("Attack") + .HasColumnType("integer"); + + b.Property("ClassId") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("Defense") + .HasColumnType("integer"); + + b.Property("IsFoil") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("PrimaryResourceCost") + .HasColumnType("integer"); + + b.Property("Rarity") + .HasColumnType("integer"); + + b.Property("ShadowverseCardSetEntryId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ClassId"); + + b.HasIndex("ShadowverseCardSetEntryId"); + + b.ToTable("Cards"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ShadowverseCardSetEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("IsBasic") + .HasColumnType("boolean"); + + b.Property("IsInRotation") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("CardSets"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ShadowverseDeckEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ClassId") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("Format") + .HasColumnType("integer"); + + b.Property("LeaderSkinId") + .HasColumnType("integer"); + + b.Property("MyRotationId") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Number") + .HasColumnType("integer"); + + b.Property("RandomLeaderSkin") + .HasColumnType("boolean"); + + b.Property("SleeveId") + .HasColumnType("integer"); + + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ClassId"); + + b.HasIndex("LeaderSkinId"); + + b.HasIndex("SleeveId"); + + b.HasIndex("ViewerId"); + + b.ToTable("Decks"); + }); + + modelBuilder.Entity("SVSim.Database.Models.SleeveEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("Sleeves"); + }); + + modelBuilder.Entity("SVSim.Database.Models.SleeveShopProductEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("IsEnabled") + .HasColumnType("boolean"); + + b.Property("NameKey") + .IsRequired() + .HasColumnType("text"); + + b.Property("PriceCrystal") + .HasColumnType("integer"); + + b.Property("PriceRupy") + .HasColumnType("integer"); + + b.Property("SeriesId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("SeriesId"); + + b.ToTable("SleeveShopProducts"); + }); + + modelBuilder.Entity("SVSim.Database.Models.SleeveShopSeriesEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("IsEnabled") + .HasColumnType("boolean"); + + b.Property("IsNew") + .HasColumnType("boolean"); + + b.HasKey("Id"); + + b.ToTable("SleeveShopSeries"); + }); + + modelBuilder.Entity("SVSim.Database.Models.SpecialDeckFormatEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("DeckFormat") + .IsRequired() + .HasColumnType("text"); + + b.Property("EndTime") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("SpecialDeckFormats"); + }); + + modelBuilder.Entity("SVSim.Database.Models.SpotCardEntry", b => + { + b.Property("Id") + .HasColumnType("bigint"); + + b.Property("CardId") + .HasColumnType("bigint"); + + b.Property("Cost") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("SpotCards"); + }); + + modelBuilder.Entity("SVSim.Database.Models.SpotCardExchangeEntry", b => + { + b.Property("Id") + .HasColumnType("bigint"); + + b.Property("CardId") + .HasColumnType("bigint"); + + b.Property("ClassId") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("ExchangePoint") + .HasColumnType("integer"); + + b.Property("IsEnabled") + .HasColumnType("boolean"); + + b.Property("IsPreRelease") + .HasColumnType("boolean"); + + b.Property("TsRotationId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.ToTable("SpotCardExchangeCatalog"); + }); + + modelBuilder.Entity("SVSim.Database.Models.StoryDeckEntry", b => + { + b.Property("Id") + .HasColumnType("integer"); + + b.Property("ClassId") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("DeckFormat") + .HasColumnType("integer"); + + b.Property("DeckName") + .IsRequired() + .HasColumnType("text"); + + b.Property("DeckNo") + .HasColumnType("integer"); + + b.Property("EntryNo") + .HasColumnType("integer"); + + b.Property("IsRecommend") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("integer"); + + b.Property("LeaderSkinId") + .HasColumnType("integer"); + + b.Property("OrderNum") + .HasColumnType("integer"); + + b.Property("SleeveId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("StoryDecks"); + }); + + modelBuilder.Entity("SVSim.Database.Models.TutorialPresentEntry", b => + { + b.Property("PresentId") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ItemType") + .HasColumnType("integer"); + + b.Property("Message") + .IsRequired() + .HasColumnType("text"); + + b.Property("RewardCount") + .HasColumnType("bigint"); + + b.Property("RewardDetailId") + .HasColumnType("bigint"); + + b.Property("RewardType") + .HasColumnType("integer"); + + b.HasKey("PresentId"); + + b.ToTable("TutorialPresentEntries"); + }); + + modelBuilder.Entity("SVSim.Database.Models.UnlimitedRestrictionEntry", b => + { + b.Property("Id") + .HasColumnType("bigint"); + + b.Property("CardId") + .HasColumnType("bigint"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("RestrictionValue") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("UnlimitedRestrictions"); + }); + + modelBuilder.Entity("SVSim.Database.Models.Viewer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnType("text"); + + b.Property("LastLogin") + .HasColumnType("timestamp with time zone"); + + b.Property("MyPageBgId") + .HasColumnType("integer"); + + b.Property("MyPageBgSelectType") + .HasColumnType("integer"); + + b.Property("ShortUdid") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasDefaultValueSql("nextval('\"ShortUdidSequence\"')"); + + NpgsqlPropertyBuilderExtensions.UseSequence(b.Property("ShortUdid"), "ShortUdidSequence"); + + b.Property("Udid") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ShortUdid"); + + b.HasIndex("Udid") + .IsUnique(); + + b.ToTable("Viewers"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerAchievement", b => + { + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.Property("AchievementType") + .HasColumnType("integer"); + + b.Property("AchievementStatus") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("NowAchievedLevel") + .HasColumnType("integer"); + + b.Property("ResultAnnounceSawLevel") + .HasColumnType("integer"); + + b.HasKey("ViewerId", "AchievementType"); + + b.ToTable("ViewerAchievements"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerAcquireHistoryEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AcquireTime") + .HasColumnType("timestamp with time zone"); + + b.Property("AcquireType") + .HasColumnType("integer"); + + b.Property("Message") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("RewardCount") + .HasColumnType("integer"); + + b.Property("RewardDetailId") + .HasColumnType("bigint"); + + b.Property("RewardType") + .HasColumnType("integer"); + + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ViewerId", "AcquireTime", "Id"); + + b.ToTable("ViewerAcquireHistory"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerArenaColosseumRun", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BattleCountThisRound") + .HasColumnType("integer"); + + b.Property("BreakthroughNumberThisRound") + .HasColumnType("integer"); + + b.Property("CandidateClassIdsJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("ChaosId") + .HasColumnType("integer"); + + b.Property("ClassId") + .HasColumnType("integer"); + + b.Property("ConsumeItemType") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeckFormat") + .HasColumnType("integer"); + + b.Property("EntryId") + .HasColumnType("bigint"); + + b.Property("IsChampion") + .HasColumnType("boolean"); + + b.Property("IsPublished") + .HasColumnType("boolean"); + + b.Property("IsRankMatching") + .HasColumnType("boolean"); + + b.Property("IsSelectCompleted") + .HasColumnType("boolean"); + + b.Property("LeaderSkinId") + .HasColumnType("bigint"); + + b.Property("LossCount") + .HasColumnType("integer"); + + b.Property("MaxBattleCountThisRound") + .HasColumnType("integer"); + + b.Property("NextCandidateId") + .HasColumnType("bigint"); + + b.Property("PendingPickSetsJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("RegisteredDeckNoListJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("RestEntryNum") + .HasColumnType("integer"); + + b.Property("ResultListJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("RoundId") + .HasColumnType("integer"); + + b.Property("SeasonId") + .HasColumnType("integer"); + + b.Property("SelectTurn") + .HasColumnType("integer"); + + b.Property("SelectedCardIdsJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.Property("WinCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ViewerId") + .IsUnique(); + + b.ToTable("ViewerArenaColosseumRuns"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerArenaTwoPickRun", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CandidateClassIdsJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("ChallengeId") + .HasColumnType("integer"); + + b.Property("ClassId") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("EntryId") + .HasColumnType("bigint"); + + b.Property("IsRetire") + .HasColumnType("boolean"); + + b.Property("IsSelectCompleted") + .HasColumnType("boolean"); + + b.Property("LeaderSkinId") + .HasColumnType("bigint"); + + b.Property("LossCount") + .HasColumnType("integer"); + + b.Property("MaxBattleCount") + .HasColumnType("integer"); + + b.Property("NextCandidateId") + .HasColumnType("bigint"); + + b.Property("PendingPickSetsJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("ResultListJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("RewardScheduleId") + .HasColumnType("integer"); + + b.Property("SelectTurn") + .HasColumnType("integer"); + + b.Property("SelectedCardIdsJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.Property("WinCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ViewerId") + .IsUnique(); + + b.ToTable("ViewerArenaTwoPickRuns"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerBattleHistory", b => + { + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.Property("BattleId") + .HasColumnType("bigint"); + + b.Property("BattleStartTime") + .HasColumnType("timestamp with time zone"); + + b.Property("BattleType") + .HasColumnType("integer"); + + b.Property("CreateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("DeckFormat") + .HasColumnType("integer"); + + b.Property("IsLimitTurn") + .HasColumnType("integer"); + + b.Property("IsWin") + .HasColumnType("boolean"); + + b.Property("OpponentCharaId") + .HasColumnType("integer"); + + b.Property("OpponentClassId") + .HasColumnType("integer"); + + b.Property("OpponentCountryCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("OpponentDegreeId") + .HasColumnType("bigint"); + + b.Property("OpponentEmblemId") + .HasColumnType("bigint"); + + b.Property("OpponentName") + .IsRequired() + .HasColumnType("text"); + + b.Property("OpponentRotationId") + .IsRequired() + .HasColumnType("text"); + + b.Property("OpponentSubClassId") + .HasColumnType("integer"); + + b.Property("SelfCharaId") + .HasColumnType("integer"); + + b.Property("SelfClassId") + .HasColumnType("integer"); + + b.Property("SelfRotationId") + .IsRequired() + .HasColumnType("text"); + + b.Property("SelfSubClassId") + .HasColumnType("integer"); + + b.Property("TwoPickType") + .HasColumnType("integer"); + + b.HasKey("ViewerId", "BattleId"); + + b.HasIndex("ViewerId", "CreateTime") + .HasDatabaseName("IX_ViewerBattleHistories_ViewerId_CreateTime"); + + b.ToTable("ViewerBattleHistories"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerBattlePassClaimEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("SeasonId") + .HasColumnType("integer"); + + b.Property("Track") + .HasColumnType("integer"); + + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ViewerId", "SeasonId"); + + b.HasIndex("ViewerId", "SeasonId", "Track", "Level") + .IsUnique(); + + b.ToTable("ViewerBattlePassClaims"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerBattlePassProgressEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CurrentPoint") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("IsPremium") + .HasColumnType("boolean"); + + b.Property("SeasonId") + .HasColumnType("integer"); + + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.Property("WeeklyPeriodStart") + .HasColumnType("timestamp with time zone"); + + b.Property("WeeklyPoints") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ViewerId", "SeasonId") + .IsUnique(); + + b.ToTable("ViewerBattlePassProgress"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerEventCounter", b => + { + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.Property("EventKey") + .HasColumnType("text"); + + b.Property("Period") + .HasColumnType("text"); + + b.Property("Count") + .HasColumnType("integer"); + + b.HasKey("ViewerId", "EventKey", "Period"); + + b.HasIndex("ViewerId", "Period"); + + b.ToTable("ViewerEventCounters"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerFriend", b => + { + b.Property("OwnerViewerId") + .HasColumnType("bigint"); + + b.Property("FriendViewerId") + .HasColumnType("bigint"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("OwnerViewerId", "FriendViewerId"); + + b.HasIndex("FriendViewerId"); + + b.HasIndex("OwnerViewerId", "CreatedAt"); + + b.ToTable("ViewerFriends"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerFriendApply", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("FromViewerId") + .HasColumnType("bigint"); + + b.Property("MissionType") + .HasColumnType("integer"); + + b.Property("ToViewerId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ToViewerId"); + + b.HasIndex("FromViewerId", "ToViewerId") + .IsUnique(); + + b.ToTable("ViewerFriendApplies"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerLeaderSkinSetClaim", b => + { + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.Property("SeriesId") + .HasColumnType("integer"); + + b.Property("ClaimedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("ViewerId", "SeriesId"); + + b.HasIndex("ViewerId"); + + b.ToTable("ViewerLeaderSkinSetClaims"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerMission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssignedAt") + .HasColumnType("bigint"); + + b.Property("ClaimedAt") + .HasColumnType("bigint"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("MissionCatalogId") + .HasColumnType("integer"); + + b.Property("MissionStatus") + .HasColumnType("integer"); + + b.Property("Slot") + .HasColumnType("integer"); + + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ViewerId"); + + b.HasIndex("ViewerId", "Slot") + .IsUnique(); + + b.ToTable("ViewerMissions"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerPlayedTogether", b => + { + b.Property("OwnerViewerId") + .HasColumnType("bigint"); + + b.Property("OpponentViewerId") + .HasColumnType("bigint"); + + b.Property("BattleType") + .HasColumnType("integer"); + + b.Property("DeckFormat") + .HasColumnType("integer"); + + b.Property("PlayedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("PlayedMode") + .HasColumnType("integer"); + + b.Property("TwoPickType") + .HasColumnType("integer"); + + b.HasKey("OwnerViewerId", "OpponentViewerId"); + + b.HasIndex("OwnerViewerId", "PlayedAt"); + + b.ToTable("ViewerPlayedTogethers"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerPresent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ConditionNumber") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ItemType") + .HasColumnType("integer"); + + b.Property("Message") + .IsRequired() + .HasColumnType("text"); + + b.Property("PresentId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("PresentLimitType") + .HasColumnType("integer"); + + b.Property("RewardCount") + .HasColumnType("bigint"); + + b.Property("RewardDetailId") + .HasColumnType("bigint"); + + b.Property("RewardLimitTime") + .HasColumnType("bigint"); + + b.Property("RewardType") + .HasColumnType("integer"); + + b.Property("Source") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ViewerId", "PresentId") + .IsUnique(); + + b.HasIndex("ViewerId", "Status", "CreatedAt"); + + b.ToTable("ViewerPresents"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerPuzzleClear", b => + { + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.Property("PuzzleId") + .HasColumnType("integer"); + + b.Property("BestRetryCount") + .HasColumnType("integer"); + + b.Property("ClearedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("ViewerId", "PuzzleId"); + + b.ToTable("ViewerPuzzleClears"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerSerialCodeRedemption", b => + { + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.Property("SerialCodeId") + .HasColumnType("integer"); + + b.Property("RedeemedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("ViewerId", "SerialCodeId"); + + b.HasIndex("SerialCodeId"); + + b.ToTable("ViewerSerialCodeRedemptions"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerSpotCardExchange", b => + { + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.Property("CardId") + .HasColumnType("bigint"); + + b.Property("ExchangedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("IsPreRelease") + .HasColumnType("boolean"); + + b.HasKey("ViewerId", "CardId"); + + b.HasIndex("ViewerId"); + + b.ToTable("ViewerSpotCardExchanges"); + }); + + modelBuilder.Entity("SleeveEntryViewer", b => + { + b.Property("SleevesId") + .HasColumnType("integer"); + + b.Property("ViewersId") + .HasColumnType("bigint"); + + b.HasKey("SleevesId", "ViewersId"); + + b.HasIndex("ViewersId"); + + b.ToTable("SleeveEntryViewer"); + }); + + modelBuilder.Entity("DegreeEntryViewer", b => + { + b.HasOne("SVSim.Database.Models.DegreeEntry", null) + .WithMany() + .HasForeignKey("DegreesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany() + .HasForeignKey("ViewersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("EmblemEntryViewer", b => + { + b.HasOne("SVSim.Database.Models.EmblemEntry", null) + .WithMany() + .HasForeignKey("EmblemsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany() + .HasForeignKey("ViewersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LeaderSkinEntryViewer", b => + { + b.HasOne("SVSim.Database.Models.LeaderSkinEntry", null) + .WithMany() + .HasForeignKey("LeaderSkinsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany() + .HasForeignKey("ViewersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MyPageBackgroundEntryViewer", b => + { + b.HasOne("SVSim.Database.Models.MyPageBackgroundEntry", null) + .WithMany() + .HasForeignKey("MyPageBackgroundsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany() + .HasForeignKey("ViewersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("SVSim.Database.Entities.Story.StoryChapter", b => + { + b.HasOne("SVSim.Database.Entities.Story.StorySection", "Section") + .WithMany() + .HasForeignKey("SectionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SVSim.Database.Entities.Story.SpecialBattleSetting", "SpecialBattleSetting") + .WithMany() + .HasForeignKey("SpecialBattleSettingId"); + + b.OwnsMany("SVSim.Database.Entities.Story.StoryChapterBattleSetting", "BattleSettings", b1 => + { + b1.Property("StoryId") + .HasColumnType("integer"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("Battle3dFieldIdOverride") + .HasColumnType("integer"); + + b1.Property("BgmIdOverride") + .HasColumnType("integer"); + + b1.Property("DeckClassId") + .HasColumnType("integer"); + + b1.Property("DeckSkinIdOverride") + .HasColumnType("integer"); + + b1.Property("EnemyEmotionOverride") + .HasColumnType("integer"); + + b1.Property("PlayerEmotionOverride") + .HasColumnType("integer"); + + b1.Property("SkinIdOverride") + .HasColumnType("integer"); + + b1.HasKey("StoryId", "Id"); + + b1.ToTable("StoryChapterBattleSetting"); + + b1.WithOwner() + .HasForeignKey("StoryId"); + }); + + b.OwnsMany("SVSim.Database.Entities.Story.StoryChapterReward", "Rewards", b1 => + { + b1.Property("StoryId") + .HasColumnType("integer"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("RewardDetailId") + .HasColumnType("bigint"); + + b1.Property("RewardNumber") + .HasColumnType("integer"); + + b1.Property("RewardType") + .HasColumnType("integer"); + + b1.HasKey("StoryId", "Id"); + + b1.ToTable("StoryChapterReward"); + + b1.WithOwner() + .HasForeignKey("StoryId"); + }); + + b.OwnsMany("SVSim.Database.Entities.Story.StorySubChapter", "SubChapters", b1 => + { + b1.Property("StoryId") + .HasColumnType("integer"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("IsMaintenanceChapter") + .HasColumnType("boolean"); + + b1.Property("SubChapterId") + .HasColumnType("integer"); + + b1.Property("SubChapterStoryId") + .HasColumnType("integer"); + + b1.HasKey("StoryId", "Id"); + + b1.ToTable("StorySubChapter"); + + b1.WithOwner() + .HasForeignKey("StoryId"); + }); + + b.Navigation("BattleSettings"); + + b.Navigation("Rewards"); + + b.Navigation("Section"); + + b.Navigation("SpecialBattleSetting"); + + b.Navigation("SubChapters"); + }); + + modelBuilder.Entity("SVSim.Database.Entities.Story.StorySection", b => + { + b.HasOne("SVSim.Database.Entities.Story.StoryWorld", "World") + .WithMany() + .HasForeignKey("WorldId"); + + b.Navigation("World"); + }); + + modelBuilder.Entity("SVSim.Database.Models.BattlePassRewardEntry", b => + { + b.HasOne("SVSim.Database.Models.BattlePassSeasonEntry", "Season") + .WithMany("Rewards") + .HasForeignKey("SeasonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Season"); + }); + + modelBuilder.Entity("SVSim.Database.Models.BuildDeckProductEntry", b => + { + b.HasOne("SVSim.Database.Models.BuildDeckSeriesEntry", "Series") + .WithMany("Products") + .HasForeignKey("SeriesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("SVSim.Database.Models.BuildDeckProductCardEntry", "Cards", b1 => + { + b1.Property("BuildDeckProductEntryId") + .HasColumnType("integer"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("CardId") + .HasColumnType("bigint"); + + b1.Property("IsSpot") + .HasColumnType("boolean"); + + b1.Property("Number") + .HasColumnType("integer"); + + b1.HasKey("BuildDeckProductEntryId", "Id"); + + b1.ToTable("BuildDeckProductCardEntry"); + + b1.WithOwner() + .HasForeignKey("BuildDeckProductEntryId"); + }); + + b.OwnsMany("SVSim.Database.Models.BuildDeckProductRewardEntry", "Rewards", b1 => + { + b1.Property("BuildDeckProductEntryId") + .HasColumnType("integer"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("MessageId") + .HasColumnType("integer"); + + b1.Property("RewardDetailId") + .HasColumnType("bigint"); + + b1.Property("RewardIndex") + .HasColumnType("integer"); + + b1.Property("RewardNumber") + .HasColumnType("integer"); + + b1.Property("RewardType") + .HasColumnType("integer"); + + b1.HasKey("BuildDeckProductEntryId", "Id"); + + b1.ToTable("BuildDeckProductRewardEntry"); + + b1.WithOwner() + .HasForeignKey("BuildDeckProductEntryId"); + }); + + b.Navigation("Cards"); + + b.Navigation("Rewards"); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("SVSim.Database.Models.BuildDeckSeriesEntry", b => + { + b.OwnsMany("SVSim.Database.Models.BuildDeckSeriesRewardEntry", "SeriesRewards", b1 => + { + b1.Property("BuildDeckSeriesEntryId") + .HasColumnType("integer"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("ItemIndex") + .HasColumnType("integer"); + + b1.Property("MessageId") + .HasColumnType("integer"); + + b1.Property("RewardDetailId") + .HasColumnType("bigint"); + + b1.Property("RewardNumber") + .HasColumnType("integer"); + + b1.Property("RewardType") + .HasColumnType("integer"); + + b1.Property("TierIndex") + .HasColumnType("integer"); + + b1.HasKey("BuildDeckSeriesEntryId", "Id"); + + b1.ToTable("BuildDeckSeriesRewardEntry"); + + b1.WithOwner() + .HasForeignKey("BuildDeckSeriesEntryId"); + }); + + b.Navigation("SeriesRewards"); + }); + + modelBuilder.Entity("SVSim.Database.Models.CardCosmeticReward", b => + { + b.HasOne("SVSim.Database.Models.ShadowverseCardEntry", "Card") + .WithMany() + .HasForeignKey("CardId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Card"); + }); + + modelBuilder.Entity("SVSim.Database.Models.LeaderSkinEntry", b => + { + b.HasOne("SVSim.Database.Models.ClassEntry", "Class") + .WithMany("LeaderSkins") + .HasForeignKey("ClassId"); + + b.Navigation("Class"); + }); + + modelBuilder.Entity("SVSim.Database.Models.LeaderSkinShopProductEntry", b => + { + b.HasOne("SVSim.Database.Models.LeaderSkinShopSeriesEntry", "Series") + .WithMany("Products") + .HasForeignKey("SeriesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("SVSim.Database.Models.LeaderSkinShopProductRewardEntry", "Rewards", b1 => + { + b1.Property("LeaderSkinShopProductEntryId") + .HasColumnType("integer"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("OrderIndex") + .HasColumnType("integer"); + + b1.Property("RewardDetailId") + .HasColumnType("bigint"); + + b1.Property("RewardNumber") + .HasColumnType("integer"); + + b1.Property("RewardType") + .HasColumnType("integer"); + + b1.HasKey("LeaderSkinShopProductEntryId", "Id"); + + b1.ToTable("LeaderSkinShopProductRewardEntry"); + + b1.WithOwner() + .HasForeignKey("LeaderSkinShopProductEntryId"); + }); + + b.Navigation("Rewards"); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("SVSim.Database.Models.LeaderSkinShopSeriesEntry", b => + { + b.OwnsMany("SVSim.Database.Models.LeaderSkinShopSeriesRewardEntry", "SetCompletionRewards", b1 => + { + b1.Property("LeaderSkinShopSeriesEntryId") + .HasColumnType("integer"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("OrderIndex") + .HasColumnType("integer"); + + b1.Property("RewardDetailId") + .HasColumnType("bigint"); + + b1.Property("RewardNumber") + .HasColumnType("integer"); + + b1.Property("RewardType") + .HasColumnType("integer"); + + b1.HasKey("LeaderSkinShopSeriesEntryId", "Id"); + + b1.ToTable("LeaderSkinShopSeriesRewardEntry"); + + b1.WithOwner() + .HasForeignKey("LeaderSkinShopSeriesEntryId"); + }); + + b.Navigation("SetCompletionRewards"); + }); + + modelBuilder.Entity("SVSim.Database.Models.PackConfigEntry", b => + { + b.OwnsMany("SVSim.Database.Models.PackBannerEntry", "Banners", b1 => + { + b1.Property("PackConfigEntryId") + .HasColumnType("integer"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("BannerName") + .IsRequired() + .HasColumnType("text"); + + b1.Property("DialogTitle") + .IsRequired() + .HasColumnType("text"); + + b1.HasKey("PackConfigEntryId", "Id"); + + b1.ToTable("PackBannerEntry"); + + b1.WithOwner() + .HasForeignKey("PackConfigEntryId"); + }); + + b.OwnsMany("SVSim.Database.Models.PackChildGachaEntry", "ChildGachas", b1 => + { + b1.Property("PackConfigEntryId") + .HasColumnType("integer"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("CampaignName") + .HasColumnType("text"); + + b1.Property("CardCount") + .HasColumnType("integer"); + + b1.Property("Cost") + .HasColumnType("integer"); + + b1.Property("DailyFreeGachaCount") + .HasColumnType("integer"); + + b1.Property("FreeGachaCampaignId") + .HasColumnType("integer"); + + b1.Property("GachaId") + .HasColumnType("integer"); + + b1.Property("IsDailySingle") + .HasColumnType("boolean"); + + b1.Property("ItemId") + .HasColumnType("bigint"); + + b1.Property("OverrideIncreaseGachaPoint") + .HasColumnType("integer"); + + b1.Property("PurchaseLimitCount") + .HasColumnType("integer"); + + b1.Property("TypeDetail") + .HasColumnType("integer"); + + b1.HasKey("PackConfigEntryId", "Id"); + + b1.ToTable("PackChildGachaEntry"); + + b1.WithOwner() + .HasForeignKey("PackConfigEntryId"); + }); + + b.OwnsOne("SVSim.Database.Models.PackGachaPointConfig", "GachaPointConfig", b1 => + { + b1.Property("PackConfigEntryId") + .HasColumnType("integer"); + + b1.Property("ExchangeablePoint") + .HasColumnType("integer"); + + b1.Property("IncreaseGachaPoint") + .HasColumnType("integer"); + + b1.HasKey("PackConfigEntryId"); + + b1.ToTable("Packs"); + + b1.WithOwner() + .HasForeignKey("PackConfigEntryId"); + }); + + b.Navigation("Banners"); + + b.Navigation("ChildGachas"); + + b.Navigation("GachaPointConfig"); + }); + + modelBuilder.Entity("SVSim.Database.Models.PuzzleEntry", b => + { + b.HasOne("SVSim.Database.Models.PuzzleGroupEntry", "Group") + .WithMany("Puzzles") + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("SVSim.Database.Models.SerialCodeRewardEntry", b => + { + b.HasOne("SVSim.Database.Models.SerialCodeEntry", null) + .WithMany("Rewards") + .HasForeignKey("SerialCodeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("SVSim.Database.Models.ShadowverseCardEntry", b => + { + b.HasOne("SVSim.Database.Models.ClassEntry", "Class") + .WithMany() + .HasForeignKey("ClassId"); + + b.HasOne("SVSim.Database.Models.ShadowverseCardSetEntry", null) + .WithMany("Cards") + .HasForeignKey("ShadowverseCardSetEntryId"); + + b.OwnsOne("SVSim.Database.Models.CardCollectionInfo", "CollectionInfo", b1 => + { + b1.Property("ShadowverseCardEntryId") + .HasColumnType("bigint"); + + b1.Property("CraftCost") + .HasColumnType("integer"); + + b1.Property("DustReward") + .HasColumnType("integer"); + + b1.HasKey("ShadowverseCardEntryId"); + + b1.ToTable("Cards"); + + b1.WithOwner() + .HasForeignKey("ShadowverseCardEntryId"); + }); + + b.Navigation("Class"); + + b.Navigation("CollectionInfo"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ShadowverseDeckEntry", b => + { + b.HasOne("SVSim.Database.Models.ClassEntry", "Class") + .WithMany() + .HasForeignKey("ClassId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SVSim.Database.Models.LeaderSkinEntry", "LeaderSkin") + .WithMany() + .HasForeignKey("LeaderSkinId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SVSim.Database.Models.SleeveEntry", "Sleeve") + .WithMany() + .HasForeignKey("SleeveId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany("Decks") + .HasForeignKey("ViewerId"); + + b.OwnsMany("SVSim.Database.Models.DeckCard", "Cards", b1 => + { + b1.Property("ShadowverseDeckEntryId") + .HasColumnType("uuid"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("CardId") + .HasColumnType("bigint"); + + b1.Property("Count") + .HasColumnType("integer"); + + b1.HasKey("ShadowverseDeckEntryId", "Id"); + + b1.HasIndex("CardId"); + + b1.ToTable("DeckCard"); + + b1.HasOne("SVSim.Database.Models.ShadowverseCardEntry", "Card") + .WithMany() + .HasForeignKey("CardId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.WithOwner() + .HasForeignKey("ShadowverseDeckEntryId"); + + b1.Navigation("Card"); + }); + + b.Navigation("Cards"); + + b.Navigation("Class"); + + b.Navigation("LeaderSkin"); + + b.Navigation("Sleeve"); + }); + + modelBuilder.Entity("SVSim.Database.Models.SleeveShopProductEntry", b => + { + b.HasOne("SVSim.Database.Models.SleeveShopSeriesEntry", "Series") + .WithMany("Products") + .HasForeignKey("SeriesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("SVSim.Database.Models.SleeveShopProductRewardEntry", "Rewards", b1 => + { + b1.Property("SleeveShopProductEntryId") + .HasColumnType("integer"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("OrderIndex") + .HasColumnType("integer"); + + b1.Property("RewardDetailId") + .HasColumnType("bigint"); + + b1.Property("RewardNumber") + .HasColumnType("integer"); + + b1.Property("RewardType") + .HasColumnType("integer"); + + b1.HasKey("SleeveShopProductEntryId", "Id"); + + b1.ToTable("SleeveShopProductRewardEntry"); + + b1.WithOwner() + .HasForeignKey("SleeveShopProductEntryId"); + }); + + b.Navigation("Rewards"); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("SVSim.Database.Models.Viewer", b => + { + b.OwnsMany("SVSim.Database.Models.MyPageBgRotationEntry", "MyPageBgRotation", b1 => + { + b1.Property("ViewerId") + .HasColumnType("bigint"); + + b1.Property("Slot") + .HasColumnType("integer"); + + b1.Property("BgId") + .HasColumnType("integer"); + + b1.HasKey("ViewerId", "Slot"); + + b1.ToTable("ViewerMyPageBgRotation", (string)null); + + b1.WithOwner() + .HasForeignKey("ViewerId"); + }); + + b.OwnsMany("SVSim.Database.Models.OwnedCardEntry", "Cards", b1 => + { + b1.Property("ViewerId") + .HasColumnType("bigint"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("CardId") + .HasColumnType("bigint"); + + b1.Property("Count") + .HasColumnType("integer"); + + b1.Property("IsProtected") + .HasColumnType("boolean"); + + b1.HasKey("ViewerId", "Id"); + + b1.HasIndex("CardId"); + + b1.HasIndex("ViewerId", "CardId") + .IsUnique(); + + b1.ToTable("OwnedCardEntry"); + + b1.HasOne("SVSim.Database.Models.ShadowverseCardEntry", "Card") + .WithMany() + .HasForeignKey("CardId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.WithOwner() + .HasForeignKey("ViewerId"); + + b1.Navigation("Card"); + }); + + b.OwnsMany("SVSim.Database.Models.OwnedItemEntry", "Items", b1 => + { + b1.Property("ViewerId") + .HasColumnType("bigint"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("Count") + .HasColumnType("integer"); + + b1.Property("ItemId") + .HasColumnType("integer"); + + b1.HasKey("ViewerId", "Id"); + + b1.HasIndex("ItemId"); + + b1.HasIndex("ViewerId", "ItemId") + .IsUnique(); + + b1.ToTable("OwnedItemEntry"); + + b1.HasOne("SVSim.Database.Models.ItemEntry", "Item") + .WithMany() + .HasForeignKey("ItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.WithOwner("Viewer") + .HasForeignKey("ViewerId"); + + b1.Navigation("Item"); + + b1.Navigation("Viewer"); + }); + + b.OwnsMany("SVSim.Database.Models.SocialAccountConnection", "SocialAccountConnections", b1 => + { + b1.Property("ViewerId") + .HasColumnType("bigint"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("AccountId") + .HasColumnType("numeric(20,0)"); + + b1.Property("AccountType") + .HasColumnType("integer"); + + b1.HasKey("ViewerId", "Id"); + + b1.HasIndex("AccountType", "AccountId") + .IsUnique(); + + b1.ToTable("SocialAccountConnection"); + + b1.WithOwner("Viewer") + .HasForeignKey("ViewerId"); + + b1.Navigation("Viewer"); + }); + + b.OwnsMany("SVSim.Database.Models.ViewerBuildDeckProductPurchase", "BuildDeckPurchases", b1 => + { + b1.Property("ViewerId") + .HasColumnType("bigint"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("ProductId") + .HasColumnType("integer"); + + b1.Property("PurchaseCount") + .HasColumnType("integer"); + + b1.HasKey("ViewerId", "Id"); + + b1.HasIndex("ViewerId", "ProductId") + .IsUnique(); + + b1.ToTable("ViewerBuildDeckProductPurchase"); + + b1.WithOwner() + .HasForeignKey("ViewerId"); + }); + + b.OwnsMany("SVSim.Database.Models.ViewerClassData", "Classes", b1 => + { + b1.Property("ViewerId") + .HasColumnType("bigint"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("ClassId") + .HasColumnType("integer"); + + b1.Property("Exp") + .HasColumnType("integer"); + + b1.Property("IsRandomLeaderSkin") + .HasColumnType("boolean"); + + b1.Property("LeaderSkinId") + .HasColumnType("integer"); + + b1.Property("Level") + .HasColumnType("integer"); + + b1.HasKey("ViewerId", "Id"); + + b1.HasIndex("ClassId"); + + b1.HasIndex("LeaderSkinId"); + + b1.ToTable("ViewerClassData"); + + b1.HasOne("SVSim.Database.Models.ClassEntry", "Class") + .WithMany() + .HasForeignKey("ClassId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.HasOne("SVSim.Database.Models.LeaderSkinEntry", "LeaderSkin") + .WithMany() + .HasForeignKey("LeaderSkinId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.WithOwner("Viewer") + .HasForeignKey("ViewerId"); + + b1.Navigation("Class"); + + b1.Navigation("LeaderSkin"); + + b1.Navigation("Viewer"); + }); + + b.OwnsOne("SVSim.Database.Models.ViewerCurrency", "Currency", b1 => + { + b1.Property("ViewerId") + .HasColumnType("bigint"); + + b1.Property("AndroidCrystals") + .HasColumnType("numeric(20,0)"); + + b1.Property("Crystals") + .HasColumnType("numeric(20,0)"); + + b1.Property("DmmCrystals") + .HasColumnType("numeric(20,0)"); + + b1.Property("FreeCrystals") + .HasColumnType("numeric(20,0)"); + + b1.Property("IosCrystals") + .HasColumnType("numeric(20,0)"); + + b1.Property("LifeTotalCrystals") + .HasColumnType("numeric(20,0)"); + + b1.Property("RedEther") + .HasColumnType("numeric(20,0)"); + + b1.Property("Rupees") + .HasColumnType("numeric(20,0)"); + + b1.Property("SpotPoints") + .HasColumnType("numeric(20,0)"); + + b1.Property("SteamCrystals") + .HasColumnType("numeric(20,0)"); + + b1.HasKey("ViewerId"); + + b1.ToTable("Viewers"); + + b1.WithOwner() + .HasForeignKey("ViewerId"); + }); + + b.OwnsMany("SVSim.Database.Models.ViewerFreePackClaim", "FreePackClaims", b1 => + { + b1.Property("ViewerId") + .HasColumnType("bigint"); + + b1.Property("FreeGachaCampaignId") + .HasColumnType("integer"); + + b1.Property("ClaimCount") + .HasColumnType("integer"); + + b1.Property("LastClaimedAt") + .HasColumnType("timestamp with time zone"); + + b1.HasKey("ViewerId", "FreeGachaCampaignId"); + + b1.ToTable("ViewerFreePackClaim"); + + b1.WithOwner() + .HasForeignKey("ViewerId"); + }); + + b.OwnsMany("SVSim.Database.Models.ViewerGachaPointBalance", "GachaPointBalances", b1 => + { + b1.Property("ViewerId") + .HasColumnType("bigint"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("PackId") + .HasColumnType("integer"); + + b1.Property("Points") + .HasColumnType("integer"); + + b1.HasKey("ViewerId", "Id"); + + b1.HasIndex("ViewerId", "PackId") + .IsUnique(); + + b1.ToTable("ViewerGachaPointBalance"); + + b1.WithOwner() + .HasForeignKey("ViewerId"); + }); + + b.OwnsMany("SVSim.Database.Models.ViewerGachaPointReceived", "GachaPointReceived", b1 => + { + b1.Property("ViewerId") + .HasColumnType("bigint"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("CardId") + .HasColumnType("bigint"); + + b1.Property("PackId") + .HasColumnType("integer"); + + b1.Property("ReceivedAt") + .HasColumnType("timestamp with time zone"); + + b1.HasKey("ViewerId", "Id"); + + b1.HasIndex("ViewerId", "PackId", "CardId") + .IsUnique(); + + b1.ToTable("ViewerGachaPointReceived"); + + b1.WithOwner() + .HasForeignKey("ViewerId"); + }); + + b.OwnsOne("SVSim.Database.Models.ViewerInfo", "Info", b1 => + { + b1.Property("ViewerId") + .HasColumnType("bigint"); + + b1.Property("BirthDate") + .HasColumnType("timestamp with time zone"); + + b1.Property("ChallengeTwoPickSleeveId") + .HasColumnType("bigint"); + + b1.Property("CountryCode") + .IsRequired() + .HasColumnType("text"); + + b1.Property("IsFoilPreferred") + .HasColumnType("boolean"); + + b1.Property("IsOfficial") + .HasColumnType("boolean"); + + b1.Property("IsOfficialMarkDisplayed") + .HasColumnType("boolean"); + + b1.Property("IsPrizePreferred") + .HasColumnType("boolean"); + + b1.Property("IsSkipGachaEffect") + .HasColumnType("boolean"); + + b1.Property("MaxFriends") + .HasColumnType("integer"); + + b1.Property("SelectedDegreeId") + .HasColumnType("integer"); + + b1.Property("SelectedEmblemId") + .HasColumnType("integer"); + + b1.Property("UseChallengeTwoPickPremiumCard") + .HasColumnType("boolean"); + + b1.HasKey("ViewerId"); + + b1.HasIndex("SelectedDegreeId"); + + b1.HasIndex("SelectedEmblemId"); + + b1.ToTable("Viewers"); + + b1.HasOne("SVSim.Database.Models.DegreeEntry", "SelectedDegree") + .WithMany() + .HasForeignKey("SelectedDegreeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.HasOne("SVSim.Database.Models.EmblemEntry", "SelectedEmblem") + .WithMany() + .HasForeignKey("SelectedEmblemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.WithOwner() + .HasForeignKey("ViewerId"); + + b1.Navigation("SelectedDegree"); + + b1.Navigation("SelectedEmblem"); + }); + + b.OwnsOne("SVSim.Database.Models.ViewerMissionData", "MissionData", b1 => + { + b1.Property("ViewerId") + .HasColumnType("bigint"); + + b1.Property("HasReceivedPickTwoMission") + .HasColumnType("boolean"); + + b1.Property("MissionChangeTime") + .HasColumnType("timestamp with time zone"); + + b1.Property("MissionReceiveType") + .HasColumnType("integer"); + + b1.Property("TutorialState") + .HasColumnType("integer"); + + b1.HasKey("ViewerId"); + + b1.ToTable("Viewers"); + + b1.WithOwner() + .HasForeignKey("ViewerId"); + }); + + b.OwnsMany("SVSim.Database.Models.ViewerPackOpenCount", "PackOpenCounts", b1 => + { + b1.Property("ViewerId") + .HasColumnType("bigint"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("LastDailyFreeAt") + .HasColumnType("timestamp with time zone"); + + b1.Property("OpenCount") + .HasColumnType("integer"); + + b1.Property("PackId") + .HasColumnType("integer"); + + b1.HasKey("ViewerId", "Id"); + + b1.ToTable("ViewerPackOpenCount"); + + b1.WithOwner() + .HasForeignKey("ViewerId"); + }); + + b.Navigation("BuildDeckPurchases"); + + b.Navigation("Cards"); + + b.Navigation("Classes"); + + b.Navigation("Currency") + .IsRequired(); + + b.Navigation("FreePackClaims"); + + b.Navigation("GachaPointBalances"); + + b.Navigation("GachaPointReceived"); + + b.Navigation("Info") + .IsRequired(); + + b.Navigation("Items"); + + b.Navigation("MissionData") + .IsRequired(); + + b.Navigation("MyPageBgRotation"); + + b.Navigation("PackOpenCounts"); + + b.Navigation("SocialAccountConnections"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerAchievement", b => + { + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany("Achievements") + .HasForeignKey("ViewerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerAcquireHistoryEntry", b => + { + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany() + .HasForeignKey("ViewerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerEventCounter", b => + { + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany("EventCounters") + .HasForeignKey("ViewerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerFriend", b => + { + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany() + .HasForeignKey("FriendViewerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany() + .HasForeignKey("OwnerViewerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerFriendApply", b => + { + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany() + .HasForeignKey("FromViewerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany() + .HasForeignKey("ToViewerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerMission", b => + { + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany("Missions") + .HasForeignKey("ViewerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerPlayedTogether", b => + { + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany() + .HasForeignKey("OwnerViewerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerPresent", b => + { + b.HasOne("SVSim.Database.Models.Viewer", "Viewer") + .WithMany() + .HasForeignKey("ViewerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Viewer"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ViewerSerialCodeRedemption", b => + { + b.HasOne("SVSim.Database.Models.SerialCodeEntry", null) + .WithMany() + .HasForeignKey("SerialCodeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany() + .HasForeignKey("ViewerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("SleeveEntryViewer", b => + { + b.HasOne("SVSim.Database.Models.SleeveEntry", null) + .WithMany() + .HasForeignKey("SleevesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SVSim.Database.Models.Viewer", null) + .WithMany() + .HasForeignKey("ViewersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("SVSim.Database.Models.BattlePassSeasonEntry", b => + { + b.Navigation("Rewards"); + }); + + modelBuilder.Entity("SVSim.Database.Models.BuildDeckSeriesEntry", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ClassEntry", b => + { + b.Navigation("LeaderSkins"); + }); + + modelBuilder.Entity("SVSim.Database.Models.LeaderSkinShopSeriesEntry", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("SVSim.Database.Models.PuzzleGroupEntry", b => + { + b.Navigation("Puzzles"); + }); + + modelBuilder.Entity("SVSim.Database.Models.SerialCodeEntry", b => + { + b.Navigation("Rewards"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ShadowverseCardSetEntry", b => + { + b.Navigation("Cards"); + }); + + modelBuilder.Entity("SVSim.Database.Models.SleeveShopSeriesEntry", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("SVSim.Database.Models.Viewer", b => + { + b.Navigation("Achievements"); + + b.Navigation("Decks"); + + b.Navigation("EventCounters"); + + b.Navigation("Missions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/SVSim.Database/Migrations/20260613164340_AddColosseumCuratedDecks.cs b/SVSim.Database/Migrations/20260613164340_AddColosseumCuratedDecks.cs new file mode 100644 index 00000000..0a68488d --- /dev/null +++ b/SVSim.Database/Migrations/20260613164340_AddColosseumCuratedDecks.cs @@ -0,0 +1,100 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace SVSim.Database.Migrations +{ + /// + public partial class AddColosseumCuratedDecks : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "ColosseumAvatarDecks", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + DeckNo = table.Column(type: "integer", nullable: false), + ClassId = table.Column(type: "integer", nullable: false), + CardListJson = table.Column(type: "jsonb", nullable: false), + SleeveId = table.Column(type: "bigint", nullable: false), + LeaderSkinId = table.Column(type: "bigint", nullable: false), + DisplayOrder = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ColosseumAvatarDecks", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "ColosseumHofDecks", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + DeckNo = table.Column(type: "integer", nullable: false), + ClassId = table.Column(type: "integer", nullable: false), + CardListJson = table.Column(type: "jsonb", nullable: false), + SleeveId = table.Column(type: "bigint", nullable: false), + LeaderSkinId = table.Column(type: "bigint", nullable: false), + DisplayOrder = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ColosseumHofDecks", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "ColosseumWindFallDecks", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + DeckNo = table.Column(type: "integer", nullable: false), + ClassId = table.Column(type: "integer", nullable: false), + CardListJson = table.Column(type: "jsonb", nullable: false), + SleeveId = table.Column(type: "bigint", nullable: false), + LeaderSkinId = table.Column(type: "bigint", nullable: false), + DisplayOrder = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ColosseumWindFallDecks", x => x.Id); + }); + + migrationBuilder.CreateIndex( + name: "IX_ColosseumAvatarDecks_DeckNo", + table: "ColosseumAvatarDecks", + column: "DeckNo", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_ColosseumHofDecks_DeckNo", + table: "ColosseumHofDecks", + column: "DeckNo", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_ColosseumWindFallDecks_DeckNo", + table: "ColosseumWindFallDecks", + column: "DeckNo", + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ColosseumAvatarDecks"); + + migrationBuilder.DropTable( + name: "ColosseumHofDecks"); + + migrationBuilder.DropTable( + name: "ColosseumWindFallDecks"); + } + } +} diff --git a/SVSim.Database/Migrations/SVSimDbContextModelSnapshot.cs b/SVSim.Database/Migrations/SVSimDbContextModelSnapshot.cs index 6108762a..91baefe9 100644 --- a/SVSim.Database/Migrations/SVSimDbContextModelSnapshot.cs +++ b/SVSim.Database/Migrations/SVSimDbContextModelSnapshot.cs @@ -970,6 +970,41 @@ namespace SVSim.Database.Migrations b.ToTable("ClassExpCurve"); }); + modelBuilder.Entity("SVSim.Database.Models.ColosseumAvatarDeck", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CardListJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("ClassId") + .HasColumnType("integer"); + + b.Property("DeckNo") + .HasColumnType("integer"); + + b.Property("DisplayOrder") + .HasColumnType("integer"); + + b.Property("LeaderSkinId") + .HasColumnType("bigint"); + + b.Property("SleeveId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("DeckNo") + .IsUnique(); + + b.ToTable("ColosseumAvatarDecks"); + }); + modelBuilder.Entity("SVSim.Database.Models.ColosseumConfig", b => { b.Property("Id") @@ -1041,6 +1076,76 @@ namespace SVSim.Database.Migrations b.ToTable("Colosseums"); }); + modelBuilder.Entity("SVSim.Database.Models.ColosseumHofDeck", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CardListJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("ClassId") + .HasColumnType("integer"); + + b.Property("DeckNo") + .HasColumnType("integer"); + + b.Property("DisplayOrder") + .HasColumnType("integer"); + + b.Property("LeaderSkinId") + .HasColumnType("bigint"); + + b.Property("SleeveId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("DeckNo") + .IsUnique(); + + b.ToTable("ColosseumHofDecks"); + }); + + modelBuilder.Entity("SVSim.Database.Models.ColosseumWindFallDeck", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CardListJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("ClassId") + .HasColumnType("integer"); + + b.Property("DeckNo") + .HasColumnType("integer"); + + b.Property("DisplayOrder") + .HasColumnType("integer"); + + b.Property("LeaderSkinId") + .HasColumnType("bigint"); + + b.Property("SleeveId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("DeckNo") + .IsUnique(); + + b.ToTable("ColosseumWindFallDecks"); + }); + modelBuilder.Entity("SVSim.Database.Models.DailyLoginBonusEntry", b => { b.Property("Id") @@ -2766,6 +2871,111 @@ namespace SVSim.Database.Migrations b.ToTable("ViewerAcquireHistory"); }); + modelBuilder.Entity("SVSim.Database.Models.ViewerArenaColosseumRun", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BattleCountThisRound") + .HasColumnType("integer"); + + b.Property("BreakthroughNumberThisRound") + .HasColumnType("integer"); + + b.Property("CandidateClassIdsJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("ChaosId") + .HasColumnType("integer"); + + b.Property("ClassId") + .HasColumnType("integer"); + + b.Property("ConsumeItemType") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeckFormat") + .HasColumnType("integer"); + + b.Property("EntryId") + .HasColumnType("bigint"); + + b.Property("IsChampion") + .HasColumnType("boolean"); + + b.Property("IsPublished") + .HasColumnType("boolean"); + + b.Property("IsRankMatching") + .HasColumnType("boolean"); + + b.Property("IsSelectCompleted") + .HasColumnType("boolean"); + + b.Property("LeaderSkinId") + .HasColumnType("bigint"); + + b.Property("LossCount") + .HasColumnType("integer"); + + b.Property("MaxBattleCountThisRound") + .HasColumnType("integer"); + + b.Property("NextCandidateId") + .HasColumnType("bigint"); + + b.Property("PendingPickSetsJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("RegisteredDeckNoListJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("RestEntryNum") + .HasColumnType("integer"); + + b.Property("ResultListJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("RoundId") + .HasColumnType("integer"); + + b.Property("SeasonId") + .HasColumnType("integer"); + + b.Property("SelectTurn") + .HasColumnType("integer"); + + b.Property("SelectedCardIdsJson") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ViewerId") + .HasColumnType("bigint"); + + b.Property("WinCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ViewerId") + .IsUnique(); + + b.ToTable("ViewerArenaColosseumRuns"); + }); + modelBuilder.Entity("SVSim.Database.Models.ViewerArenaTwoPickRun", b => { b.Property("Id") diff --git a/SVSim.Database/Models/ColosseumAvatarDeck.cs b/SVSim.Database/Models/ColosseumAvatarDeck.cs new file mode 100644 index 00000000..c5a02ba3 --- /dev/null +++ b/SVSim.Database/Models/ColosseumAvatarDeck.cs @@ -0,0 +1,21 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace SVSim.Database.Models; + +/// +/// Curated Avatar (themed-character) deck for Arena Colosseum. See +/// for the rationale on the duplicated schema. +/// +public class ColosseumAvatarDeck : IColosseumCuratedDeck +{ + public long Id { get; set; } + public int DeckNo { get; set; } + public int ClassId { get; set; } + + [Column(TypeName = "jsonb")] + public string CardListJson { get; set; } = "[]"; + + public long SleeveId { get; set; } + public long LeaderSkinId { get; set; } + public int DisplayOrder { get; set; } +} diff --git a/SVSim.Database/Models/ColosseumHofDeck.cs b/SVSim.Database/Models/ColosseumHofDeck.cs new file mode 100644 index 00000000..7ca2099a --- /dev/null +++ b/SVSim.Database/Models/ColosseumHofDeck.cs @@ -0,0 +1,23 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace SVSim.Database.Models; + +/// +/// Curated Hall-of-Fame deck pool for Arena Colosseum. Identical schema to +/// and — separate +/// tables instead of an enum-discriminated shared one because the operational lifecycle +/// (per-pool importer, per-pool register endpoint, per-pool query) is independent. +/// +public class ColosseumHofDeck : IColosseumCuratedDeck +{ + public long Id { get; set; } + public int DeckNo { get; set; } + public int ClassId { get; set; } + + [Column(TypeName = "jsonb")] + public string CardListJson { get; set; } = "[]"; + + public long SleeveId { get; set; } + public long LeaderSkinId { get; set; } + public int DisplayOrder { get; set; } +} diff --git a/SVSim.Database/Models/ColosseumWindFallDeck.cs b/SVSim.Database/Models/ColosseumWindFallDeck.cs new file mode 100644 index 00000000..2c446912 --- /dev/null +++ b/SVSim.Database/Models/ColosseumWindFallDeck.cs @@ -0,0 +1,21 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace SVSim.Database.Models; + +/// +/// Curated WindFall (limited-pool wildcard) deck for Arena Colosseum. See +/// for the rationale on the duplicated schema. +/// +public class ColosseumWindFallDeck : IColosseumCuratedDeck +{ + public long Id { get; set; } + public int DeckNo { get; set; } + public int ClassId { get; set; } + + [Column(TypeName = "jsonb")] + public string CardListJson { get; set; } = "[]"; + + public long SleeveId { get; set; } + public long LeaderSkinId { get; set; } + public int DisplayOrder { get; set; } +} diff --git a/SVSim.Database/Models/Config/ColosseumRoundsConfig.cs b/SVSim.Database/Models/Config/ColosseumRoundsConfig.cs new file mode 100644 index 00000000..c0744070 --- /dev/null +++ b/SVSim.Database/Models/Config/ColosseumRoundsConfig.cs @@ -0,0 +1,75 @@ +using SVSim.Database.Enums; + +namespace SVSim.Database.Models.Config; + +/// +/// The 3-round bracket schedule for an active Colosseum season — and the per-round +/// reward bundles paid out by /finish + /retire. Empty +/// is the default shipped state — lobby /event_info renders a benign payload with +/// no rounds active. Collection default is in per +/// feedback_config_defaults (property-initializer collection defaults silently empty out +/// under the tier merge). +/// +[ConfigSection("ColosseumRounds")] +public class ColosseumRoundsConfig +{ + public List Rounds { get; set; } = new(); + + /// Champion-only reward bundle, paid alongside the final round's FinishRewards + /// when ColosseumProgressionService determines the viewer cleared the bracket. + public List ChampionRewards { get; set; } = new(); + + public static ColosseumRoundsConfig ShippedDefaults() => new() + { + Rounds = new(), + ChampionRewards = new(), + }; + + public class RoundEntry + { + /// 1, 2, or 3 in the canonical 3-round schedule. + public int RoundId { get; set; } + + public DateTime StartTime { get; set; } + public DateTime EndTime { get; set; } + + /// Bracket groups within the round (e.g. distinct breakthrough thresholds + /// for late-joiners). The first entry is the canonical lookup used by + /// ColosseumProgressionService for the v1 single-bracket case. + public List Groups { get; set; } = new(); + + /// Paid by /finish when the viewer clears or otherwise ends this round + /// successfully. Empty = no bonus for this round. + public List FinishRewards { get; set; } = new(); + + /// Paid by /retire when the viewer abandons mid-round. Client ignores + /// these once run.RoundId >= FinalB, but server still emits them per + /// retire.md (log completeness). + public List RetireRewards { get; set; } = new(); + } + + public class GroupEntry + { + public string Group { get; set; } = ""; + + /// Max battles a viewer can play in this round before bracket termination. + public int MaxBattleCount { get; set; } + + /// Wins required to promote out of this round. + public int BreakthroughNumber { get; set; } + + /// Total bracket entries allotted to this group. + public int EntryNumber { get; set; } + } + + public class RewardEntry + { + public UserGoodsType Type { get; set; } + public long DetailId { get; set; } + public int Count { get; set; } + + /// Display name for the rewards[] receipt block. Defaults to empty; + /// client uses system-text lookups when blank. + public string Name { get; set; } = ""; + } +} diff --git a/SVSim.Database/Models/Config/ColosseumSeasonConfig.cs b/SVSim.Database/Models/Config/ColosseumSeasonConfig.cs new file mode 100644 index 00000000..4c3caddc --- /dev/null +++ b/SVSim.Database/Models/Config/ColosseumSeasonConfig.cs @@ -0,0 +1,68 @@ +using SVSim.Database.Enums; + +namespace SVSim.Database.Models.Config; + +/// +/// Event-level configuration for an active Arena Colosseum (Grand Prix) season. Default +/// emits IsColosseumPeriod = false so the lobby read +/// endpoints render an empty "no event scheduled" payload without crashing the client. +/// Flipping the event on is an admin operation per +/// docs/operations/grand-prix-event-setup.md — write a row to GameConfigs. +/// +[ConfigSection("ColosseumSeason")] +public class ColosseumSeasonConfig +{ + /// Master gate. false = lobby reads render an empty info block and + /// entry rejects. The client (Wizard/ColosseumEntryInfoTask.cs) reads this and + /// skips parsing the rest of the colosseum_info object. + public bool IsColosseumPeriod { get; set; } + + /// Stamped onto every at entry time. + public int SeasonId { get; set; } + + public string ColosseumName { get; set; } = ""; + + /// Bracket format. Stamped onto the run at entry time. + public Format DeckFormat { get; set; } = Format.Rotation; + + /// Server stores bool; the wire shape is the STRING "0"/"1" per Wizard/ColosseumEntryInfoTask.cs's + /// jsonData.ToString() == "1" parse. The response DTO converts at serialization time. + public bool IsNormalTwoPick { get; set; } + + /// Wire string used by the client as a theme/color code. Empty when not in special mode. + public string IsSpecialMode { get; set; } = ""; + + public string? AnnounceId { get; set; } + + public DateTime EventStartTime { get; set; } + public DateTime EventEndTime { get; set; } + + /// How many bracket entries get eliminated in the final round before champion-determination. + public int FinalRoundEliminateCount { get; set; } + + public string CardPoolName { get; set; } = ""; + + /// Card-set ids used as the 2-Pick / Chaos draft pool override for this season. + /// Phase 3 reads this through ArenaTwoPickCardPoolService instead of + /// ChallengeConfig.PoolCardSetIds. + public List PoolCardSetIds { get; set; } = new(); + + public int RupyCost { get; set; } + public int TicketCost { get; set; } + public int CrystalCost { get; set; } + + public bool IsAllowedFreeEntry { get; set; } + + public bool IsAllCardEnabled { get; set; } + + /// Number of strategies offered per pick in 2-Pick Chaos mode. + public int StrategyPickNum { get; set; } + + public DateTime SalesPeriodStart { get; set; } + public DateTime SalesPeriodEnd { get; set; } + + public static ColosseumSeasonConfig ShippedDefaults() => new() + { + IsColosseumPeriod = false, + }; +} diff --git a/SVSim.Database/Models/IColosseumCuratedDeck.cs b/SVSim.Database/Models/IColosseumCuratedDeck.cs new file mode 100644 index 00000000..83d15eba --- /dev/null +++ b/SVSim.Database/Models/IColosseumCuratedDeck.cs @@ -0,0 +1,17 @@ +namespace SVSim.Database.Models; + +/// +/// Common shape across the three curated-deck pool tables — used by the controller's +/// generic list+register dispatcher (Phase 3 Task 10) to avoid duplicating identical code +/// per pool. The interface is plumbing only; the pools stay distinct EF entity types. +/// +public interface IColosseumCuratedDeck +{ + long Id { get; set; } + int DeckNo { get; set; } + int ClassId { get; set; } + string CardListJson { get; set; } + long SleeveId { get; set; } + long LeaderSkinId { get; set; } + int DisplayOrder { get; set; } +} diff --git a/SVSim.Database/Models/ViewerArenaColosseumRun.cs b/SVSim.Database/Models/ViewerArenaColosseumRun.cs new file mode 100644 index 00000000..7778ba86 --- /dev/null +++ b/SVSim.Database/Models/ViewerArenaColosseumRun.cs @@ -0,0 +1,105 @@ +using System.ComponentModel.DataAnnotations.Schema; +using Microsoft.EntityFrameworkCore; +using SVSim.Database.Enums; + +namespace SVSim.Database.Models; + +/// +/// One active Grand Prix (Arena Colosseum) bracket run per viewer. Mirrors +/// in shape so the 2-Pick draft state machine can be +/// lifted onto it in Phase 3 — the schema is the union of constructed-mode lifecycle +/// (registered decks, bracket counts, rank-match promotion flag) and TK2-style draft +/// state. Standalone (not a Viewer owned collection) per +/// project_ef_nav_include_pitfall, with a unique index on ViewerId to enforce +/// "one active run per viewer". Row is deleted on /finish or /retire. +/// +[Index(nameof(ViewerId), IsUnique = true)] +public class ViewerArenaColosseumRun +{ + public long Id { get; set; } + + public long ViewerId { get; set; } + + /// Wire entry_info.id. Set to on insert. + public long EntryId { get; set; } + + /// Stamped from at entry time so + /// mid-run season-config edits don't shift the run's identity. + public int SeasonId { get; set; } + + /// Current bracket round (1..3 in the canonical 3-round schedule). Indexes + /// at entry time, advances on bracket + /// promotion via ColosseumProgressionService. + public int RoundId { get; set; } + + /// Format the bracket plays in (Rotation/Unlimited/TwoPick/HOF/WindFall/Avatar/...). + /// Stamped from season config at entry time. + public Format DeckFormat { get; set; } + + public long LeaderSkinId { get; set; } + + /// eARENA_PAY: 1 = ticket, 2 = crystal, 3 = rupy, 0 = free entry. Stamped at entry. + public int ConsumeItemType { get; set; } + + // --- 2-Pick / Chaos draft state (lifted from ViewerArenaTwoPickRun for Phase 3) --- + + [Column(TypeName = "jsonb")] + public string CandidateClassIdsJson { get; set; } = "[]"; + + /// Stored as 0 in constructed mode (no draft turn machinery). + public int SelectTurn { get; set; } + + public bool IsSelectCompleted { get; set; } + + [Column(TypeName = "jsonb")] + public string SelectedCardIdsJson { get; set; } = "[]"; + + [Column(TypeName = "jsonb")] + public string PendingPickSetsJson { get; set; } = "[]"; + + /// Monotonic counter for CandidatePair.Id; advances by 2 each draft turn. + public long NextCandidateId { get; set; } = 1; + + /// Selected class for 2-Pick / Chaos modes; 0 in constructed mode. + public int ClassId { get; set; } + + /// Optional Chaos sub-mode replay id. 0 when not in Chaos. + public int ChaosId { get; set; } + + // --- Per-round bracket state --- + + [Column(TypeName = "jsonb")] + public string ResultListJson { get; set; } = "[]"; + + public int WinCount { get; set; } + public int LossCount { get; set; } + public int BattleCountThisRound { get; set; } + + /// Cap copied from the matching ColosseumRoundsConfig.Rounds[RoundId-1].Groups[0] + /// at entry — stamped so mid-run round-config edits don't shift the cap. + public int MaxBattleCountThisRound { get; set; } + + /// Wins required to break through to the next round. Same stamping rule as + /// . + public int BreakthroughNumberThisRound { get; set; } + + /// Remaining attempts in the current entry. Decremented per battle finish until + /// 0 or breakthrough. + public int RestEntryNum { get; set; } + + /// Flipped exactly once when the node signals matching_state == 3008. + /// Subsequent battle URLs use the colosseum_rank_battle/* prefix. + public bool IsRankMatching { get; set; } + + public bool IsChampion { get; set; } + + // --- Registered deck slot (constructed mode) --- + + [Column(TypeName = "jsonb")] + public string RegisteredDeckNoListJson { get; set; } = "[]"; + + public bool IsPublished { get; set; } + + public DateTime CreatedAt { get; set; } + public DateTime UpdatedAt { get; set; } +} diff --git a/SVSim.Database/Repositories/Viewer/ArenaColosseumRunRepository.cs b/SVSim.Database/Repositories/Viewer/ArenaColosseumRunRepository.cs new file mode 100644 index 00000000..cb048f59 --- /dev/null +++ b/SVSim.Database/Repositories/Viewer/ArenaColosseumRunRepository.cs @@ -0,0 +1,36 @@ +using Microsoft.EntityFrameworkCore; +using SVSim.Database.Models; + +namespace SVSim.Database.Repositories.Viewer; + +public class ArenaColosseumRunRepository : IArenaColosseumRunRepository +{ + private readonly SVSimDbContext _db; + public ArenaColosseumRunRepository(SVSimDbContext db) => _db = db; + + public Task GetByViewerIdAsync(long viewerId) => + _db.ViewerArenaColosseumRuns.FirstOrDefaultAsync(r => r.ViewerId == viewerId); + + public async Task UpsertAsync(ViewerArenaColosseumRun run) + { + run.UpdatedAt = DateTime.UtcNow; + if (run.Id == 0) + { + run.CreatedAt = DateTime.UtcNow; + _db.ViewerArenaColosseumRuns.Add(run); + } + else + { + _db.ViewerArenaColosseumRuns.Update(run); + } + await _db.SaveChangesAsync(); + } + + public async Task DeleteAsync(long viewerId) + { + var row = await _db.ViewerArenaColosseumRuns.FirstOrDefaultAsync(r => r.ViewerId == viewerId); + if (row is null) return; + _db.ViewerArenaColosseumRuns.Remove(row); + await _db.SaveChangesAsync(); + } +} diff --git a/SVSim.Database/Repositories/Viewer/IArenaColosseumRunRepository.cs b/SVSim.Database/Repositories/Viewer/IArenaColosseumRunRepository.cs new file mode 100644 index 00000000..9184d146 --- /dev/null +++ b/SVSim.Database/Repositories/Viewer/IArenaColosseumRunRepository.cs @@ -0,0 +1,10 @@ +using SVSim.Database.Models; + +namespace SVSim.Database.Repositories.Viewer; + +public interface IArenaColosseumRunRepository +{ + Task GetByViewerIdAsync(long viewerId); + Task UpsertAsync(ViewerArenaColosseumRun run); + Task DeleteAsync(long viewerId); +} diff --git a/SVSim.Database/SVSimDbContext.cs b/SVSim.Database/SVSimDbContext.cs index e065dbf6..a4bacc7d 100644 --- a/SVSim.Database/SVSimDbContext.cs +++ b/SVSim.Database/SVSimDbContext.cs @@ -107,6 +107,10 @@ public class SVSimDbContext : DbContext public DbSet ArenaTwoPickRewards { get; set; } = null!; public DbSet ViewerArenaTwoPickRuns { get; set; } = null!; + public DbSet ViewerArenaColosseumRuns { get; set; } = null!; + public DbSet ColosseumHofDecks { get; set; } = null!; + public DbSet ColosseumWindFallDecks { get; set; } = null!; + public DbSet ColosseumAvatarDecks { get; set; } = null!; public DbSet SerialCodes => Set(); public DbSet SerialCodeRewards => Set(); @@ -496,6 +500,12 @@ public class SVSimDbContext : DbContext b.Property(e => e.OpponentRotationId).IsRequired(); }); + // Colosseum curated-deck pools — DeckNo is the wire identifier admins reference in + // register endpoints; uniqueness per pool is the contract clients rely on. + modelBuilder.Entity().HasIndex(d => d.DeckNo).IsUnique(); + modelBuilder.Entity().HasIndex(d => d.DeckNo).IsUnique(); + modelBuilder.Entity().HasIndex(d => d.DeckNo).IsUnique(); + base.OnModelCreating(modelBuilder); } diff --git a/SVSim.EmulatedEntrypoint/Controllers/ArenaColosseumBattleController.cs b/SVSim.EmulatedEntrypoint/Controllers/ArenaColosseumBattleController.cs new file mode 100644 index 00000000..12762dc4 --- /dev/null +++ b/SVSim.EmulatedEntrypoint/Controllers/ArenaColosseumBattleController.cs @@ -0,0 +1,175 @@ +using System.Text.Json; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using SVSim.BattleNode.Bridge; +using SVSim.Database.Repositories.Viewer; +using SVSim.EmulatedEntrypoint.Constants; +using SVSim.EmulatedEntrypoint.Matching; +using SVSim.EmulatedEntrypoint.Models.Dtos.ArenaColosseum; +using SVSim.EmulatedEntrypoint.Security; +using SVSim.EmulatedEntrypoint.Security.SteamSessionAuthentication; +using SVSim.EmulatedEntrypoint.Services; +using SVSim.EmulatedEntrypoint.Services.ArenaColosseum; + +namespace SVSim.EmulatedEntrypoint.Controllers; + +/// +/// Per-match URLs for the Colosseum bracket — the dual colosseum_battle/* + +/// colosseum_rank_battle/* route family. Does NOT extend 's +/// [Route("[controller]")] because we need explicit absolute routes for two prefixes +/// off one controller (same pattern as ). +/// +/// The URL is the bracket-phase signal per do-matching.md §"server-side bidirectional +/// mapping"; flips to true once the +/// node has signalled matching_state == 3008 on a prior do_matching. +/// +/// +[ApiController] +[Authorize(AuthenticationSchemes = SteamAuthenticationConstants.SchemeName)] +public sealed class ArenaColosseumBattleController : ControllerBase +{ + /// Per FinishTaskBase.IsEffectiveErrorCode — code 3502 ("battle already finished") + /// is tolerated as a non-error retry, parsed the same as 1. + private const int BattleAlreadyFinishedResultCode = 3502; + + private readonly IMatchContextBuilder _ctxBuilder; + private readonly IMatchingResolver _resolver; + private readonly IArenaColosseumRunRepository _runs; + private readonly IColosseumProgressionService _progression; + private readonly ILogger _log; + + public ArenaColosseumBattleController( + IMatchContextBuilder ctxBuilder, + IMatchingResolver resolver, + IArenaColosseumRunRepository runs, + IColosseumProgressionService progression, + ILogger log) + { + _ctxBuilder = ctxBuilder; + _resolver = resolver; + _runs = runs; + _progression = progression; + _log = log; + } + + private bool TryGetViewerId(out long viewerId) + { + viewerId = 0; + var claim = User.Claims.FirstOrDefault(c => c.Type == ShadowverseClaimTypes.ViewerIdClaim)?.Value; + return claim is not null && long.TryParse(claim, out viewerId); + } + + [HttpPost("/colosseum_battle/do_matching")] + public Task DoMatchingPreRank( + [FromBody] ColosseumDoMatchingRequestDto req, CancellationToken ct) + => DoMatchingInternal(isRankUrl: false, req, ct); + + [HttpPost("/colosseum_rank_battle/do_matching")] + public Task DoMatchingPostRank( + [FromBody] ColosseumDoMatchingRequestDto req, CancellationToken ct) + => DoMatchingInternal(isRankUrl: true, req, ct); + + [HttpPost("/colosseum_battle/finish")] + public Task FinishPreRank( + [FromBody] ColosseumBattleFinishRequestDto req, CancellationToken ct) + => FinishInternal(isRankUrl: false, req, ct); + + [HttpPost("/colosseum_rank_battle/finish")] + public Task FinishPostRank( + [FromBody] ColosseumBattleFinishRequestDto req, CancellationToken ct) + => FinishInternal(isRankUrl: true, req, ct); + + private async Task DoMatchingInternal( + bool isRankUrl, ColosseumDoMatchingRequestDto req, CancellationToken ct) + { + if (!TryGetViewerId(out var vid)) return Unauthorized(); + + var run = await _runs.GetByViewerIdAsync(vid); + if (run is null) + { + return BadRequest(new { error = "arena_colosseum_no_active_run" }); + } + if (isRankUrl != run.IsRankMatching) + { + return BadRequest(new + { + error = "colosseum_url_phase_mismatch", + is_rank_matching = run.IsRankMatching, + requested_rank_url = isRankUrl, + }); + } + + MatchContext ctx; + try + { + ctx = await _ctxBuilder.BuildForColosseumAsync(vid); + } + catch (InvalidOperationException ex) + { + _log.LogWarning(ex, + "Colosseum BuildForColosseumAsync failed for viewer {Vid}; returning 3001.", vid); + return Ok(new Models.Dtos.FreeBattle.DoMatchingResponseDto + { + MatchingState = 3001, + NodeServerUrl = "", + }); + } + + var mode = isRankUrl ? "colosseum_rank_battle" : "colosseum_battle"; + var resolution = await _resolver.ResolveAsync(mode, new BattlePlayer(vid, ctx), ct); + + // Promotion: server flips IsRankMatching once on the 3008 signal. Subsequent battle + // URLs must use the rank prefix. (Plan §"matching_state == 3008 is the promotion trigger".) + if (_progression.ShouldPromoteToRankMatching(run, resolution.MatchingState)) + { + run.IsRankMatching = true; + await _runs.UpsertAsync(run); + } + + return Ok(new Models.Dtos.FreeBattle.DoMatchingResponseDto + { + MatchingState = resolution.MatchingState, + BattleId = resolution.BattleId, + NodeServerUrl = resolution.NodeServerUrl, + }); + } + + private async Task FinishInternal( + bool isRankUrl, ColosseumBattleFinishRequestDto req, CancellationToken ct) + { + if (!TryGetViewerId(out var vid)) return Unauthorized(); + + var run = await _runs.GetByViewerIdAsync(vid); + if (run is null) + { + return BadRequest(new { error = "arena_colosseum_no_active_run" }); + } + + // Match-result tracking: 1 = win, 2 = loss, 0 = draw/abort. Record_list mirrors + // ColosseumTopTask.battle_results.result_list (1=win, 0=loss). is_retire surfaces + // as a non-counted result — does not advance the bracket. + bool counts = req.IsRetire == 0; + if (counts) + { + bool isWin = req.BattleResult == 1; + run.BattleCountThisRound += 1; + if (isWin) run.WinCount += 1; + else run.LossCount += 1; + + var resultList = ParseIntList(run.ResultListJson); + resultList.Add(isWin ? 1 : 0); + run.ResultListJson = JsonSerializer.Serialize(resultList); + await _runs.UpsertAsync(run); + } + + // result_code 3502 ("battle already finished") is the idempotent-retry tolerance per + // FinishTaskBase.IsEffectiveErrorCode. Server emits standard data; the translation + // middleware sets the wire result_code via data_headers from the response envelope. + return Ok(new ColosseumBattleFinishResponseDto { BattleResult = req.BattleResult }); + } + + private static List ParseIntList(string json) => + string.IsNullOrEmpty(json) + ? new() + : JsonSerializer.Deserialize>(json) ?? new(); +} diff --git a/SVSim.EmulatedEntrypoint/Controllers/ArenaColosseumController.cs b/SVSim.EmulatedEntrypoint/Controllers/ArenaColosseumController.cs index 1c7029d4..44c9d59b 100644 --- a/SVSim.EmulatedEntrypoint/Controllers/ArenaColosseumController.cs +++ b/SVSim.EmulatedEntrypoint/Controllers/ArenaColosseumController.cs @@ -1,22 +1,767 @@ +using System.Text.Json; using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using SVSim.Database; +using SVSim.Database.Enums; +using SVSim.Database.Models; +using SVSim.Database.Models.Config; +using SVSim.Database.Repositories.Deck; +using SVSim.Database.Repositories.Viewer; +using SVSim.Database.Services; +using SVSim.Database.Services.Inventory; +using SVSim.EmulatedEntrypoint.Models.Dtos.ArenaColosseum; +using SVSim.EmulatedEntrypoint.Models.Dtos.Common.ArenaTwoPick; +using SVSim.EmulatedEntrypoint.Models.Dtos.Requests; using SVSim.EmulatedEntrypoint.Models.Dtos.Requests.ArenaColosseum; using SVSim.EmulatedEntrypoint.Models.Dtos.Responses.ArenaColosseum; +using SVSim.EmulatedEntrypoint.Services; +using SVSim.EmulatedEntrypoint.Services.ArenaColosseum; namespace SVSim.EmulatedEntrypoint.Controllers; /// -/// Stub controller for the Colosseum arena family. Currently only emits a "no Colosseum -/// period" /get_fee_info response so the home/arena screen doesn't 404. The full Colosseum -/// flow (top, entry, register_deck, event_info, retire, finish, class_choose, card_choose, -/// matchmaking) is deferred — see Wizard/ColosseumEntryInfoTask.cs for the parser surface. +/// Arena Colosseum (Grand Prix) lobby. Phase 1 covers the three read endpoints (/top, +/// /get_fee_info, /event_info) plus the entry/register-deck pair. Defaults to +/// "no event scheduled" via — flipping +/// the event on is an admin operation per docs/operations/grand-prix-event-setup.md. /// [Route("arena_colosseum")] public class ArenaColosseumController : SVSimController { + private readonly IGameConfigService _config; + private readonly IArenaColosseumRunRepository _runs; + private readonly IInventoryService _inventory; + private readonly IDeckRepository _decks; + private readonly IColosseumProgressionService _progression; + private readonly IArenaTwoPickCardPoolService _pool; + private readonly IRandom _rng; + private readonly SVSimDbContext _db; + + public ArenaColosseumController( + IGameConfigService config, + IArenaColosseumRunRepository runs, + IInventoryService inventory, + IDeckRepository decks, + IColosseumProgressionService progression, + IArenaTwoPickCardPoolService pool, + IRandom rng, + SVSimDbContext db) + { + _config = config; + _runs = runs; + _inventory = inventory; + _decks = decks; + _progression = progression; + _pool = pool; + _rng = rng; + _db = db; + } + + [HttpPost("top")] + public async Task Top([FromBody] BaseRequest _) + { + if (!TryGetViewerId(out var vid)) return Unauthorized(); + + var season = _config.Get(); + var run = await _runs.GetByViewerIdAsync(vid); + + var response = new TopResponse + { + ColosseumInfo = BuildColosseumInfo(season), + ColosseumStatus = BuildOwnStatus(run), + LeaderSkinId = run?.LeaderSkinId ?? 0, + }; + + if (run is not null) + { + response.EntryInfo = new ColosseumEntryRef { Id = run.EntryId }; + response.NowRoundId = run.RoundId; + response.MaxBattleCount = run.MaxBattleCountThisRound; + response.IsFinish = run.IsChampion; + response.FinalRoundEliminateCount = season.FinalRoundEliminateCount; + response.EndTime = FormatTime(season.EventEndTime); + response.BattleResults = new ColosseumBattleResults + { + WinCount = run.WinCount, + ResultList = ParseIntList(run.ResultListJson), + }; + response.BreakthroughNumber = run.BreakthroughNumberThisRound > 0 ? run.BreakthroughNumberThisRound : null; + } + + return Ok(response); + } + [HttpPost("get_fee_info")] - public IActionResult GetFeeInfo([FromBody] GetFeeInfoRequest req) + public async Task GetFeeInfo([FromBody] BaseRequest _) + { + if (!TryGetViewerId(out var vid)) return Unauthorized(); + + var season = _config.Get(); + var run = await _runs.GetByViewerIdAsync(vid); + + var response = new GetFeeInfoResponseDto + { + ColosseumInfo = BuildColosseumInfo(season), + ColosseumStatus = BuildOwnStatus(run), + }; + + if (!season.IsColosseumPeriod) + { + return Ok(response); + } + + response.IsUnfinishedEntryExists = run is not null; + response.IsAllowedFreeEntry = season.IsAllowedFreeEntry; + response.FeeList = new ColosseumFeeList + { + RupyCost = season.RupyCost, + TicketCost = season.TicketCost, + CrystalCost = season.CrystalCost, + }; + + if (run is not null) + { + response.DeckFormat = (int)run.DeckFormat; + } + + return Ok(response); + } + + [HttpPost("event_info")] + public async Task EventInfo([FromBody] BaseRequest _) + { + if (!TryGetViewerId(out var vid)) return Unauthorized(); + + var season = _config.Get(); + var rounds = _config.Get(); + var run = await _runs.GetByViewerIdAsync(vid); + + return Ok(new EventInfoResponse + { + ColosseumInfo = new ColosseumEventInfo + { + Format = (int)season.DeckFormat, + StartTime = FormatTime(season.EventStartTime), + EndTime = FormatTime(season.EventEndTime), + AnnounceId = season.AnnounceId, + FinalRoundEliminateCount = season.FinalRoundEliminateCount, + }, + Round1 = BuildRoundDetail(rounds, 1), + Round2 = BuildRoundDetail(rounds, 2), + Round3 = BuildRoundDetail(rounds, 3), + ColosseumStatus = BuildOwnStatus(run), + }); + } + + [HttpPost("entry")] + public async Task Entry([FromBody] ArenaColosseumEntryRequest req) + { + if (!TryGetViewerId(out var vid)) return Unauthorized(); + + var season = _config.Get(); + if (!season.IsColosseumPeriod) + { + return BadRequest(new { error = "colosseum_period_closed" }); + } + + var serverRoundId = ResolveServerRoundId(season); + if (req.NowRoundId != serverRoundId) + { + return BadRequest(new { error = "now_round_id_mismatch", server_round_id = serverRoundId }); + } + + if (await _runs.GetByViewerIdAsync(vid) is not null) + { + return BadRequest(new { error = "arena_colosseum_already_in_progress" }); + } + + await using var tx = await _inventory.BeginAsync(vid); + + RewardEntryDto? feeEntry = req.ConsumeItemType switch + { + 1 => await DebitCrystalAsync(tx, season.CrystalCost), + 3 => await DebitTicketAsync(tx, season.TicketCost), + 4 => await DebitRupyAsync(tx, season.RupyCost), + 5 when season.IsAllowedFreeEntry => null, + _ => throw new InvalidOperationException($"invalid consume_item_type {req.ConsumeItemType}"), + }; + + var rounds = _config.Get(); + var roundConfig = rounds.Rounds.FirstOrDefault(r => r.RoundId == serverRoundId); + var group = roundConfig?.Groups.FirstOrDefault(); + + var run = new ViewerArenaColosseumRun + { + ViewerId = vid, + EntryId = 0, + SeasonId = season.SeasonId, + RoundId = serverRoundId, + DeckFormat = season.DeckFormat, + LeaderSkinId = 0, + ConsumeItemType = req.ConsumeItemType, + MaxBattleCountThisRound = group?.MaxBattleCount ?? 0, + BreakthroughNumberThisRound = group?.BreakthroughNumber ?? 0, + RestEntryNum = 0, + }; + await _runs.UpsertAsync(run); + run.EntryId = run.Id; + await _runs.UpsertAsync(run); + await tx.CommitAsync(); + + return Ok(new EntryResponse + { + RewardList = feeEntry is null ? new() : new() { feeEntry }, + EntryInfo = new ColosseumEntryRef + { + Id = run.EntryId, + DeckFormat = (int)season.DeckFormat, + }, + }); + } + + [HttpPost("register_deck")] + public async Task RegisterDeck([FromBody] ArenaColosseumRegisterDeckRequest req) + { + if (!TryGetViewerId(out var vid)) return Unauthorized(); + + var run = await _runs.GetByViewerIdAsync(vid); + if (run is null) + { + return BadRequest(new { error = "no_active_run" }); + } + + List deckNos; + try + { + deckNos = JsonSerializer.Deserialize>(req.DeckNoList) ?? new(); + } + catch (JsonException) + { + return BadRequest(new { error = "deck_no_list_malformed" }); + } + + if (deckNos.Count == 0) + { + return BadRequest(new { error = "deck_no_list_empty" }); + } + + // GetDeck filters by (viewerId, format, deckNo) — a slot that exists under a different + // format returns null here, which is the format-mismatch case from the spec. + foreach (var no in deckNos) + { + var deck = await _decks.GetDeck(vid, run.DeckFormat, no); + if (deck is null) + { + return BadRequest(new { error = "deck_not_found", deck_no = no }); + } + } + + run.RegisteredDeckNoListJson = JsonSerializer.Serialize(deckNos); + run.IsPublished = req.IsPublished; + await _runs.UpsertAsync(run); + + return Ok(new { }); + } + + [HttpPost("finish")] + public async Task Finish([FromBody] BaseRequest _) + { + if (!TryGetViewerId(out var vid)) return Unauthorized(); + var run = await _runs.GetByViewerIdAsync(vid); + if (run is null) return BadRequest(new { error = "no_active_run" }); + + var rounds = _config.Get(); + var decision = _progression.DecideAdvancement(run, rounds); + if (!decision.IsBracketEnd) + { + return BadRequest(new { error = "bracket_not_finished" }); + } + + run.IsChampion = decision.IsChampion; + var rewardEntries = _progression.BuildFinishRewards(run, rounds); + var (wireRewards, wireRewardList) = await GrantRewardsAsync(vid, rewardEntries); + + await _runs.DeleteAsync(vid); + + return Ok(new FinishResponse + { + Rewards = wireRewards, + RewardList = wireRewardList, + ColosseumStatus = new ColosseumOwnStatus + { + NowRoundId = run.RoundId, + IsChampion = decision.IsChampion ? true : null, + ColosseumName = decision.IsChampion ? rounds.Rounds.Count > 0 + ? _config.Get().ColosseumName + : null : null, + }, + }); + } + + [HttpPost("get_candidate_classes")] + public async Task GetCandidateClasses([FromBody] BaseRequest _) + { + if (!TryGetViewerId(out var vid)) return Unauthorized(); + var run = await _runs.GetByViewerIdAsync(vid); + if (run is null) return BadRequest(new { error = "no_active_run" }); + + // No persistent slate yet — sample 3 from the configured allow-list per + // ArenaTwoPickConfig.AllowedClassIds. Idempotent re-call gets a fresh slate; the + // spec says "logged server-side so re-calling is idempotent" — Phase 3 v1 doesn't + // yet persist the slate (the slate stamps in on /class_choose). + var aCfg = _config.Get(); + if (aCfg.AllowedClassIds.Count < 3) + { + return BadRequest(new { error = "arena_two_pick_allowed_class_ids_misconfigured" }); + } + + var sampled = aCfg.AllowedClassIds + .OrderBy(_ => _rng.Next(int.MaxValue)) + .Take(3) + .ToList(); + + // Persist onto the run so /class_choose can validate the pick. + run.CandidateClassIdsJson = JsonSerializer.Serialize(sampled); + await _runs.UpsertAsync(run); + + // v1 emits Normal-mode shape only (per plan §"Defer Chaos until live capture lands"). + // Server still ACCEPTS chaos_id on /class_choose for forward compatibility. + return Ok(new GetCandidateClassesResponse + { + ClassId1 = sampled[0], + ClassId2 = sampled[1], + ClassId3 = sampled[2], + }); + } + + [HttpPost("class_choose")] + public async Task ClassChoose([FromBody] ArenaColosseumClassChooseRequest req) + { + if (!TryGetViewerId(out var vid)) return Unauthorized(); + var run = await _runs.GetByViewerIdAsync(vid); + if (run is null) return BadRequest(new { error = "no_active_run" }); + if (run.ClassId != 0) return BadRequest(new { error = "arena_colosseum_invalid_state" }); + + // Mutually-exclusive request shape per class-choose.md. + bool isNormal = req.ClassId != 0 && req.ChaosId == 0; + bool isChaos = req.ChaosId != 0 && req.ClassId == 0; + if (!isNormal && !isChaos) + { + return BadRequest(new { error = "class_choose_requires_class_id_xor_chaos_id" }); + } + + var candidates = JsonSerializer.Deserialize>(run.CandidateClassIdsJson) ?? new(); + int chosenClassId = isNormal ? req.ClassId : ResolveChaosClassId(req.ChaosId); + if (isNormal && !candidates.Contains(chosenClassId)) + { + return BadRequest(new { error = "arena_colosseum_class_not_offered" }); + } + + run.ClassId = chosenClassId; + run.ChaosId = isChaos ? req.ChaosId : 0; + run.LeaderSkinId = chosenClassId; // class-default skin convention from TwoPick + + var pool = _config.Get().PoolCardSetIds; + var pairs = _pool.GeneratePickSetsForTurn( + chosenClassId, turn: 1, startingPairId: run.NextCandidateId, _rng, poolCardSetIds: pool); + run.NextCandidateId += pairs.Count; + run.SelectTurn = 1; + run.PendingPickSetsJson = JsonSerializer.Serialize(pairs); + await _runs.UpsertAsync(run); + + return Ok(new SVSim.EmulatedEntrypoint.Models.Dtos.Responses.ArenaTwoPick.ClassChooseResponseDto + { + ClassInfo = ProjectClassInfo(run), + DeckInfo = ProjectDeckInfo(run), + CandidateCardList = pairs.Select(ToDto).ToList(), + }); + } + + [HttpPost("get_candidate_cards")] + public async Task GetCandidateCards([FromBody] BaseRequest _) + { + if (!TryGetViewerId(out var vid)) return Unauthorized(); + var run = await _runs.GetByViewerIdAsync(vid); + if (run is null) return BadRequest(new { error = "no_active_run" }); + + // Idempotent resume — no state mutation here, just replay the current snapshot. + var pending = JsonSerializer.Deserialize>(run.PendingPickSetsJson) ?? new(); + return Ok(new GetCandidateCardsResponse + { + DeckInfo = ProjectDeckInfo(run), + CandidateCardList = pending.Select(ToDto).ToList(), + LeaderSkinId = run.LeaderSkinId == 0 ? null : run.LeaderSkinId, + ClassInfo = ProjectClassInfo(run), + }); + } + + [HttpPost("card_choose")] + public async Task CardChoose([FromBody] ArenaColosseumCardChooseRequest req) + { + if (!TryGetViewerId(out var vid)) return Unauthorized(); + var run = await _runs.GetByViewerIdAsync(vid); + if (run is null) return BadRequest(new { error = "no_active_run" }); + if (run.ClassId == 0 || run.IsSelectCompleted) + return BadRequest(new { error = "arena_colosseum_invalid_state" }); + + var pending = JsonSerializer.Deserialize>(run.PendingPickSetsJson) ?? new(); + var pick = pending.FirstOrDefault(p => p.Id == req.SelectedId); + if (pick is null) + return BadRequest(new { error = "arena_colosseum_invalid_selection" }); + + var selectedCards = JsonSerializer.Deserialize>(run.SelectedCardIdsJson) ?? new(); + selectedCards.Add(pick.CardId1); + selectedCards.Add(pick.CardId2); + run.SelectedCardIdsJson = JsonSerializer.Serialize(selectedCards); + + List? nextPairs = null; + if (run.SelectTurn < 15) + { + run.SelectTurn += 1; + var pool = _config.Get().PoolCardSetIds; + nextPairs = _pool.GeneratePickSetsForTurn( + run.ClassId, run.SelectTurn, run.NextCandidateId, _rng, poolCardSetIds: pool); + run.NextCandidateId += nextPairs.Count; + run.PendingPickSetsJson = JsonSerializer.Serialize(nextPairs); + } + else + { + run.IsSelectCompleted = true; + run.PendingPickSetsJson = "[]"; + } + await _runs.UpsertAsync(run); + + return Ok(new SVSim.EmulatedEntrypoint.Models.Dtos.Responses.ArenaTwoPick.CardChooseResponseDto + { + DeckInfo = ProjectDeckInfo(run), + CandidateCardList = nextPairs?.Select(ToDto).ToList(), + }); + } + + [HttpPost("get_hof_deck_list")] + public Task GetHofDeckList([FromBody] BaseRequest _) => + GetCuratedListAsync(); + + [HttpPost("get_windfall_deck_list")] + public Task GetWindFallDeckList([FromBody] BaseRequest _) => + GetCuratedListAsync(); + + [HttpPost("get_avatar_deck_list")] + public Task GetAvatarDeckList([FromBody] BaseRequest _) => + GetCuratedListAsync(); + + [HttpPost("register_hof_deck")] + public Task RegisterHofDeck([FromBody] RegisterCuratedDeckRequest req) => + RegisterCuratedAsync(req); + + [HttpPost("register_windfall_deck")] + public Task RegisterWindFallDeck([FromBody] RegisterCuratedDeckRequest req) => + RegisterCuratedAsync(req); + + [HttpPost("register_avatar_deck")] + public Task RegisterAvatarDeck([FromBody] RegisterCuratedDeckRequest req) => + RegisterCuratedAsync(req); + + /// + /// Shared list dispatcher for the three curated-deck pools. Wire shape: bare array at + /// data per get-curated-deck-list.md (NOT a wrapper object — client iterates + /// ResponseData["data"] directly). + /// + private async Task GetCuratedListAsync() + where TEntity : class, IColosseumCuratedDeck { if (!TryGetViewerId(out _)) return Unauthorized(); - return Ok(new GetFeeInfoResponseDto()); + + var rows = await _db.Set().AsNoTracking() + .OrderBy(d => d.DisplayOrder).ThenBy(d => d.DeckNo) + .ToListAsync(); + + var entries = rows.Select(r => new ColosseumCuratedDeckEntry + { + DeckId = r.DeckNo, + ClassId = r.ClassId, + CardList = JsonSerializer.Deserialize>(r.CardListJson) ?? new(), + SleeveId = r.SleeveId == 0 ? null : r.SleeveId, + SkinId = r.LeaderSkinId == 0 ? null : r.LeaderSkinId, + }).ToList(); + + return Ok(entries); } + + /// + /// Shared register dispatcher — validates each deck_no_list entry exists in the + /// pool table for (cross-pool register is rejected via + /// the per-pool lookup). Persists onto the active run, NO is_published flag here + /// — that's constructed-format-only per register-curated-deck.md. + /// + private async Task RegisterCuratedAsync(RegisterCuratedDeckRequest req) + where TEntity : class, IColosseumCuratedDeck + { + if (!TryGetViewerId(out var vid)) return Unauthorized(); + + var run = await _runs.GetByViewerIdAsync(vid); + if (run is null) return BadRequest(new { error = "no_active_run" }); + + List deckNos; + try + { + deckNos = JsonSerializer.Deserialize>(req.DeckNoList) ?? new(); + } + catch (JsonException) + { + return BadRequest(new { error = "deck_no_list_malformed" }); + } + + if (deckNos.Count == 0) + { + return BadRequest(new { error = "deck_no_list_empty" }); + } + + var set = _db.Set(); + foreach (var no in deckNos) + { + // Per-pool lookup — registering an HOF deck_no against /register_windfall_deck + // resolves to null here and rejects (cross-pool isolation). + var found = await set.AnyAsync(d => d.DeckNo == no); + if (!found) + { + return BadRequest(new { error = "deck_not_found", deck_no = no }); + } + } + + run.RegisteredDeckNoListJson = JsonSerializer.Serialize(deckNos); + // Curated-register has no is_published flag; clear any prior value to keep state + // consistent if the viewer switches from constructed to curated mid-bracket. + run.IsPublished = false; + await _runs.UpsertAsync(run); + + return Ok(new { }); + } + + /// v1 placeholder — Phase 3 §"Defer Chaos until live capture lands". Chaos + /// chara ids map to a class via prod data (e.g. via a ChaosInfoMap). Until that lands, + /// fall back to the chaos id mod 8 + 1 to keep the pool service happy. Real impl reads + /// from ColosseumChaosConfig once captured. + private static int ResolveChaosClassId(int chaosId) => ((chaosId - 1) % 8) + 1; + + private static SVSim.EmulatedEntrypoint.Models.Dtos.Common.ArenaTwoPick.CandidatePairDto + ToDto(CandidatePair p) => new() + { + Id = p.Id, Turn = p.Turn, SetNum = p.SetNum, + CardId1 = p.CardId1, CardId2 = p.CardId2, + IsSelected = p.IsSelected ? 1 : 0, + }; + + private static SVSim.EmulatedEntrypoint.Models.Dtos.Common.ArenaTwoPick.ClassInfoDto + ProjectClassInfo(ViewerArenaColosseumRun run) + { + var ids = JsonSerializer.Deserialize>(run.CandidateClassIdsJson) ?? new(); + return new() + { + ClassId1 = ids.ElementAtOrDefault(0), + ClassId2 = ids.ElementAtOrDefault(1), + ClassId3 = ids.ElementAtOrDefault(2), + SelectedClassId = run.ClassId, + }; + } + + private static SVSim.EmulatedEntrypoint.Models.Dtos.Common.ArenaTwoPick.DeckInfoDto + ProjectDeckInfo(ViewerArenaColosseumRun run) + { + var cards = JsonSerializer.Deserialize>(run.SelectedCardIdsJson) ?? new(); + return new() + { + TwoPickEntryId = run.EntryId, + ClassId = run.ClassId, + IsSelectCompleted = run.IsSelectCompleted, + SelectedCardIds = cards, + SelectTurn = run.SelectTurn == 0 ? 1 : run.SelectTurn, + }; + } + + [HttpPost("retire")] + public async Task Retire([FromBody] BaseRequest _) + { + if (!TryGetViewerId(out var vid)) return Unauthorized(); + var run = await _runs.GetByViewerIdAsync(vid); + if (run is null) return BadRequest(new { error = "no_active_run" }); + + var rounds = _config.Get(); + var rewardEntries = _progression.BuildRetireRewards(run, rounds); + var (wireRewards, wireRewardList) = await GrantRewardsAsync(vid, rewardEntries); + + await _runs.DeleteAsync(vid); + + return Ok(new FinishResponse + { + Rewards = wireRewards, + RewardList = wireRewardList, + ColosseumStatus = new ColosseumOwnStatus + { + NowRoundId = run.RoundId, + RestEntryNum = 0, + }, + }); + } + + /// + /// Grant the bundle through IInventoryTransaction.GrantAsync per + /// feedback_reward_grant_service — single dispatch table for every UserGoodsType. + /// Returns the two wire forms (rich rewards receipt + wallet-delta reward_list). + /// + private async Task<(List, List)> GrantRewardsAsync( + long viewerId, IReadOnlyList bundle) + { + var receipts = new List(); + var deltas = new List(); + if (bundle.Count == 0) return (receipts, deltas); + + await using var tx = await _inventory.BeginAsync(viewerId); + foreach (var entry in bundle) + { + var granted = await tx.GrantAsync(entry.Type, entry.DetailId, entry.Count); + receipts.Add(new ColosseumReceivedReward + { + RewardNumber = entry.Count, + RewardType = (int)entry.Type, + RewardDetailId = entry.DetailId, + Name = entry.Name, + }); + // GrantAsync returns one or more (RewardType, RewardId, RewardNum) tuples — the + // post-state-total semantics are owned by the inventory commit, which the wallet-delta + // reflection inherits via tx.CommitAsync below. + var first = granted.FirstOrDefault(); + deltas.Add(new RewardEntryDto + { + RewardType = first is null ? (int)entry.Type : (int)first.RewardType, + RewardId = first?.RewardId ?? entry.DetailId, + RewardNum = first?.RewardNum ?? entry.Count, + }); + } + await tx.CommitAsync(); + return (receipts, deltas); + } + + private static int ResolveServerRoundId(ColosseumSeasonConfig season) => 1; + + private async Task DebitCrystalAsync(IInventoryTransaction tx, int cost) + { + var result = await tx.TrySpendAsync(SpendCurrency.Crystal, cost); + if (!result.Success) + throw new InvalidOperationException("insufficient_crystal"); + return new RewardEntryDto + { + RewardType = (int)UserGoodsType.Crystal, + RewardId = 0, + RewardNum = (int)result.PostStateTotal, + }; + } + + private async Task DebitRupyAsync(IInventoryTransaction tx, int cost) + { + var result = await tx.TrySpendAsync(SpendCurrency.Rupee, cost); + if (!result.Success) + throw new InvalidOperationException("insufficient_rupy"); + return new RewardEntryDto + { + RewardType = (int)UserGoodsType.Rupy, + RewardId = 0, + RewardNum = (int)result.PostStateTotal, + }; + } + + private async Task DebitTicketAsync(IInventoryTransaction tx, int cost) + { + // Colosseum's ticket id is server-internal — using ArenaTwoPick's TicketItemId convention + // (item id 1) until a per-season override is captured. + const int ticketItemId = 1; + var result = await tx.TryDebitAsync(UserGoodsType.Item, ticketItemId, cost); + if (!result.Success) + throw new InvalidOperationException("insufficient_ticket"); + return new RewardEntryDto + { + RewardType = (int)UserGoodsType.Item, + RewardId = ticketItemId, + RewardNum = (int)result.PostStateTotal, + }; + } + + // --- helpers --- + + private static ColosseumLobbyInfo BuildColosseumInfo(ColosseumSeasonConfig season) + { + if (!season.IsColosseumPeriod) + { + return new ColosseumLobbyInfo { IsColosseumPeriod = false }; + } + + return new ColosseumLobbyInfo + { + IsColosseumPeriod = true, + DeckFormat = (int)season.DeckFormat, + IsNormalTwoPick = season.IsNormalTwoPick ? "1" : "0", + ColosseumName = season.ColosseumName, + IsRoundPeriod = true, + IsSpecialMode = season.IsSpecialMode, + CardPoolName = string.IsNullOrEmpty(season.CardPoolName) ? null : season.CardPoolName, + NowRound = 1, + StartTime = FormatTime(season.EventStartTime), + EndTime = FormatTime(season.EventEndTime), + IsAllCardEnabled = season.IsAllCardEnabled ? 1 : 0, + SalesPeriodInfo = new SVSim.EmulatedEntrypoint.Models.Dtos.ColosseumSalesPeriodInfo + { + SalesPeriodTime = FormatTime(season.SalesPeriodEnd), + }, + StrategyPickNum = season.StrategyPickNum > 0 ? season.StrategyPickNum : null, + }; + } + + /// Builds the colosseum_status block. When the viewer has no run, every + /// property is null and global WhenWritingNull renders {} — the client + /// (SetColosseumOwnStatus) short-circuits on status.Count == 0. + private static ColosseumOwnStatus BuildOwnStatus(ViewerArenaColosseumRun? run) + { + if (run is null) return new ColosseumOwnStatus(); + + return new ColosseumOwnStatus + { + RestEntryNum = run.RestEntryNum, + NowRoundId = run.RoundId, + IsChampion = run.IsChampion ? true : null, + }; + } + + private static ColosseumRoundDetail BuildRoundDetail(ColosseumRoundsConfig rounds, int roundId) + { + var match = rounds.Rounds.FirstOrDefault(r => r.RoundId == roundId); + if (match is null) return new ColosseumRoundDetail(); + + return new ColosseumRoundDetail + { + StartTime = FormatTime(match.StartTime), + EndTime = FormatTime(match.EndTime), + IsNowRound = IsNowRound(match), + RoundDetail = match.Groups.Select(g => new ColosseumGroupRow + { + Group = g.Group, + MaxBattleCount = g.MaxBattleCount, + BreakthroughNumber = g.BreakthroughNumber, + EntryNumber = g.EntryNumber, + }).ToList(), + }; + } + + private static bool IsNowRound(ColosseumRoundsConfig.RoundEntry round) + { + var now = DateTime.UtcNow; + return now >= round.StartTime && now <= round.EndTime; + } + + private static string FormatTime(DateTime t) => + t == default ? "" : t.ToString("yyyy-MM-dd HH:mm:ss"); + + private static List ParseIntList(string json) => + string.IsNullOrEmpty(json) + ? new() + : System.Text.Json.JsonSerializer.Deserialize>(json) ?? new(); } diff --git a/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/BattleDoMatchingRequestDto.cs b/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/BattleDoMatchingRequestDto.cs new file mode 100644 index 00000000..447d06d7 --- /dev/null +++ b/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/BattleDoMatchingRequestDto.cs @@ -0,0 +1,33 @@ +using System.Text.Json.Serialization; +using MessagePack; +using SVSim.EmulatedEntrypoint.Models.Dtos.Requests; + +namespace SVSim.EmulatedEntrypoint.Models.Dtos.ArenaColosseum; + +/// +/// POST /colosseum_battle/do_matching + POST /colosseum_rank_battle/do_matching. +/// Standard DoMatchingParam wire shape — same fields as rank/free-battle's variant. +/// Per do-matching.md, post-promotion the client forces need_init = 0, but the +/// server tolerates either value (URL is the routing signal). +/// +[MessagePackObject] +public sealed class ColosseumDoMatchingRequestDto : BaseRequest +{ + [JsonPropertyName("need_init")] [Key("need_init")] + public int NeedInit { get; set; } + + [JsonPropertyName("card_master_hash")] [Key("card_master_hash")] + public string? CardMasterHash { get; set; } + + [JsonPropertyName("log")] [Key("log")] + public int Log { get; set; } + + [JsonPropertyName("use_stage_select")] [Key("use_stage_select")] + public int UseStageSelect { get; set; } + + [JsonPropertyName("excluded_field_id_list")] [Key("excluded_field_id_list")] + public List ExcludedFieldIdList { get; set; } = new(); + + [JsonPropertyName("is_default_skin")] [Key("is_default_skin")] + public int IsDefaultSkin { get; set; } +} diff --git a/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/BattleFinishRequestDto.cs b/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/BattleFinishRequestDto.cs new file mode 100644 index 00000000..32c766e6 --- /dev/null +++ b/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/BattleFinishRequestDto.cs @@ -0,0 +1,49 @@ +using System.Text.Json.Serialization; +using MessagePack; +using SVSim.EmulatedEntrypoint.Models.Dtos.Requests; + +namespace SVSim.EmulatedEntrypoint.Models.Dtos.ArenaColosseum; + +/// +/// POST /colosseum_battle/finish + POST /colosseum_rank_battle/finish request +/// body — the per-match finish, NOT the bracket-end /arena_colosseum/finish. +/// Standard BattleFinishParam shape inherited from FinishTaskBase. +/// +[MessagePackObject] +public sealed class ColosseumBattleFinishRequestDto : BaseRequest +{ + [JsonPropertyName("battle_result")] [Key("battle_result")] + public int BattleResult { get; set; } + + [JsonPropertyName("is_retire")] [Key("is_retire")] + public int IsRetire { get; set; } + + [JsonPropertyName("recovery_data")] [Key("recovery_data")] + public string? RecoveryData { get; set; } + + [JsonPropertyName("class_id")] [Key("class_id")] + public int ClassId { get; set; } + + [JsonPropertyName("total_turn")] [Key("total_turn")] + public int TotalTurn { get; set; } + + [JsonPropertyName("evolve_count")] [Key("evolve_count")] + public int EvolveCount { get; set; } + + [JsonPropertyName("enemy_evolve_count")] [Key("enemy_evolve_count")] + public int EnemyEvolveCount { get; set; } +} + +/// +/// colosseum_battle/finish response. Per battle-finish.md, the client maps this to +/// ColosseumBattleFinishDetail which is an empty MatchFinishBase subclass — +/// no Colosseum-specific fields beyond the shared rank-battle-finish superset. Phase 2 v1 +/// emits the minimum required to keep the client's BattleFinishResponsProcessing +/// happy. +/// +[MessagePackObject(keyAsPropertyName: true)] +public sealed class ColosseumBattleFinishResponseDto +{ + [JsonPropertyName("battle_result")] [Key("battle_result")] + public int BattleResult { get; set; } +} diff --git a/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/ColosseumBattleResults.cs b/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/ColosseumBattleResults.cs new file mode 100644 index 00000000..e795ecab --- /dev/null +++ b/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/ColosseumBattleResults.cs @@ -0,0 +1,15 @@ +using System.Text.Json.Serialization; +using MessagePack; + +namespace SVSim.EmulatedEntrypoint.Models.Dtos.ArenaColosseum; + +[MessagePackObject] +public class ColosseumBattleResults +{ + [JsonPropertyName("win_count")] [Key("win_count")] + public int WinCount { get; set; } + + /// 0 = loss, 1 = win. Client iterates as bool list. + [JsonPropertyName("result_list")] [Key("result_list")] + public List ResultList { get; set; } = new(); +} diff --git a/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/ColosseumCuratedDeckEntry.cs b/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/ColosseumCuratedDeckEntry.cs new file mode 100644 index 00000000..b4ba8cfc --- /dev/null +++ b/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/ColosseumCuratedDeckEntry.cs @@ -0,0 +1,32 @@ +using System.Text.Json.Serialization; +using MessagePack; + +namespace SVSim.EmulatedEntrypoint.Models.Dtos.ArenaColosseum; + +/// +/// Wire shape for a single curated deck on /get_{hof|windfall|avatar}_deck_list. +/// The list response is a BARE ARRAY at the data level per spec — client iterates +/// directly without a wrapper object. Sleeve/skin are optional; client falls back to +/// defaults when absent. +/// +[MessagePackObject] +public sealed class ColosseumCuratedDeckEntry +{ + [JsonPropertyName("deck_id")] [Key("deck_id")] + public int DeckId { get; set; } + + [JsonPropertyName("class_id")] [Key("class_id")] + public int ClassId { get; set; } + + [JsonPropertyName("card_list")] [Key("card_list")] + public List CardList { get; set; } = new(); + + [JsonPropertyName("sleeve_id")] [Key("sleeve_id")] + public long? SleeveId { get; set; } + + [JsonPropertyName("skin_id")] [Key("skin_id")] + public long? SkinId { get; set; } + + [JsonPropertyName("deck_name")] [Key("deck_name")] + public string? DeckName { get; set; } +} diff --git a/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/ColosseumEntryRef.cs b/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/ColosseumEntryRef.cs new file mode 100644 index 00000000..c852c0f3 --- /dev/null +++ b/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/ColosseumEntryRef.cs @@ -0,0 +1,16 @@ +using System.Text.Json.Serialization; +using MessagePack; + +namespace SVSim.EmulatedEntrypoint.Models.Dtos.ArenaColosseum; + +/// Wire entry_info object on /top and /entry. Reused across endpoints. +[MessagePackObject] +public class ColosseumEntryRef +{ + [JsonPropertyName("id")] [Key("id")] + public long Id { get; set; } + + /// Used by /entry only — Format enum integer. Top emits via colosseum_info. + [JsonPropertyName("deck_format")] [Key("deck_format")] + public int? DeckFormat { get; set; } +} diff --git a/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/ColosseumEventInfo.cs b/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/ColosseumEventInfo.cs new file mode 100644 index 00000000..8d10c95b --- /dev/null +++ b/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/ColosseumEventInfo.cs @@ -0,0 +1,63 @@ +using System.Text.Json.Serialization; +using MessagePack; + +namespace SVSim.EmulatedEntrypoint.Models.Dtos.ArenaColosseum; + +/// +/// Event-level descriptor used by /event_info only — distinct shape from +/// : only format, the event window, the announce id, +/// and the final-round eliminate count. The client's ColosseumDetailTask reads +/// these five fields plus the three string-keyed rounds. +/// +[MessagePackObject] +public class ColosseumEventInfo +{ + /// Event format. Mapped via ApiRuleParseAndSet on the client. + [JsonPropertyName("format")] [Key("format")] + public int Format { get; set; } + + [JsonPropertyName("start_time")] [Key("start_time")] + public string StartTime { get; set; } = ""; + + [JsonPropertyName("end_time")] [Key("end_time")] + public string EndTime { get; set; } = ""; + + /// Optional — emit null when no announce content is configured. + [JsonPropertyName("announce_id")] [Key("announce_id")] + public string? AnnounceId { get; set; } + + [JsonPropertyName("final_round_eliminate_count")] [Key("final_round_eliminate_count")] + public int FinalRoundEliminateCount { get; set; } +} + +[MessagePackObject] +public class ColosseumRoundDetail +{ + [JsonPropertyName("start_time")] [Key("start_time")] + public string StartTime { get; set; } = ""; + + [JsonPropertyName("end_time")] [Key("end_time")] + public string EndTime { get; set; } = ""; + + [JsonPropertyName("is_now_round")] [Key("is_now_round")] + public bool IsNowRound { get; set; } + + [JsonPropertyName("round_detail")] [Key("round_detail")] + public List RoundDetail { get; set; } = new(); +} + +[MessagePackObject] +public class ColosseumGroupRow +{ + [JsonPropertyName("group")] [Key("group")] + public string Group { get; set; } = ""; + + [JsonPropertyName("max_battle_count")] [Key("max_battle_count")] + public int MaxBattleCount { get; set; } + + [JsonPropertyName("breakthrough_number")] [Key("breakthrough_number")] + public int BreakthroughNumber { get; set; } + + [JsonPropertyName("entry_number")] [Key("entry_number")] + public int EntryNumber { get; set; } +} diff --git a/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/ColosseumFeeList.cs b/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/ColosseumFeeList.cs new file mode 100644 index 00000000..7f0c079d --- /dev/null +++ b/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/ColosseumFeeList.cs @@ -0,0 +1,17 @@ +using System.Text.Json.Serialization; +using MessagePack; + +namespace SVSim.EmulatedEntrypoint.Models.Dtos.ArenaColosseum; + +[MessagePackObject] +public class ColosseumFeeList +{ + [JsonPropertyName("rupy_cost")] [Key("rupy_cost")] + public int RupyCost { get; set; } + + [JsonPropertyName("ticket_cost")] [Key("ticket_cost")] + public int TicketCost { get; set; } + + [JsonPropertyName("crystal_cost")] [Key("crystal_cost")] + public int CrystalCost { get; set; } +} diff --git a/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/ColosseumInfo.cs b/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/ColosseumInfo.cs new file mode 100644 index 00000000..786192c8 --- /dev/null +++ b/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/ColosseumInfo.cs @@ -0,0 +1,81 @@ +using System.Text.Json.Serialization; +using MessagePack; +using SVSim.EmulatedEntrypoint.Models.Dtos; + +namespace SVSim.EmulatedEntrypoint.Models.Dtos.ArenaColosseum; + +/// +/// Round-level Colosseum descriptor. Shared by /top and /get_fee_info via +/// the client's static ColosseumEntryInfoTask.SetColosseumInfo helper. When +/// is false, the client skips parsing every other +/// field — server still emits this minimal payload so the lobby renders cleanly. +/// +/// Distinct from (the +/// captured prod /mypage/index shape — stringly-typed and read-only). This is the +/// per-endpoint Colosseum-family shape. /event_info uses yet a third shape — +/// . +/// +/// +[MessagePackObject] +public class ColosseumLobbyInfo +{ + /// Master gate. false = lobby renders empty. + [JsonPropertyName("is_colosseum_period")] [Key("is_colosseum_period")] + public bool IsColosseumPeriod { get; set; } + + /// Format enum (Rotation=0, Unlimited=1, TwoPick=10, HOF=31, ...). + [JsonPropertyName("deck_format")] [Key("deck_format")] + public int? DeckFormat { get; set; } + + /// STRING wire shape: "0"/"1". Client parses with + /// jsonData.ToString() == "1". + [JsonPropertyName("is_normal_two_pick")] [Key("is_normal_two_pick")] + public string? IsNormalTwoPick { get; set; } + + [JsonPropertyName("colosseum_name")] [Key("colosseum_name")] + public string? ColosseumName { get; set; } + + [JsonPropertyName("is_round_period")] [Key("is_round_period")] + public bool? IsRoundPeriod { get; set; } + + /// Wire STRING used by the client as a UI color/theme code. + [JsonPropertyName("is_special_mode")] [Key("is_special_mode")] + public string? IsSpecialMode { get; set; } + + [JsonPropertyName("card_pool_name")] [Key("card_pool_name")] + public string? CardPoolName { get; set; } + + /// Present during round period — current stage number (1..3). + [JsonPropertyName("now_round")] [Key("now_round")] + public int? NowRound { get; set; } + + /// Present outside round period — next stage number. + [JsonPropertyName("next_round")] [Key("next_round")] + public int? NextRound { get; set; } + + [JsonPropertyName("start_time")] [Key("start_time")] + public string? StartTime { get; set; } + + [JsonPropertyName("end_time")] [Key("end_time")] + public string? EndTime { get; set; } + + [JsonPropertyName("is_display_tips")] [Key("is_display_tips")] + public int? IsDisplayTips { get; set; } + + [JsonPropertyName("colosseum_id")] [Key("colosseum_id")] + public int? ColosseumId { get; set; } + + [JsonPropertyName("tips_id")] [Key("tips_id")] + public int? TipsId { get; set; } + + [JsonPropertyName("is_all_card_enabled")] [Key("is_all_card_enabled")] + public int? IsAllCardEnabled { get; set; } + + /// Reuses the captured /mypage/index shape — single + /// sales_period_time field per prod capture. + [JsonPropertyName("sales_period_info")] [Key("sales_period_info")] + public ColosseumSalesPeriodInfo? SalesPeriodInfo { get; set; } + + [JsonPropertyName("strategy_pick_num")] [Key("strategy_pick_num")] + public int? StrategyPickNum { get; set; } +} diff --git a/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/ColosseumOwnStatus.cs b/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/ColosseumOwnStatus.cs new file mode 100644 index 00000000..90989dc7 --- /dev/null +++ b/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/ColosseumOwnStatus.cs @@ -0,0 +1,33 @@ +using System.Text.Json.Serialization; +using MessagePack; + +namespace SVSim.EmulatedEntrypoint.Models.Dtos.ArenaColosseum; + +/// +/// Per-viewer Colosseum state. All fields optional — when the viewer has no run, ALL fields +/// are null and the global WhenWritingNull policy renders this as {}, which +/// the client's SetColosseumOwnStatus short-circuits with status.Count != 0. +/// +[MessagePackObject] +public class ColosseumOwnStatus +{ + [JsonPropertyName("rest_entry_num")] [Key("rest_entry_num")] + public int? RestEntryNum { get; set; } + + [JsonPropertyName("now_round_id")] [Key("now_round_id")] + public int? NowRoundId { get; set; } + + [JsonPropertyName("next_round_id")] [Key("next_round_id")] + public int? NextRoundId { get; set; } + + [JsonPropertyName("is_last_day")] [Key("is_last_day")] + public bool? IsLastDay { get; set; } + + [JsonPropertyName("is_champion")] [Key("is_champion")] + public bool? IsChampion { get; set; } + + /// Only present when is true — client uses it to overwrite + /// ColosseumData.Name for the champion screen. + [JsonPropertyName("colosseum_name")] [Key("colosseum_name")] + public string? ColosseumName { get; set; } +} diff --git a/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/ColosseumReceivedReward.cs b/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/ColosseumReceivedReward.cs new file mode 100644 index 00000000..224cf3cc --- /dev/null +++ b/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/ColosseumReceivedReward.cs @@ -0,0 +1,26 @@ +using System.Text.Json.Serialization; +using MessagePack; + +namespace SVSim.EmulatedEntrypoint.Models.Dtos.ArenaColosseum; + +/// +/// Per-entry shape for the rewards array on /finish + /retire. Richer +/// than RewardEntryDto (which is the reward_list shape) — carries a display +/// name. Distinct from the wallet-delta block: client renders rewards in the +/// post-bracket popup while reward_list drives the silent wallet update. +/// +[MessagePackObject] +public sealed class ColosseumReceivedReward +{ + [JsonPropertyName("reward_number")] [Key("reward_number")] + public int RewardNumber { get; set; } + + [JsonPropertyName("reward_type")] [Key("reward_type")] + public int RewardType { get; set; } + + [JsonPropertyName("reward_detail_id")] [Key("reward_detail_id")] + public long RewardDetailId { get; set; } + + [JsonPropertyName("name")] [Key("name")] + public string Name { get; set; } = ""; +} diff --git a/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/ColosseumUserDeck.cs b/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/ColosseumUserDeck.cs new file mode 100644 index 00000000..729e707b --- /dev/null +++ b/SVSim.EmulatedEntrypoint/Models/Dtos/ArenaColosseum/ColosseumUserDeck.cs @@ -0,0 +1,26 @@ +using System.Text.Json.Serialization; +using MessagePack; + +namespace SVSim.EmulatedEntrypoint.Models.Dtos.ArenaColosseum; + +/// Lightweight deck-info shape for /top's user_deck[0]. The client's +/// DeckData.Initialize consumes the canonical deck shape; this is the minimum needed +/// to render the deck preview in Phase 1. +[MessagePackObject] +public class ColosseumUserDeck +{ + [JsonPropertyName("deck_id")] [Key("deck_id")] + public long DeckId { get; set; } + + [JsonPropertyName("class_id")] [Key("class_id")] + public int ClassId { get; set; } + + [JsonPropertyName("card_list")] [Key("card_list")] + public List CardList { get; set; } = new(); + + [JsonPropertyName("sleeve_id")] [Key("sleeve_id")] + public long? SleeveId { get; set; } + + [JsonPropertyName("skin_id")] [Key("skin_id")] + public long? SkinId { get; set; } +} diff --git a/SVSim.EmulatedEntrypoint/Models/Dtos/Requests/ArenaColosseum/ArenaColosseumCardChooseRequest.cs b/SVSim.EmulatedEntrypoint/Models/Dtos/Requests/ArenaColosseum/ArenaColosseumCardChooseRequest.cs new file mode 100644 index 00000000..4773c44b --- /dev/null +++ b/SVSim.EmulatedEntrypoint/Models/Dtos/Requests/ArenaColosseum/ArenaColosseumCardChooseRequest.cs @@ -0,0 +1,12 @@ +using System.Text.Json.Serialization; +using MessagePack; +using SVSim.EmulatedEntrypoint.Models.Dtos.Requests; + +namespace SVSim.EmulatedEntrypoint.Models.Dtos.Requests.ArenaColosseum; + +[MessagePackObject] +public sealed class ArenaColosseumCardChooseRequest : BaseRequest +{ + [JsonPropertyName("selected_id")] [Key("selected_id")] + public long SelectedId { get; set; } +} diff --git a/SVSim.EmulatedEntrypoint/Models/Dtos/Requests/ArenaColosseum/ArenaColosseumClassChooseRequest.cs b/SVSim.EmulatedEntrypoint/Models/Dtos/Requests/ArenaColosseum/ArenaColosseumClassChooseRequest.cs new file mode 100644 index 00000000..02fc0729 --- /dev/null +++ b/SVSim.EmulatedEntrypoint/Models/Dtos/Requests/ArenaColosseum/ArenaColosseumClassChooseRequest.cs @@ -0,0 +1,22 @@ +using System.Text.Json.Serialization; +using MessagePack; +using SVSim.EmulatedEntrypoint.Models.Dtos.Requests; + +namespace SVSim.EmulatedEntrypoint.Models.Dtos.Requests.ArenaColosseum; + +/// +/// POST /arena_colosseum/class_choose. Two mutually-exclusive request shapes per +/// class-choose.md — Normal sends class_id, Chaos sends chaos_id. Both fields +/// are bound on this DTO; the server picks the mode by which is non-zero and rejects when +/// both are present (or neither). +/// +[MessagePackObject] +public sealed class ArenaColosseumClassChooseRequest : BaseRequest +{ + [JsonPropertyName("class_id")] [Key("class_id")] + public int ClassId { get; set; } + + /// Chaos sub-mode replay id. 0 in Normal mode. + [JsonPropertyName("chaos_id")] [Key("chaos_id")] + public int ChaosId { get; set; } +} diff --git a/SVSim.EmulatedEntrypoint/Models/Dtos/Requests/ArenaColosseum/ArenaColosseumEntryRequest.cs b/SVSim.EmulatedEntrypoint/Models/Dtos/Requests/ArenaColosseum/ArenaColosseumEntryRequest.cs new file mode 100644 index 00000000..ae78f735 --- /dev/null +++ b/SVSim.EmulatedEntrypoint/Models/Dtos/Requests/ArenaColosseum/ArenaColosseumEntryRequest.cs @@ -0,0 +1,22 @@ +using System.Text.Json.Serialization; +using MessagePack; +using SVSim.EmulatedEntrypoint.Models.Dtos.Requests; + +namespace SVSim.EmulatedEntrypoint.Models.Dtos.Requests.ArenaColosseum; + +/// +/// POST /arena_colosseum/entry — pay the entry cost and start a Colosseum bracket +/// attempt. Maps to Wizard/ColosseumEntryTask.ColosseumEntryTaskParam. +/// +[MessagePackObject(keyAsPropertyName: false)] +public class ArenaColosseumEntryRequest : BaseRequest +{ + /// Currency selector — eARENA_PAY enum. 1=Crystal, 3=Ticket, 4=Rupy, 5=Free. + [JsonPropertyName("consume_item_type")] [Key("consume_item_type")] + public int ConsumeItemType { get; set; } + + /// Client-echoed round id from the most recent /get_fee_info or /top. + /// Server rejects if it disagrees with the current server-decided round. + [JsonPropertyName("now_round_id")] [Key("now_round_id")] + public int NowRoundId { get; set; } +} diff --git a/SVSim.EmulatedEntrypoint/Models/Dtos/Requests/ArenaColosseum/ArenaColosseumRegisterDeckRequest.cs b/SVSim.EmulatedEntrypoint/Models/Dtos/Requests/ArenaColosseum/ArenaColosseumRegisterDeckRequest.cs new file mode 100644 index 00000000..720e8470 --- /dev/null +++ b/SVSim.EmulatedEntrypoint/Models/Dtos/Requests/ArenaColosseum/ArenaColosseumRegisterDeckRequest.cs @@ -0,0 +1,22 @@ +using System.Text.Json.Serialization; +using MessagePack; +using SVSim.EmulatedEntrypoint.Models.Dtos.Requests; + +namespace SVSim.EmulatedEntrypoint.Models.Dtos.Requests.ArenaColosseum; + +/// +/// POST /arena_colosseum/register_deck — submit deck slot(s) for a constructed-format +/// entry. Same wire gotcha as arena_competition/register_deck et al — +/// is a JSON-encoded STRING like "[3,4,5]", not an array. The server parses it. +/// +[MessagePackObject(keyAsPropertyName: false)] +public class ArenaColosseumRegisterDeckRequest : BaseRequest +{ + /// JSON-encoded list of deck slot numbers. Client does JsonMapper.ToJson(List<int>). + [JsonPropertyName("deck_no_list")] [Key("deck_no_list")] + public string DeckNoList { get; set; } = "[]"; + + /// Server-stored visibility flag — does not affect bracket play. + [JsonPropertyName("is_published")] [Key("is_published")] + public bool IsPublished { get; set; } +} diff --git a/SVSim.EmulatedEntrypoint/Models/Dtos/Requests/ArenaColosseum/GetFeeInfoRequest.cs b/SVSim.EmulatedEntrypoint/Models/Dtos/Requests/ArenaColosseum/GetFeeInfoRequest.cs deleted file mode 100644 index f13ba635..00000000 --- a/SVSim.EmulatedEntrypoint/Models/Dtos/Requests/ArenaColosseum/GetFeeInfoRequest.cs +++ /dev/null @@ -1,6 +0,0 @@ -using MessagePack; - -namespace SVSim.EmulatedEntrypoint.Models.Dtos.Requests.ArenaColosseum; - -[MessagePackObject] -public class GetFeeInfoRequest : BaseRequest { } diff --git a/SVSim.EmulatedEntrypoint/Models/Dtos/Requests/ArenaColosseum/RegisterCuratedDeckRequest.cs b/SVSim.EmulatedEntrypoint/Models/Dtos/Requests/ArenaColosseum/RegisterCuratedDeckRequest.cs new file mode 100644 index 00000000..d446df0d --- /dev/null +++ b/SVSim.EmulatedEntrypoint/Models/Dtos/Requests/ArenaColosseum/RegisterCuratedDeckRequest.cs @@ -0,0 +1,18 @@ +using System.Text.Json.Serialization; +using MessagePack; +using SVSim.EmulatedEntrypoint.Models.Dtos.Requests; + +namespace SVSim.EmulatedEntrypoint.Models.Dtos.Requests.ArenaColosseum; + +/// +/// Shared request shape for the three curated-deck register URLs (HOF / WindFall / Avatar). +/// Same JSON-encoded-string gotcha as — +/// deck_no_list is a wire string like "[1001,1002]". No is_published +/// here (constructed-only flag per spec). +/// +[MessagePackObject] +public sealed class RegisterCuratedDeckRequest : BaseRequest +{ + [JsonPropertyName("deck_no_list")] [Key("deck_no_list")] + public string DeckNoList { get; set; } = "[]"; +} diff --git a/SVSim.EmulatedEntrypoint/Models/Dtos/Responses/ArenaColosseum/EntryResponse.cs b/SVSim.EmulatedEntrypoint/Models/Dtos/Responses/ArenaColosseum/EntryResponse.cs new file mode 100644 index 00000000..92fe2bc8 --- /dev/null +++ b/SVSim.EmulatedEntrypoint/Models/Dtos/Responses/ArenaColosseum/EntryResponse.cs @@ -0,0 +1,22 @@ +using System.Text.Json.Serialization; +using MessagePack; +using SVSim.EmulatedEntrypoint.Models.Dtos.ArenaColosseum; +using SVSim.EmulatedEntrypoint.Models.Dtos.Common.ArenaTwoPick; + +namespace SVSim.EmulatedEntrypoint.Models.Dtos.Responses.ArenaColosseum; + +/// +/// POST /arena_colosseum/entry. Sparse — only reward_list (wallet debit) + +/// entry_info.deck_format. Client refreshes full lobby state via the next /top. +/// Reuses from arena-two-pick — the wire shape is identical +/// (reward_type/reward_id/reward_num per UpdateHaveUserGoodsNumByJsonData). +/// +[MessagePackObject] +public class EntryResponse +{ + [JsonPropertyName("reward_list")] [Key("reward_list")] + public List RewardList { get; set; } = new(); + + [JsonPropertyName("entry_info")] [Key("entry_info")] + public ColosseumEntryRef EntryInfo { get; set; } = new(); +} diff --git a/SVSim.EmulatedEntrypoint/Models/Dtos/Responses/ArenaColosseum/EventInfoResponse.cs b/SVSim.EmulatedEntrypoint/Models/Dtos/Responses/ArenaColosseum/EventInfoResponse.cs new file mode 100644 index 00000000..fd729989 --- /dev/null +++ b/SVSim.EmulatedEntrypoint/Models/Dtos/Responses/ArenaColosseum/EventInfoResponse.cs @@ -0,0 +1,31 @@ +using System.Text.Json.Serialization; +using MessagePack; +using SVSim.EmulatedEntrypoint.Models.Dtos.ArenaColosseum; + +namespace SVSim.EmulatedEntrypoint.Models.Dtos.Responses.ArenaColosseum; + +/// +/// POST /arena_colosseum/event_info. The 3-round Colosseum bracket descriptor — note +/// the rounds are STRING-keyed ("1", "2", "3"), NOT an array. The +/// client iterates for (i = 1; i <= 3; i++) jsonData[i.ToString()]. Using three +/// explicit [JsonPropertyName("1"|"2"|"3")] properties is simpler than a custom STJ +/// converter and round-trips cleanly through MessagePack via matching [Key("1"|...)]. +/// +[MessagePackObject] +public class EventInfoResponse +{ + [JsonPropertyName("colosseum_info")] [Key("colosseum_info")] + public ColosseumEventInfo ColosseumInfo { get; set; } = new(); + + [JsonPropertyName("1")] [Key("1")] + public ColosseumRoundDetail Round1 { get; set; } = new(); + + [JsonPropertyName("2")] [Key("2")] + public ColosseumRoundDetail Round2 { get; set; } = new(); + + [JsonPropertyName("3")] [Key("3")] + public ColosseumRoundDetail Round3 { get; set; } = new(); + + [JsonPropertyName("colosseum_status")] [Key("colosseum_status")] + public ColosseumOwnStatus ColosseumStatus { get; set; } = new(); +} diff --git a/SVSim.EmulatedEntrypoint/Models/Dtos/Responses/ArenaColosseum/FinishResponse.cs b/SVSim.EmulatedEntrypoint/Models/Dtos/Responses/ArenaColosseum/FinishResponse.cs new file mode 100644 index 00000000..a4f646ef --- /dev/null +++ b/SVSim.EmulatedEntrypoint/Models/Dtos/Responses/ArenaColosseum/FinishResponse.cs @@ -0,0 +1,27 @@ +using System.Text.Json.Serialization; +using MessagePack; +using SVSim.EmulatedEntrypoint.Models.Dtos.ArenaColosseum; +using SVSim.EmulatedEntrypoint.Models.Dtos.Common.ArenaTwoPick; + +namespace SVSim.EmulatedEntrypoint.Models.Dtos.Responses.ArenaColosseum; + +/// +/// POST /arena_colosseum/finish and POST /arena_colosseum/retire. Wire-identical +/// shape per finish.md §"Wire-shared with /retire" — endpoints differ in side-effects only: +/// /finish emits per-round-completion + champion bonus and marks the entry champion; +/// /retire emits the round-capped consolation. The client renders rewards in the +/// post-bracket popup, applies wallet deltas via reward_list, and updates the +/// status block via colosseum_status. +/// +[MessagePackObject] +public sealed class FinishResponse +{ + [JsonPropertyName("rewards")] [Key("rewards")] + public List Rewards { get; set; } = new(); + + [JsonPropertyName("reward_list")] [Key("reward_list")] + public List RewardList { get; set; } = new(); + + [JsonPropertyName("colosseum_status")] [Key("colosseum_status")] + public ColosseumOwnStatus ColosseumStatus { get; set; } = new(); +} diff --git a/SVSim.EmulatedEntrypoint/Models/Dtos/Responses/ArenaColosseum/GetCandidateCardsResponse.cs b/SVSim.EmulatedEntrypoint/Models/Dtos/Responses/ArenaColosseum/GetCandidateCardsResponse.cs new file mode 100644 index 00000000..1ca16685 --- /dev/null +++ b/SVSim.EmulatedEntrypoint/Models/Dtos/Responses/ArenaColosseum/GetCandidateCardsResponse.cs @@ -0,0 +1,27 @@ +using System.Text.Json.Serialization; +using MessagePack; +using SVSim.EmulatedEntrypoint.Models.Dtos.Common.ArenaTwoPick; + +namespace SVSim.EmulatedEntrypoint.Models.Dtos.Responses.ArenaColosseum; + +/// +/// POST /arena_colosseum/get_candidate_cards. Idempotent draft-resume — server emits +/// the current snapshot for the active run plus the pending pair offer. The Common +/// DeckInfoDto/CandidatePairDto/ClassInfoDto shapes are shared with +/// arena-two-pick and arena-competition per spec. +/// +[MessagePackObject] +public sealed class GetCandidateCardsResponse +{ + [JsonPropertyName("deck_info")] [Key("deck_info")] + public DeckInfoDto DeckInfo { get; set; } = new(); + + [JsonPropertyName("candidate_card_list")] [Key("candidate_card_list")] + public List CandidateCardList { get; set; } = new(); + + [JsonPropertyName("leader_skin_id")] [Key("leader_skin_id")] + public long? LeaderSkinId { get; set; } + + [JsonPropertyName("class_info")] [Key("class_info")] + public ClassInfoDto ClassInfo { get; set; } = new(); +} diff --git a/SVSim.EmulatedEntrypoint/Models/Dtos/Responses/ArenaColosseum/GetCandidateClassesResponse.cs b/SVSim.EmulatedEntrypoint/Models/Dtos/Responses/ArenaColosseum/GetCandidateClassesResponse.cs new file mode 100644 index 00000000..29c17ef7 --- /dev/null +++ b/SVSim.EmulatedEntrypoint/Models/Dtos/Responses/ArenaColosseum/GetCandidateClassesResponse.cs @@ -0,0 +1,41 @@ +using System.Text.Json.Serialization; +using MessagePack; + +namespace SVSim.EmulatedEntrypoint.Models.Dtos.Responses.ArenaColosseum; + +/// +/// POST /arena_colosseum/get_candidate_classes. Two mutually-exclusive sub-shapes — +/// Normal 2-pick emits class_id_1/2/3; Chaos emits chaos_id_1/2/3 + +/// chaos_info. WhenWritingNull strips the inactive branch so the wire matches +/// the spec exactly. +/// +[MessagePackObject] +public sealed class GetCandidateClassesResponse +{ + [JsonPropertyName("class_id_1")] [Key("class_id_1")] + public int? ClassId1 { get; set; } + + [JsonPropertyName("class_id_2")] [Key("class_id_2")] + public int? ClassId2 { get; set; } + + [JsonPropertyName("class_id_3")] [Key("class_id_3")] + public int? ClassId3 { get; set; } + + [JsonPropertyName("chaos_id_1")] [Key("chaos_id_1")] + public int? ChaosId1 { get; set; } + + [JsonPropertyName("chaos_id_2")] [Key("chaos_id_2")] + public int? ChaosId2 { get; set; } + + [JsonPropertyName("chaos_id_3")] [Key("chaos_id_3")] + public int? ChaosId3 { get; set; } + + [JsonPropertyName("selected_chaos_id")] [Key("selected_chaos_id")] + public int? SelectedChaosId { get; set; } + + [JsonPropertyName("selected_class_id")] [Key("selected_class_id")] + public int? SelectedClassId { get; set; } + + [JsonPropertyName("selected_leader_skin_id")] [Key("selected_leader_skin_id")] + public long? SelectedLeaderSkinId { get; set; } +} diff --git a/SVSim.EmulatedEntrypoint/Models/Dtos/Responses/ArenaColosseum/GetFeeInfoResponseDto.cs b/SVSim.EmulatedEntrypoint/Models/Dtos/Responses/ArenaColosseum/GetFeeInfoResponseDto.cs index f697163c..059acf30 100644 --- a/SVSim.EmulatedEntrypoint/Models/Dtos/Responses/ArenaColosseum/GetFeeInfoResponseDto.cs +++ b/SVSim.EmulatedEntrypoint/Models/Dtos/Responses/ArenaColosseum/GetFeeInfoResponseDto.cs @@ -1,39 +1,46 @@ using System.Text.Json.Serialization; using MessagePack; +using SVSim.EmulatedEntrypoint.Models.Dtos.ArenaColosseum; namespace SVSim.EmulatedEntrypoint.Models.Dtos.Responses.ArenaColosseum; /// -/// Minimum-viable stub for /arena_colosseum/get_fee_info — emits is_colosseum_period:false -/// so the client (Wizard/ColosseumEntryInfoTask.cs:99) skips the rest of the parse and the -/// home/arena screen renders without 404ing. TODO: implement the full Colosseum entry flow -/// when the Colosseum format is brought online. +/// POST /arena_colosseum/get_fee_info — pre-entry oracle. Most fields are optional; +/// presence drives the lobby state machine on the client side +/// (Wizard/ColosseumEntryInfoTask.cs). When no season is active, only +/// + are emitted (the former with +/// is_colosseum_period:false, the latter as {} via WhenWritingNull stripping). /// [MessagePackObject] public class GetFeeInfoResponseDto { - /// - /// Per-viewer Colosseum entry status (rest_entry_num, now_round_id, is_last_day, etc.). - /// Empty object — client (ColosseumEntryInfoTask.cs:146) guards with `if (status.Count != 0)`, - /// so an empty dict short-circuits cleanly. - /// - [JsonPropertyName("colosseum_status")] [Key("colosseum_status")] - public ColosseumStatusDto ColosseumStatus { get; set; } = new(); - [JsonPropertyName("colosseum_info")] [Key("colosseum_info")] - public ColosseumInfoDto ColosseumInfo { get; set; } = new(); -} + public ColosseumLobbyInfo ColosseumInfo { get; set; } = new(); -[MessagePackObject] -public class ColosseumStatusDto { } + [JsonPropertyName("colosseum_status")] [Key("colosseum_status")] + public ColosseumOwnStatus ColosseumStatus { get; set; } = new(); -[MessagePackObject] -public class ColosseumInfoDto -{ - /// - /// false = no Colosseum event running. Client (ColosseumEntryInfoTask.cs:100) gates every - /// other field on this — emitting false is what lets us ship an otherwise-empty info block. - /// - [JsonPropertyName("is_colosseum_period")] [Key("is_colosseum_period")] - public bool IsColosseumPeriod { get; set; } = false; + [JsonPropertyName("is_unfinished_entry_exists")] [Key("is_unfinished_entry_exists")] + public bool? IsUnfinishedEntryExists { get; set; } + + [JsonPropertyName("is_allowed_free_entry")] [Key("is_allowed_free_entry")] + public bool? IsAllowedFreeEntry { get; set; } + + [JsonPropertyName("fee_list")] [Key("fee_list")] + public ColosseumFeeList? FeeList { get; set; } + + [JsonPropertyName("deck_format")] [Key("deck_format")] + public int? DeckFormat { get; set; } + + [JsonPropertyName("is_able_to_join_round_3")] [Key("is_able_to_join_round_3")] + public bool? IsAbleToJoinRound3 { get; set; } + + [JsonPropertyName("is_already_entry_final_round")] [Key("is_already_entry_final_round")] + public bool? IsAlreadyEntryFinalRound { get; set; } + + [JsonPropertyName("is_deck_deleted")] [Key("is_deck_deleted")] + public bool? IsDeckDeleted { get; set; } + + [JsonPropertyName("two_pick_status")] [Key("two_pick_status")] + public int? TwoPickStatus { get; set; } } diff --git a/SVSim.EmulatedEntrypoint/Models/Dtos/Responses/ArenaColosseum/TopResponse.cs b/SVSim.EmulatedEntrypoint/Models/Dtos/Responses/ArenaColosseum/TopResponse.cs new file mode 100644 index 00000000..f7e1600a --- /dev/null +++ b/SVSim.EmulatedEntrypoint/Models/Dtos/Responses/ArenaColosseum/TopResponse.cs @@ -0,0 +1,61 @@ +using System.Text.Json.Serialization; +using MessagePack; +using SVSim.EmulatedEntrypoint.Models.Dtos.ArenaColosseum; + +namespace SVSim.EmulatedEntrypoint.Models.Dtos.Responses.ArenaColosseum; + +/// +/// POST /arena_colosseum/top — lobby state for an in-progress run. When no season is +/// active is false and most other +/// fields are absent (the client guards on that flag before reading anything else). +/// +[MessagePackObject] +public class TopResponse +{ + [JsonPropertyName("entry_info")] [Key("entry_info")] + public ColosseumEntryRef EntryInfo { get; set; } = new(); + + [JsonPropertyName("colosseum_info")] [Key("colosseum_info")] + public ColosseumLobbyInfo ColosseumInfo { get; set; } = new(); + + [JsonPropertyName("colosseum_status")] [Key("colosseum_status")] + public ColosseumOwnStatus ColosseumStatus { get; set; } = new(); + + [JsonPropertyName("now_round_id")] [Key("now_round_id")] + public int NowRoundId { get; set; } + + [JsonPropertyName("user_deck")] [Key("user_deck")] + public List UserDeck { get; set; } = new(); + + [JsonPropertyName("max_battle_count")] [Key("max_battle_count")] + public int MaxBattleCount { get; set; } + + [JsonPropertyName("is_finish")] [Key("is_finish")] + public bool IsFinish { get; set; } + + [JsonPropertyName("final_round_eliminate_count")] [Key("final_round_eliminate_count")] + public int FinalRoundEliminateCount { get; set; } + + [JsonPropertyName("end_time")] [Key("end_time")] + public string EndTime { get; set; } = ""; + + [JsonPropertyName("battle_results")] [Key("battle_results")] + public ColosseumBattleResults BattleResults { get; set; } = new(); + + [JsonPropertyName("breakthrough_number")] [Key("breakthrough_number")] + public int? BreakthroughNumber { get; set; } + + [JsonPropertyName("box_grade_list")] [Key("box_grade_list")] + public List? BoxGradeList { get; set; } + + [JsonPropertyName("selected_chaos_id")] [Key("selected_chaos_id")] + public int? SelectedChaosId { get; set; } + + /// ALWAYS emitted, even when 0. WhenWritingNull would strip this otherwise — + /// see project_wire_null_policy: client does jsonData["leader_skin_id"].ToInt() + /// unguarded, which throws a KeyNotFoundException if absent. + [JsonPropertyName("leader_skin_id")] + [JsonIgnore(Condition = JsonIgnoreCondition.Never)] + [Key("leader_skin_id")] + public long LeaderSkinId { get; set; } +} diff --git a/SVSim.EmulatedEntrypoint/Program.cs b/SVSim.EmulatedEntrypoint/Program.cs index 1297c930..16a7ab6b 100644 --- a/SVSim.EmulatedEntrypoint/Program.cs +++ b/SVSim.EmulatedEntrypoint/Program.cs @@ -106,6 +106,9 @@ public class Program builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); @@ -157,6 +160,11 @@ public class Program // (see Shadowverse_Code_2026-05-23/ApiType.cs), so PvpOnly: park forever, no AI fallback. new ModePolicy("rotation_free_battle", PolicyKind.PvpOnly), new ModePolicy("unlimited_free_battle", PolicyKind.PvpOnly), + // Colosseum (Grand Prix). Pre-promotion + post-promotion (rank) URLs each map + // to their own pair-up mode — the URL IS the signal per do-matching.md, and the + // node session has no way to ask the client "which bracket are you in?". + new ModePolicy("colosseum_battle", PolicyKind.PvpOnly), + new ModePolicy("colosseum_rank_battle", PolicyKind.PvpOnly), })); builder.Services.AddSingleton(); // Single resolver shared by every /do_matching family controller. Owns the diff --git a/SVSim.EmulatedEntrypoint/Services/ArenaColosseum/ColosseumProgressionService.cs b/SVSim.EmulatedEntrypoint/Services/ArenaColosseum/ColosseumProgressionService.cs new file mode 100644 index 00000000..a07abfe4 --- /dev/null +++ b/SVSim.EmulatedEntrypoint/Services/ArenaColosseum/ColosseumProgressionService.cs @@ -0,0 +1,69 @@ +using SVSim.Database.Models; +using SVSim.Database.Models.Config; + +namespace SVSim.EmulatedEntrypoint.Services.ArenaColosseum; + +public class ColosseumProgressionService : IColosseumProgressionService +{ + /// Colosseum-specific node signal — see do-matching.md §matching_state 3008. + public const int PromoteToRankMatchingState = 3008; + + public bool ShouldPromoteToRankMatching(ViewerArenaColosseumRun run, int matchingState) => + matchingState == PromoteToRankMatchingState && !run.IsRankMatching; + + public AdvancementDecision DecideAdvancement(ViewerArenaColosseumRun run, ColosseumRoundsConfig rounds) + { + var currentRound = rounds.Rounds.FirstOrDefault(r => r.RoundId == run.RoundId); + var currentGroup = currentRound?.Groups.FirstOrDefault(); + var maxRoundId = rounds.Rounds.Count == 0 ? run.RoundId : rounds.Rounds.Max(r => r.RoundId); + + // No matching round config (e.g. content not seeded) — treat current state as terminal + // so the controller doesn't loop forever. Champion=false because we can't tell. + if (currentGroup is null) + { + return new AdvancementDecision(run.RoundId, IsBracketEnd: true, IsChampion: false); + } + + // Cleared the breakthrough threshold this round. + if (run.WinCount >= currentGroup.BreakthroughNumber) + { + bool isFinal = run.RoundId >= maxRoundId; + return new AdvancementDecision( + NextRoundId: isFinal ? run.RoundId : run.RoundId + 1, + IsBracketEnd: isFinal, + IsChampion: isFinal); + } + + // Exhausted the per-round battle cap without clearing — bracket ends at current round. + if (run.BattleCountThisRound >= currentGroup.MaxBattleCount) + { + return new AdvancementDecision(run.RoundId, IsBracketEnd: true, IsChampion: false); + } + + // Mid-round, still playing. + return new AdvancementDecision(run.RoundId, IsBracketEnd: false, IsChampion: false); + } + + public IReadOnlyList BuildRetireRewards( + ViewerArenaColosseumRun run, ColosseumRoundsConfig rounds) + { + var round = rounds.Rounds.FirstOrDefault(r => r.RoundId == run.RoundId); + return round?.RetireRewards ?? new(); + } + + public IReadOnlyList BuildFinishRewards( + ViewerArenaColosseumRun run, ColosseumRoundsConfig rounds) + { + var round = rounds.Rounds.FirstOrDefault(r => r.RoundId == run.RoundId); + var bundle = new List(); + if (round is not null) + { + bundle.AddRange(round.FinishRewards); + } + if (run.IsChampion) + { + bundle.AddRange(rounds.ChampionRewards); + } + return bundle; + } +} diff --git a/SVSim.EmulatedEntrypoint/Services/ArenaColosseum/IColosseumProgressionService.cs b/SVSim.EmulatedEntrypoint/Services/ArenaColosseum/IColosseumProgressionService.cs new file mode 100644 index 00000000..9c58afc0 --- /dev/null +++ b/SVSim.EmulatedEntrypoint/Services/ArenaColosseum/IColosseumProgressionService.cs @@ -0,0 +1,39 @@ +using SVSim.Database.Enums; +using SVSim.Database.Models; +using SVSim.Database.Models.Config; + +namespace SVSim.EmulatedEntrypoint.Services.ArenaColosseum; + +/// +/// Pure-logic decisions for the Colosseum bracket lifecycle. Reads a +/// + snapshot and +/// returns advancement / promotion / reward decisions. Side-effectful (debits, grants, +/// run-row writes) live on the controllers — this service just computes. +/// +public interface IColosseumProgressionService +{ + /// True when the node signal matching_state == 3008 indicates the run + /// has been promoted to the ranked bracket and we haven't already flipped the flag. + /// Subsequent battle URLs route to colosseum_rank_battle/*. + bool ShouldPromoteToRankMatching(ViewerArenaColosseumRun run, int matchingState); + + /// Triggered post-match-finish when wins/losses cross thresholds. Returns the + /// next round id (or current if no change), whether the bracket has ended, and the + /// champion flag for the final-round-cleared case. + AdvancementDecision DecideAdvancement(ViewerArenaColosseumRun run, ColosseumRoundsConfig rounds); + + /// Bundle to grant on /retire. Reads + /// for the run's + /// . Empty when no matching round. + IReadOnlyList BuildRetireRewards( + ViewerArenaColosseumRun run, ColosseumRoundsConfig rounds); + + /// Bundle to grant on /finish. Combines the current round's + /// with + /// when the run is a champion. + IReadOnlyList BuildFinishRewards( + ViewerArenaColosseumRun run, ColosseumRoundsConfig rounds); +} + +/// Output of . +public sealed record AdvancementDecision(int NextRoundId, bool IsBracketEnd, bool IsChampion); diff --git a/SVSim.EmulatedEntrypoint/Services/ArenaTwoPickCardPoolService.cs b/SVSim.EmulatedEntrypoint/Services/ArenaTwoPickCardPoolService.cs index 77d05461..86655048 100644 --- a/SVSim.EmulatedEntrypoint/Services/ArenaTwoPickCardPoolService.cs +++ b/SVSim.EmulatedEntrypoint/Services/ArenaTwoPickCardPoolService.cs @@ -17,14 +17,28 @@ public class ArenaTwoPickCardPoolService : IArenaTwoPickCardPoolService _db = db; _config = config; } - public List GeneratePickSetsForTurn(int classId, int turn, long startingPairId, IRandom rng) + public List GeneratePickSetsForTurn(int classId, int turn, long startingPairId, IRandom rng) => + GeneratePickSetsForTurn(classId, turn, startingPairId, rng, poolCardSetIds: null); + + public List GeneratePickSetsForTurn( + int classId, int turn, long startingPairId, IRandom rng, IReadOnlyList? poolCardSetIds) { var aCfg = _config.Get(); - var cCfg = _config.Get(); - var setIds = cCfg.PoolCardSetIds is { Count: > 0 } ids - ? ids - : _config.Get().RotationCardSetIds ?? new List(); + // Caller-supplied override wins (e.g. ColosseumSeasonConfig.PoolCardSetIds). Falls + // back to ChallengeConfig → RotationConfig per the original TK2 resolution chain. + IReadOnlyList setIds; + if (poolCardSetIds is { Count: > 0 }) + { + setIds = poolCardSetIds; + } + else + { + var cCfg = _config.Get(); + setIds = cCfg.PoolCardSetIds is { Count: > 0 } ids + ? ids + : _config.Get().RotationCardSetIds ?? new List(); + } var setIdsArr = setIds.ToArray(); diff --git a/SVSim.EmulatedEntrypoint/Services/IArenaTwoPickCardPoolService.cs b/SVSim.EmulatedEntrypoint/Services/IArenaTwoPickCardPoolService.cs index e6f06957..8b48a0d5 100644 --- a/SVSim.EmulatedEntrypoint/Services/IArenaTwoPickCardPoolService.cs +++ b/SVSim.EmulatedEntrypoint/Services/IArenaTwoPickCardPoolService.cs @@ -9,4 +9,13 @@ public interface IArenaTwoPickCardPoolService /// (startingPairId, startingPairId+1); set_num = 1, 2; isSelected = false. /// List GeneratePickSetsForTurn(int classId, int turn, long startingPairId, IRandom rng); + + /// + /// Pool-override variant — used by Arena Colosseum's 2-Pick mode, where the draft pool + /// comes from the per-season ColosseumSeasonConfig.PoolCardSetIds rather than the + /// global ChallengeConfig.PoolCardSetIds. Pass an empty/null list to fall back to + /// the default-pool resolution (challenge → rotation). + /// + List GeneratePickSetsForTurn( + int classId, int turn, long startingPairId, IRandom rng, IReadOnlyList? poolCardSetIds); } diff --git a/SVSim.EmulatedEntrypoint/Services/IMatchContextBuilder.cs b/SVSim.EmulatedEntrypoint/Services/IMatchContextBuilder.cs index 84c9a83c..a40efd0a 100644 --- a/SVSim.EmulatedEntrypoint/Services/IMatchContextBuilder.cs +++ b/SVSim.EmulatedEntrypoint/Services/IMatchContextBuilder.cs @@ -24,4 +24,13 @@ public interface IMatchContextBuilder /// no deck at that slot. /// Task BuildForRankBattleAsync(long viewerId, Format format, int deckNo); + + /// + /// Build a context for an Arena Colosseum bracket match — reads the active + /// ViewerArenaColosseumRun's registered deck slot (single-deck v1) via + /// IDeckRepository.GetDeck (NOT viewer-graph traversal per + /// project_ef_nav_include_pitfall). Throws when the run is missing or no deck + /// has been registered yet. + /// + Task BuildForColosseumAsync(long viewerId); } diff --git a/SVSim.EmulatedEntrypoint/Services/MatchContextBuilder.cs b/SVSim.EmulatedEntrypoint/Services/MatchContextBuilder.cs index 9b827c4e..f4b5e9f7 100644 --- a/SVSim.EmulatedEntrypoint/Services/MatchContextBuilder.cs +++ b/SVSim.EmulatedEntrypoint/Services/MatchContextBuilder.cs @@ -11,17 +11,20 @@ namespace SVSim.EmulatedEntrypoint.Services; public class MatchContextBuilder : IMatchContextBuilder { private readonly IArenaTwoPickRunRepository _runs; + private readonly IArenaColosseumRunRepository _colosseumRuns; private readonly IViewerRepository _viewers; private readonly IDeckRepository _decks; private readonly IGameConfigService _config; public MatchContextBuilder( IArenaTwoPickRunRepository runs, + IArenaColosseumRunRepository colosseumRuns, IViewerRepository viewers, IDeckRepository decks, IGameConfigService config) { _runs = runs; + _colosseumRuns = colosseumRuns; _viewers = viewers; _decks = decks; _config = config; @@ -120,4 +123,58 @@ public class MatchContextBuilder : IMatchContextBuilder IsOfficial: viewer.Info.IsOfficial ? 1 : 0, BattleModeId: BattleModes.TakeTwo); } + + public async Task BuildForColosseumAsync(long viewerId) + { + var run = await _colosseumRuns.GetByViewerIdAsync(viewerId) + ?? throw new InvalidOperationException("arena_colosseum_no_active_run"); + + // v1 single-deck slot — Round-3 multi-deck format is deferred per plan. + var deckNos = JsonSerializer.Deserialize>(run.RegisteredDeckNoListJson) ?? new(); + if (deckNos.Count == 0) + { + throw new InvalidOperationException("arena_colosseum_no_deck_registered"); + } + var deckNo = deckNos[0]; + + var viewer = await _viewers.LoadForMatchContextAsync(viewerId) + ?? throw new InvalidOperationException($"viewer {viewerId} not found"); + + var deck = await _decks.GetDeck(viewerId, run.DeckFormat, deckNo) + ?? throw new InvalidOperationException( + $"viewer {viewerId} has no deck #{deckNo} for format {run.DeckFormat}"); + + var defaults = _config.Get(); + var emblemId = viewer.Info.SelectedEmblem.Id != 0 + ? viewer.Info.SelectedEmblem.Id.ToString() + : defaults.EmblemId.ToString(); + var degreeId = viewer.Info.SelectedDegree.Id != 0 + ? viewer.Info.SelectedDegree.Id.ToString() + : defaults.DegreeId.ToString(); + var charaId = run.LeaderSkinId != 0 + ? run.LeaderSkinId.ToString() + : deck.LeaderSkin.Id != 0 + ? deck.LeaderSkin.Id.ToString() + : deck.Class.Id.ToString(); + var sleeveId = deck.Sleeve.Id != 0 + ? deck.Sleeve.Id.ToString() + : defaults.SleeveId.ToString(); + var deckCardIds = deck.Cards + .SelectMany(c => Enumerable.Repeat(c.Card.Id, c.Count)) + .ToList(); + + return new MatchContext( + SelfDeckCardIds: deckCardIds, + ClassId: (CardClass)deck.Class.Id, + CharaId: charaId, + CardMasterName: "card_master_node_10015", + CountryCode: viewer.Info.CountryCode ?? string.Empty, + UserName: viewer.DisplayName, + SleeveId: sleeveId, + EmblemId: emblemId, + DegreeId: degreeId, + FieldId: 43, + IsOfficial: viewer.Info.IsOfficial ? 1 : 0, + BattleModeId: BattleModes.TakeTwo); + } } diff --git a/SVSim.UnitTests/Controllers/ArenaColosseumBattleControllerTests.cs b/SVSim.UnitTests/Controllers/ArenaColosseumBattleControllerTests.cs new file mode 100644 index 00000000..07cc21a7 --- /dev/null +++ b/SVSim.UnitTests/Controllers/ArenaColosseumBattleControllerTests.cs @@ -0,0 +1,156 @@ +using System.Net; +using System.Net.Http.Json; +using System.Text.Json; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using SVSim.Database; +using SVSim.Database.Enums; +using SVSim.Database.Models; +using SVSim.UnitTests.Infrastructure; + +namespace SVSim.UnitTests.Controllers; + +/// +/// Per-match battle URL coverage — verifies the dual colosseum_battle/* + +/// colosseum_rank_battle/* dispatch matches run.IsRankMatching, that +/// battle/finish bumps the per-round counters, and that the 3008 promotion +/// trigger flips the run's rank flag. +/// +public class ArenaColosseumBattleControllerTests +{ + private static readonly object Envelope = + new { viewer_id = "0", steam_id = 0, steam_session_ticket = "" }; + + private static async Task SeedRunAsync(SVSimTestFactory factory, long viewerId, bool isRankMatching = false) + { + using var scope = factory.Services.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + db.ViewerArenaColosseumRuns.Add(new ViewerArenaColosseumRun + { + ViewerId = viewerId, + EntryId = 1001, + SeasonId = 42, + RoundId = 1, + DeckFormat = Format.Rotation, + MaxBattleCountThisRound = 5, + BreakthroughNumberThisRound = 4, + IsRankMatching = isRankMatching, + RegisteredDeckNoListJson = "[3]", + }); + await db.SaveChangesAsync(); + } + + [Test] + public async Task DoMatching_pre_rank_rejects_when_run_is_rank_matching() + { + using var factory = new SVSimTestFactory(); + var vid = await factory.SeedViewerAsync(); + await SeedRunAsync(factory, vid, isRankMatching: true); + await factory.SeedDeckAsync(vid, Format.Rotation, number: 3); + using var client = factory.CreateAuthenticatedClient(vid); + + var resp = await client.PostAsync("/colosseum_battle/do_matching", JsonContent.Create(Envelope)); + Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); + var body = await resp.Content.ReadAsStringAsync(); + StringAssert.Contains("colosseum_url_phase_mismatch", body); + } + + [Test] + public async Task DoMatching_post_rank_rejects_when_run_is_pre_rank() + { + using var factory = new SVSimTestFactory(); + var vid = await factory.SeedViewerAsync(); + await SeedRunAsync(factory, vid, isRankMatching: false); + await factory.SeedDeckAsync(vid, Format.Rotation, number: 3); + using var client = factory.CreateAuthenticatedClient(vid); + + var resp = await client.PostAsync("/colosseum_rank_battle/do_matching", JsonContent.Create(Envelope)); + Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); + var body = await resp.Content.ReadAsStringAsync(); + StringAssert.Contains("colosseum_url_phase_mismatch", body); + } + + [Test] + public async Task DoMatching_returns_3001_when_no_deck_registered() + { + using var factory = new SVSimTestFactory(); + var vid = await factory.SeedViewerAsync(); + + using (var scope = factory.Services.CreateScope()) + { + var db = scope.ServiceProvider.GetRequiredService(); + db.ViewerArenaColosseumRuns.Add(new ViewerArenaColosseumRun + { + ViewerId = vid, + EntryId = 1001, + SeasonId = 42, + RoundId = 1, + DeckFormat = Format.Rotation, + RegisteredDeckNoListJson = "[]", + }); + await db.SaveChangesAsync(); + } + + using var client = factory.CreateAuthenticatedClient(vid); + var resp = await client.PostAsync("/colosseum_battle/do_matching", JsonContent.Create(Envelope)); + Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + + var body = await resp.Content.ReadAsStringAsync(); + using var doc = JsonDocument.Parse(body); + Assert.That(doc.RootElement.GetProperty("matching_state").GetInt32(), Is.EqualTo(3001)); + } + + [Test] + public async Task BattleFinish_win_advances_counters_and_appends_result_list() + { + using var factory = new SVSimTestFactory(); + var vid = await factory.SeedViewerAsync(); + await SeedRunAsync(factory, vid); + using var client = factory.CreateAuthenticatedClient(vid); + + var req = new + { + battle_result = 1, is_retire = 0, class_id = 1, + total_turn = 5, evolve_count = 1, enemy_evolve_count = 0, + recovery_data = "", + viewer_id = "0", steam_id = 0, steam_session_ticket = "", + }; + var resp = await client.PostAsync("/colosseum_battle/finish", JsonContent.Create(req)); + Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + + using var scope = factory.Services.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + var run = await db.ViewerArenaColosseumRuns.FirstAsync(r => r.ViewerId == vid); + Assert.That(run.WinCount, Is.EqualTo(1)); + Assert.That(run.LossCount, Is.EqualTo(0)); + Assert.That(run.BattleCountThisRound, Is.EqualTo(1)); + Assert.That(run.ResultListJson, Is.EqualTo("[1]")); + } + + [Test] + public async Task BattleFinish_retire_does_not_advance_counters() + { + using var factory = new SVSimTestFactory(); + var vid = await factory.SeedViewerAsync(); + await SeedRunAsync(factory, vid); + using var client = factory.CreateAuthenticatedClient(vid); + + var req = new + { + battle_result = 2, is_retire = 1, class_id = 1, + total_turn = 3, evolve_count = 0, enemy_evolve_count = 0, + recovery_data = "", + viewer_id = "0", steam_id = 0, steam_session_ticket = "", + }; + var resp = await client.PostAsync("/colosseum_battle/finish", JsonContent.Create(req)); + Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + + using var scope = factory.Services.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + var run = await db.ViewerArenaColosseumRuns.FirstAsync(r => r.ViewerId == vid); + Assert.That(run.WinCount, Is.EqualTo(0)); + Assert.That(run.LossCount, Is.EqualTo(0)); + Assert.That(run.BattleCountThisRound, Is.EqualTo(0), + "is_retire=1 must not bump the per-round battle counter"); + } +} diff --git a/SVSim.UnitTests/Controllers/ArenaColosseumControllerBracketTerminateTests.cs b/SVSim.UnitTests/Controllers/ArenaColosseumControllerBracketTerminateTests.cs new file mode 100644 index 00000000..017ca313 --- /dev/null +++ b/SVSim.UnitTests/Controllers/ArenaColosseumControllerBracketTerminateTests.cs @@ -0,0 +1,244 @@ +using System.Net; +using System.Net.Http.Json; +using System.Text.Json; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using SVSim.Database; +using SVSim.Database.Enums; +using SVSim.Database.Models; +using SVSim.UnitTests.Infrastructure; + +namespace SVSim.UnitTests.Controllers; + +/// +/// Bracket-end /finish + /retire coverage. Locks the wire shape (rewards + reward_list + +/// colosseum_status) and verifies side-effects: rewards granted through the inventory +/// service, run row deleted, champion flag flipped on final-round clear. +/// +public class ArenaColosseumControllerBracketTerminateTests +{ + private static readonly object Envelope = + new { viewer_id = "0", steam_id = 0, steam_session_ticket = "" }; + + /// Three-round config with reward bundles on every round + a champion bundle. + private static async Task ActivateSeasonWithRewardsAsync(SVSimTestFactory factory) + { + using var scope = factory.Services.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + + var seasonJson = JsonSerializer.Serialize(new + { + IsColosseumPeriod = true, + SeasonId = 42, + ColosseumName = "Test Cup", + DeckFormat = (int)Format.Rotation, + FinalRoundEliminateCount = 1000, + }); + await UpsertConfigAsync(db, "ColosseumSeason", seasonJson); + + var roundsJson = JsonSerializer.Serialize(new + { + Rounds = new[] + { + new + { + RoundId = 1, + Groups = new[] { new { Group = "", MaxBattleCount = 5, BreakthroughNumber = 3, EntryNumber = 100_000 } }, + FinishRewards = new[] + { + new { Type = (int)UserGoodsType.Crystal, DetailId = 0L, Count = 100, Name = "R1 finish" }, + }, + RetireRewards = new object[] + { + new { Type = (int)UserGoodsType.Rupy, DetailId = 0L, Count = 50, Name = "R1 retire" }, + }, + }, + new + { + RoundId = 2, + Groups = new[] { new { Group = "Group A", MaxBattleCount = 5, BreakthroughNumber = 4, EntryNumber = 10_000 } }, + FinishRewards = new[] + { + new { Type = (int)UserGoodsType.Crystal, DetailId = 0L, Count = 250, Name = "R2 finish" }, + }, + RetireRewards = Array.Empty(), + }, + new + { + RoundId = 3, + Groups = new[] { new { Group = "Final", MaxBattleCount = 5, BreakthroughNumber = 4, EntryNumber = 1_000 } }, + FinishRewards = new[] + { + new { Type = (int)UserGoodsType.Crystal, DetailId = 0L, Count = 1000, Name = "Final clear" }, + }, + RetireRewards = Array.Empty(), + }, + }, + ChampionRewards = new[] + { + new { Type = (int)UserGoodsType.Crystal, DetailId = 0L, Count = 5000, Name = "Champion Pack" }, + }, + }); + await UpsertConfigAsync(db, "ColosseumRounds", roundsJson); + } + + private static async Task UpsertConfigAsync(SVSimDbContext db, string section, string json) + { + var existing = await db.GameConfigs.FirstOrDefaultAsync(s => s.SectionName == section); + if (existing is null) + db.GameConfigs.Add(new GameConfigSection { SectionName = section, ValueJson = json }); + else + existing.ValueJson = json; + await db.SaveChangesAsync(); + } + + private static async Task SeedRunAsync( + SVSimTestFactory factory, long viewerId, int roundId, int winCount, int battleCount) + { + using var scope = factory.Services.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + db.ViewerArenaColosseumRuns.Add(new ViewerArenaColosseumRun + { + ViewerId = viewerId, + EntryId = 1001, + SeasonId = 42, + RoundId = roundId, + DeckFormat = Format.Rotation, + WinCount = winCount, + BattleCountThisRound = battleCount, + MaxBattleCountThisRound = 5, + BreakthroughNumberThisRound = roundId == 1 ? 3 : 4, + }); + await db.SaveChangesAsync(); + } + + [Test] + public async Task Finish_emits_champion_flag_when_round_3_cleared() + { + using var factory = new SVSimTestFactory(); + await ActivateSeasonWithRewardsAsync(factory); + var vid = await factory.SeedViewerAsync(); + await SeedRunAsync(factory, vid, roundId: 3, winCount: 4, battleCount: 4); + + using var client = factory.CreateAuthenticatedClient(vid); + var resp = await client.PostAsync("/arena_colosseum/finish", JsonContent.Create(Envelope)); + Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + + var body = await resp.Content.ReadAsStringAsync(); + using var doc = JsonDocument.Parse(body); + var root = doc.RootElement; + + Assert.That(root.GetProperty("colosseum_status").GetProperty("is_champion").GetBoolean(), Is.True); + Assert.That(root.GetProperty("colosseum_status").GetProperty("colosseum_name").GetString(), + Is.EqualTo("Test Cup")); + + // Final clear + champion bundle = 2 reward entries. + Assert.That(root.GetProperty("rewards").GetArrayLength(), Is.EqualTo(2)); + Assert.That(root.GetProperty("reward_list").GetArrayLength(), Is.EqualTo(2)); + } + + [Test] + public async Task Finish_grants_rewards_and_deletes_run() + { + using var factory = new SVSimTestFactory(); + await ActivateSeasonWithRewardsAsync(factory); + var vid = await factory.SeedViewerAsync(); + // Round 1 breakthrough advances to round 2 — bracket isn't finished. Use round 3 + + // exhausted battle cap WITHOUT breakthrough to terminate cleanly with round-end rewards. + await SeedRunAsync(factory, vid, roundId: 3, winCount: 2, battleCount: 5); + + ulong crystalsBefore; + using (var beforeScope = factory.Services.CreateScope()) + { + var beforeDb = beforeScope.ServiceProvider.GetRequiredService(); + crystalsBefore = (await beforeDb.Viewers.FirstAsync(v => v.Id == vid)).Currency.Crystals; + } + + using var client = factory.CreateAuthenticatedClient(vid); + var resp = await client.PostAsync("/arena_colosseum/finish", JsonContent.Create(Envelope)); + Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + + using var verifyScope = factory.Services.CreateScope(); + var db = verifyScope.ServiceProvider.GetRequiredService(); + + var run = await db.ViewerArenaColosseumRuns.FirstOrDefaultAsync(r => r.ViewerId == vid); + Assert.That(run, Is.Null, "run row must be deleted on /finish"); + + var viewer = await db.Viewers.FirstAsync(v => v.Id == vid); + Assert.That(viewer.Currency.Crystals - crystalsBefore, Is.EqualTo(1000UL), + "Round 3 finish bundle is 1000 Crystal (not champion — battle cap hit without breakthrough)"); + } + + [Test] + public async Task Finish_rejects_when_bracket_still_in_progress() + { + using var factory = new SVSimTestFactory(); + await ActivateSeasonWithRewardsAsync(factory); + var vid = await factory.SeedViewerAsync(); + // Mid-round: 1 win, 1 battle, breakthrough is 3 — not yet eligible. + await SeedRunAsync(factory, vid, roundId: 1, winCount: 1, battleCount: 1); + + using var client = factory.CreateAuthenticatedClient(vid); + var resp = await client.PostAsync("/arena_colosseum/finish", JsonContent.Create(Envelope)); + Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); + + var body = await resp.Content.ReadAsStringAsync(); + StringAssert.Contains("bracket_not_finished", body); + } + + [Test] + public async Task Retire_grants_round_capped_rewards_and_deletes_run() + { + using var factory = new SVSimTestFactory(); + await ActivateSeasonWithRewardsAsync(factory); + var vid = await factory.SeedViewerAsync(); + await SeedRunAsync(factory, vid, roundId: 1, winCount: 1, battleCount: 2); + + ulong rupeesBefore; + using (var beforeScope = factory.Services.CreateScope()) + { + var beforeDb = beforeScope.ServiceProvider.GetRequiredService(); + rupeesBefore = (await beforeDb.Viewers.FirstAsync(v => v.Id == vid)).Currency.Rupees; + } + + using var client = factory.CreateAuthenticatedClient(vid); + var resp = await client.PostAsync("/arena_colosseum/retire", JsonContent.Create(Envelope)); + Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + + var body = await resp.Content.ReadAsStringAsync(); + using var doc = JsonDocument.Parse(body); + var root = doc.RootElement; + Assert.That(root.GetProperty("rewards").GetArrayLength(), Is.EqualTo(1)); + Assert.That(root.GetProperty("rewards")[0].GetProperty("name").GetString(), Is.EqualTo("R1 retire")); + + using var verifyScope = factory.Services.CreateScope(); + var db = verifyScope.ServiceProvider.GetRequiredService(); + var run = await db.ViewerArenaColosseumRuns.FirstOrDefaultAsync(r => r.ViewerId == vid); + Assert.That(run, Is.Null, "run row must be deleted on /retire"); + + var viewer = await db.Viewers.FirstAsync(v => v.Id == vid); + Assert.That(viewer.Currency.Rupees - rupeesBefore, Is.EqualTo(50UL), + "Round 1 retire bundle adds 50 Rupy on top of starting balance"); + } + + [Test] + public async Task Retire_during_final_round_still_works_and_emits_status() + { + using var factory = new SVSimTestFactory(); + await ActivateSeasonWithRewardsAsync(factory); + var vid = await factory.SeedViewerAsync(); + // Round 3 has empty RetireRewards per config — client ignores rewards at FinalB anyway. + await SeedRunAsync(factory, vid, roundId: 3, winCount: 2, battleCount: 3); + + using var client = factory.CreateAuthenticatedClient(vid); + var resp = await client.PostAsync("/arena_colosseum/retire", JsonContent.Create(Envelope)); + Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + + var body = await resp.Content.ReadAsStringAsync(); + using var doc = JsonDocument.Parse(body); + Assert.That(doc.RootElement.GetProperty("rewards").GetArrayLength(), Is.EqualTo(0), + "FinalB retire emits empty rewards per retire.md"); + Assert.That(doc.RootElement.GetProperty("colosseum_status").GetProperty("now_round_id").GetInt32(), + Is.EqualTo(3)); + } +} diff --git a/SVSim.UnitTests/Controllers/ArenaColosseumControllerCuratedDeckTests.cs b/SVSim.UnitTests/Controllers/ArenaColosseumControllerCuratedDeckTests.cs new file mode 100644 index 00000000..0e202aea --- /dev/null +++ b/SVSim.UnitTests/Controllers/ArenaColosseumControllerCuratedDeckTests.cs @@ -0,0 +1,200 @@ +using System.Net; +using System.Net.Http.Json; +using System.Text.Json; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using SVSim.Database; +using SVSim.Database.Enums; +using SVSim.Database.Models; +using SVSim.UnitTests.Infrastructure; + +namespace SVSim.UnitTests.Controllers; + +/// +/// Phase 3 curated-deck coverage — the 3 list URLs and 3 register URLs share one +/// generic dispatcher; the same scenarios are parameterized across HOF / WindFall / Avatar +/// to lock per-pool isolation. +/// +public class ArenaColosseumControllerCuratedDeckTests +{ + private static readonly object Envelope = + new { viewer_id = "0", steam_id = 0, steam_session_ticket = "" }; + + public enum Pool { Hof, WindFall, Avatar } + + private static string ListUrl(Pool pool) => pool switch + { + Pool.Hof => "/arena_colosseum/get_hof_deck_list", + Pool.WindFall => "/arena_colosseum/get_windfall_deck_list", + Pool.Avatar => "/arena_colosseum/get_avatar_deck_list", + _ => throw new ArgumentOutOfRangeException(), + }; + + private static string RegisterUrl(Pool pool) => pool switch + { + Pool.Hof => "/arena_colosseum/register_hof_deck", + Pool.WindFall => "/arena_colosseum/register_windfall_deck", + Pool.Avatar => "/arena_colosseum/register_avatar_deck", + _ => throw new ArgumentOutOfRangeException(), + }; + + private static async Task SeedCuratedDecksAsync(SVSimTestFactory factory, Pool pool, params int[] deckNos) + { + using var scope = factory.Services.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + foreach (var no in deckNos) + { + switch (pool) + { + case Pool.Hof: + db.ColosseumHofDecks.Add(new ColosseumHofDeck + { + DeckNo = no, ClassId = 1, DisplayOrder = no, + CardListJson = "[101,102,103]", SleeveId = 3000011, + }); + break; + case Pool.WindFall: + db.ColosseumWindFallDecks.Add(new ColosseumWindFallDeck + { + DeckNo = no, ClassId = 2, DisplayOrder = no, + CardListJson = "[201,202,203]", + }); + break; + case Pool.Avatar: + db.ColosseumAvatarDecks.Add(new ColosseumAvatarDeck + { + DeckNo = no, ClassId = 3, DisplayOrder = no, + CardListJson = "[301,302,303]", LeaderSkinId = 70000, + }); + break; + } + } + await db.SaveChangesAsync(); + } + + private static async Task SeedRunAsync(SVSimTestFactory factory, long viewerId) + { + using var scope = factory.Services.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + db.ViewerArenaColosseumRuns.Add(new ViewerArenaColosseumRun + { + ViewerId = viewerId, + EntryId = 9999, + SeasonId = 7, + RoundId = 1, + DeckFormat = Format.Hof, + }); + await db.SaveChangesAsync(); + } + + [Test] + [TestCase(Pool.Hof)] + [TestCase(Pool.WindFall)] + [TestCase(Pool.Avatar)] + public async Task GetDeckList_returns_seeded_entries_as_bare_array(Pool pool) + { + using var factory = new SVSimTestFactory(); + await SeedCuratedDecksAsync(factory, pool, 1001, 1002); + var vid = await factory.SeedViewerAsync(); + using var client = factory.CreateAuthenticatedClient(vid); + + var resp = await client.PostAsync(ListUrl(pool), JsonContent.Create(Envelope)); + Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + + var body = await resp.Content.ReadAsStringAsync(); + using var doc = JsonDocument.Parse(body); + Assert.That(doc.RootElement.ValueKind, Is.EqualTo(JsonValueKind.Array), + $"{pool}: spec requires a BARE array at data — client iterates without a wrapper"); + Assert.That(doc.RootElement.GetArrayLength(), Is.EqualTo(2)); + Assert.That(doc.RootElement[0].GetProperty("deck_id").GetInt32(), Is.EqualTo(1001)); + } + + [Test] + [TestCase(Pool.Hof)] + [TestCase(Pool.WindFall)] + [TestCase(Pool.Avatar)] + public async Task RegisterDeck_round_trips_deck_no_list(Pool pool) + { + using var factory = new SVSimTestFactory(); + await SeedCuratedDecksAsync(factory, pool, 1001); + var vid = await factory.SeedViewerAsync(); + await SeedRunAsync(factory, vid); + using var client = factory.CreateAuthenticatedClient(vid); + + var resp = await client.PostAsync(RegisterUrl(pool), + JsonContent.Create(new { deck_no_list = "[1001]", viewer_id = "0", steam_id = 0, steam_session_ticket = "" })); + Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + + using var scope = factory.Services.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + var run = await db.ViewerArenaColosseumRuns.FirstAsync(r => r.ViewerId == vid); + Assert.That(run.RegisteredDeckNoListJson, Is.EqualTo("[1001]")); + } + + [Test] + [TestCase(Pool.Hof)] + [TestCase(Pool.WindFall)] + [TestCase(Pool.Avatar)] + public async Task RegisterDeck_rejects_unknown_deck_no(Pool pool) + { + using var factory = new SVSimTestFactory(); + await SeedCuratedDecksAsync(factory, pool, 1001); + var vid = await factory.SeedViewerAsync(); + await SeedRunAsync(factory, vid); + using var client = factory.CreateAuthenticatedClient(vid); + + var resp = await client.PostAsync(RegisterUrl(pool), + JsonContent.Create(new { deck_no_list = "[9999]", viewer_id = "0", steam_id = 0, steam_session_ticket = "" })); + Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); + + var body = await resp.Content.ReadAsStringAsync(); + StringAssert.Contains("deck_not_found", body); + } + + [Test] + public async Task Cross_pool_register_rejected_hof_against_windfall() + { + using var factory = new SVSimTestFactory(); + // 1001 lives in HOF only. + await SeedCuratedDecksAsync(factory, Pool.Hof, 1001); + var vid = await factory.SeedViewerAsync(); + await SeedRunAsync(factory, vid); + using var client = factory.CreateAuthenticatedClient(vid); + + // Register against WindFall — the HOF deck_no should not resolve. + var resp = await client.PostAsync(RegisterUrl(Pool.WindFall), + JsonContent.Create(new { deck_no_list = "[1001]", viewer_id = "0", steam_id = 0, steam_session_ticket = "" })); + Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); + + var body = await resp.Content.ReadAsStringAsync(); + StringAssert.Contains("deck_not_found", body); + } + + [Test] + public async Task RegisterDeck_clears_is_published_flag_on_swap_from_constructed() + { + using var factory = new SVSimTestFactory(); + await SeedCuratedDecksAsync(factory, Pool.Hof, 1001); + var vid = await factory.SeedViewerAsync(); + await SeedRunAsync(factory, vid); + + // Simulate the viewer having previously registered a constructed deck with is_published=true. + using (var scope = factory.Services.CreateScope()) + { + var db = scope.ServiceProvider.GetRequiredService(); + var run = await db.ViewerArenaColosseumRuns.FirstAsync(r => r.ViewerId == vid); + run.IsPublished = true; + await db.SaveChangesAsync(); + } + + using var client = factory.CreateAuthenticatedClient(vid); + await client.PostAsync(RegisterUrl(Pool.Hof), + JsonContent.Create(new { deck_no_list = "[1001]", viewer_id = "0", steam_id = 0, steam_session_ticket = "" })); + + using var verifyScope = factory.Services.CreateScope(); + var verifyDb = verifyScope.ServiceProvider.GetRequiredService(); + var verifyRun = await verifyDb.ViewerArenaColosseumRuns.FirstAsync(r => r.ViewerId == vid); + Assert.That(verifyRun.IsPublished, Is.False, + "curated register has no is_published wire field — server clears it to keep state consistent"); + } +} diff --git a/SVSim.UnitTests/Controllers/ArenaColosseumControllerDraftTests.cs b/SVSim.UnitTests/Controllers/ArenaColosseumControllerDraftTests.cs new file mode 100644 index 00000000..bb8d1d4a --- /dev/null +++ b/SVSim.UnitTests/Controllers/ArenaColosseumControllerDraftTests.cs @@ -0,0 +1,221 @@ +using System.Net; +using System.Net.Http.Json; +using System.Text.Json; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using SVSim.Database; +using SVSim.Database.Enums; +using SVSim.Database.Models; +using SVSim.UnitTests.Infrastructure; + +namespace SVSim.UnitTests.Controllers; + +/// +/// Phase 3 2-Pick draft coverage on /arena_colosseum/{get_candidate_classes, class_choose, +/// get_candidate_cards, card_choose}. Mirrors the existing ArenaTwoPick tests, with the +/// pool override sourced from ColosseumSeasonConfig.PoolCardSetIds instead of +/// ChallengeConfig.PoolCardSetIds. +/// +public class ArenaColosseumControllerDraftTests +{ + private static readonly object Envelope = + new { viewer_id = "0", steam_id = 0, steam_session_ticket = "" }; + + private static async Task ActivateChaosCapableSeasonAsync(SVSimTestFactory factory) + { + using var scope = factory.Services.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + + // Pool override: the test card-set's id (10001) — see SVSimTestFactory.SeedMinimalCardSet. + var seasonJson = JsonSerializer.Serialize(new + { + IsColosseumPeriod = true, + SeasonId = 7, + DeckFormat = (int)Format.TwoPick, + IsNormalTwoPick = true, + PoolCardSetIds = new[] { 10001 }, + }); + await UpsertConfigAsync(db, "ColosseumSeason", seasonJson); + } + + private static async Task UpsertConfigAsync(SVSimDbContext db, string section, string json) + { + var existing = await db.GameConfigs.FirstOrDefaultAsync(s => s.SectionName == section); + if (existing is null) + db.GameConfigs.Add(new GameConfigSection { SectionName = section, ValueJson = json }); + else + existing.ValueJson = json; + await db.SaveChangesAsync(); + } + + private static async Task SeedRunAsync(SVSimTestFactory factory, long viewerId) + { + using var scope = factory.Services.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + db.ViewerArenaColosseumRuns.Add(new ViewerArenaColosseumRun + { + ViewerId = viewerId, + EntryId = 9999, + SeasonId = 7, + RoundId = 1, + DeckFormat = Format.TwoPick, + }); + + // The pool service filters cards by `CollectionInfo != null` — the minimal SVSimTestFactory + // seed lacks that. Stamp it on every card in the test set so the pool service can + // actually emit a candidate pair for any class. + var cards = await db.Cards.ToListAsync(); + foreach (var c in cards) + { + c.CollectionInfo = new CardCollectionInfo { CraftCost = 40, DustReward = 10 }; + } + await db.SaveChangesAsync(); + } + + [Test] + public async Task GetCandidateClasses_seeds_three_classes_on_run() + { + using var factory = new SVSimTestFactory(); + await ActivateChaosCapableSeasonAsync(factory); + var vid = await factory.SeedViewerAsync(); + await SeedRunAsync(factory, vid); + using var client = factory.CreateAuthenticatedClient(vid); + + var resp = await client.PostAsync("/arena_colosseum/get_candidate_classes", + JsonContent.Create(Envelope)); + Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + + var body = await resp.Content.ReadAsStringAsync(); + using var doc = JsonDocument.Parse(body); + var root = doc.RootElement; + + Assert.That(root.GetProperty("class_id_1").GetInt32(), Is.GreaterThan(0)); + Assert.That(root.GetProperty("class_id_2").GetInt32(), Is.GreaterThan(0)); + Assert.That(root.GetProperty("class_id_3").GetInt32(), Is.GreaterThan(0)); + + using var verifyScope = factory.Services.CreateScope(); + var db = verifyScope.ServiceProvider.GetRequiredService(); + var run = await db.ViewerArenaColosseumRuns.FirstAsync(r => r.ViewerId == vid); + var stored = JsonSerializer.Deserialize>(run.CandidateClassIdsJson)!; + Assert.That(stored.Count, Is.EqualTo(3), + "the slate must be persisted onto the run so /class_choose can validate against it"); + } + + [Test] + public async Task ClassChoose_rejects_class_not_in_slate() + { + using var factory = new SVSimTestFactory(); + await ActivateChaosCapableSeasonAsync(factory); + var vid = await factory.SeedViewerAsync(); + await SeedRunAsync(factory, vid); + + // Force a known slate. + using (var scope = factory.Services.CreateScope()) + { + var db = scope.ServiceProvider.GetRequiredService(); + var run = await db.ViewerArenaColosseumRuns.FirstAsync(r => r.ViewerId == vid); + run.CandidateClassIdsJson = "[1,2,3]"; + await db.SaveChangesAsync(); + } + + using var client = factory.CreateAuthenticatedClient(vid); + var resp = await client.PostAsync("/arena_colosseum/class_choose", + JsonContent.Create(new { class_id = 8, viewer_id = "0", steam_id = 0, steam_session_ticket = "" })); + Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); + + var body = await resp.Content.ReadAsStringAsync(); + StringAssert.Contains("class_not_offered", body); + } + + [Test] + public async Task ClassChoose_normal_advances_run_to_turn_1_with_a_pair_offered() + { + using var factory = new SVSimTestFactory(); + await ActivateChaosCapableSeasonAsync(factory); + var vid = await factory.SeedViewerAsync(); + await SeedRunAsync(factory, vid); + using (var scope = factory.Services.CreateScope()) + { + var db = scope.ServiceProvider.GetRequiredService(); + var run = await db.ViewerArenaColosseumRuns.FirstAsync(r => r.ViewerId == vid); + run.CandidateClassIdsJson = "[1,2,3]"; + await db.SaveChangesAsync(); + } + + using var client = factory.CreateAuthenticatedClient(vid); + var resp = await client.PostAsync("/arena_colosseum/class_choose", + JsonContent.Create(new { class_id = 1, viewer_id = "0", steam_id = 0, steam_session_ticket = "" })); + Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + + var body = await resp.Content.ReadAsStringAsync(); + using var doc = JsonDocument.Parse(body); + var root = doc.RootElement; + Assert.That(root.GetProperty("class_info").GetProperty("selected_class_id").GetString(), Is.EqualTo("1"), + "selected_class_id is wire-stringified per existing TwoPick convention"); + Assert.That(root.GetProperty("candidate_card_list").GetArrayLength(), Is.EqualTo(2), + "the pool service emits exactly 2 candidate pairs per turn"); + + using var verifyScope = factory.Services.CreateScope(); + var verifyDb = verifyScope.ServiceProvider.GetRequiredService(); + var verifyRun = await verifyDb.ViewerArenaColosseumRuns.FirstAsync(r => r.ViewerId == vid); + Assert.That(verifyRun.ClassId, Is.EqualTo(1)); + Assert.That(verifyRun.SelectTurn, Is.EqualTo(1)); + } + + [Test] + public async Task CardChoose_appends_to_selected_cards_and_advances_turn() + { + using var factory = new SVSimTestFactory(); + await ActivateChaosCapableSeasonAsync(factory); + var vid = await factory.SeedViewerAsync(); + await SeedRunAsync(factory, vid); + using (var scope = factory.Services.CreateScope()) + { + var db = scope.ServiceProvider.GetRequiredService(); + var run = await db.ViewerArenaColosseumRuns.FirstAsync(r => r.ViewerId == vid); + run.CandidateClassIdsJson = "[1,2,3]"; + await db.SaveChangesAsync(); + } + + using var client = factory.CreateAuthenticatedClient(vid); + // Drive /class_choose to populate the pending pair. + var classResp = await client.PostAsync("/arena_colosseum/class_choose", + JsonContent.Create(new { class_id = 1, viewer_id = "0", steam_id = 0, steam_session_ticket = "" })); + var classBody = await classResp.Content.ReadAsStringAsync(); + using var classDoc = JsonDocument.Parse(classBody); + long firstPairId = long.Parse(classDoc.RootElement.GetProperty("candidate_card_list")[0].GetProperty("id").GetString()!); + + var cardResp = await client.PostAsync("/arena_colosseum/card_choose", + JsonContent.Create(new { selected_id = firstPairId, viewer_id = "0", steam_id = 0, steam_session_ticket = "" })); + Assert.That(cardResp.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + + using var verifyScope = factory.Services.CreateScope(); + var verifyDb = verifyScope.ServiceProvider.GetRequiredService(); + var verifyRun = await verifyDb.ViewerArenaColosseumRuns.FirstAsync(r => r.ViewerId == vid); + var picks = JsonSerializer.Deserialize>(verifyRun.SelectedCardIdsJson)!; + Assert.That(picks.Count, Is.EqualTo(2), + "first card_choose appends both cards from the picked pair"); + Assert.That(verifyRun.SelectTurn, Is.EqualTo(2)); + } + + [Test] + public async Task ClassChoose_chaos_branch_stores_chaos_id_on_run() + { + using var factory = new SVSimTestFactory(); + await ActivateChaosCapableSeasonAsync(factory); + var vid = await factory.SeedViewerAsync(); + await SeedRunAsync(factory, vid); + + using var client = factory.CreateAuthenticatedClient(vid); + var resp = await client.PostAsync("/arena_colosseum/class_choose", + JsonContent.Create(new { chaos_id = 101, viewer_id = "0", steam_id = 0, steam_session_ticket = "" })); + Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + + using var scope = factory.Services.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + var run = await db.ViewerArenaColosseumRuns.FirstAsync(r => r.ViewerId == vid); + Assert.That(run.ChaosId, Is.EqualTo(101)); + Assert.That(run.ClassId, Is.GreaterThan(0), + "chaos id must resolve to a non-zero class for the pool service"); + } +} diff --git a/SVSim.UnitTests/Controllers/ArenaColosseumControllerEntryTests.cs b/SVSim.UnitTests/Controllers/ArenaColosseumControllerEntryTests.cs new file mode 100644 index 00000000..f4e5009b --- /dev/null +++ b/SVSim.UnitTests/Controllers/ArenaColosseumControllerEntryTests.cs @@ -0,0 +1,238 @@ +using System.Net; +using System.Net.Http.Json; +using System.Text.Json; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using SVSim.Database; +using SVSim.Database.Enums; +using SVSim.Database.Models; +using SVSim.UnitTests.Infrastructure; + +namespace SVSim.UnitTests.Controllers; + +/// +/// Phase 1 entry + register-deck coverage. Activating the Colosseum season requires writing +/// a ColosseumSeason + ColosseumRounds row to GameConfigs — see +/// for the test-only equivalent of the admin flow. +/// +public class ArenaColosseumControllerEntryTests +{ + private static readonly object Envelope = + new { viewer_id = "0", steam_id = 0, steam_session_ticket = "" }; + + private static async Task ActivateSeasonAsync(SVSimTestFactory factory, int crystalCost = 300) + { + using var scope = factory.Services.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + + var seasonJson = JsonSerializer.Serialize(new + { + IsColosseumPeriod = true, + SeasonId = 42, + ColosseumName = "Test Cup", + DeckFormat = (int)Format.Rotation, + CrystalCost = crystalCost, + RupyCost = 3000, + TicketCost = 1, + IsAllowedFreeEntry = false, + }); + await UpsertConfigAsync(db, "ColosseumSeason", seasonJson); + + var roundsJson = JsonSerializer.Serialize(new + { + Rounds = new[] + { + new + { + RoundId = 1, + StartTime = DateTime.UtcNow.AddDays(-1), + EndTime = DateTime.UtcNow.AddDays(7), + Groups = new[] + { + new { Group = "", MaxBattleCount = 5, BreakthroughNumber = 4, EntryNumber = 100_000 }, + }, + }, + }, + }); + await UpsertConfigAsync(db, "ColosseumRounds", roundsJson); + } + + private static async Task UpsertConfigAsync(SVSimDbContext db, string section, string json) + { + var existing = await db.GameConfigs.FirstOrDefaultAsync(s => s.SectionName == section); + if (existing is null) + db.GameConfigs.Add(new GameConfigSection { SectionName = section, ValueJson = json }); + else + existing.ValueJson = json; + await db.SaveChangesAsync(); + } + + private static async Task SetViewerCurrencyAsync(SVSimTestFactory factory, long viewerId, ulong crystals = 0, ulong rupees = 0) + { + using var scope = factory.Services.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + var viewer = await db.Viewers.FirstAsync(v => v.Id == viewerId); + viewer.Currency.Crystals = crystals; + viewer.Currency.Rupees = rupees; + await db.SaveChangesAsync(); + } + + [Test] + public async Task Entry_debits_crystal_and_creates_run() + { + using var factory = new SVSimTestFactory(); + await ActivateSeasonAsync(factory, crystalCost: 300); + var viewerId = await factory.SeedViewerAsync(); + await SetViewerCurrencyAsync(factory, viewerId, crystals: 1000); + using var client = factory.CreateAuthenticatedClient(viewerId); + + var resp = await client.PostAsync("/arena_colosseum/entry", + JsonContent.Create(new { consume_item_type = 1, now_round_id = 1, viewer_id = "0", steam_id = 0, steam_session_ticket = "" })); + Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + + var body = await resp.Content.ReadAsStringAsync(); + using var doc = JsonDocument.Parse(body); + var root = doc.RootElement; + Assert.That(root.GetProperty("reward_list").GetArrayLength(), Is.EqualTo(1)); + Assert.That(root.GetProperty("reward_list")[0].GetProperty("reward_type").GetInt32(), Is.EqualTo((int)UserGoodsType.Crystal)); + Assert.That(root.GetProperty("entry_info").GetProperty("deck_format").GetInt32(), Is.EqualTo((int)Format.Rotation)); + + using var scope = factory.Services.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + var run = await db.ViewerArenaColosseumRuns.FirstOrDefaultAsync(r => r.ViewerId == viewerId); + Assert.That(run, Is.Not.Null); + Assert.That(run!.SeasonId, Is.EqualTo(42)); + Assert.That(run.MaxBattleCountThisRound, Is.EqualTo(5)); + Assert.That(run.BreakthroughNumberThisRound, Is.EqualTo(4)); + + var viewerAfter = await db.Viewers.FirstAsync(v => v.Id == viewerId); + Assert.That(viewerAfter.Currency.Crystals, Is.EqualTo(700UL), "1000 - 300 cost"); + } + + [Test] + public async Task Entry_rejects_when_season_inactive() + { + using var factory = new SVSimTestFactory(); + var viewerId = await factory.SeedViewerAsync(); + using var client = factory.CreateAuthenticatedClient(viewerId); + + var resp = await client.PostAsync("/arena_colosseum/entry", + JsonContent.Create(new { consume_item_type = 1, now_round_id = 1, viewer_id = "0", steam_id = 0, steam_session_ticket = "" })); + Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); + + var body = await resp.Content.ReadAsStringAsync(); + StringAssert.Contains("colosseum_period_closed", body); + } + + [Test] + public async Task Entry_rejects_when_already_in_run() + { + using var factory = new SVSimTestFactory(); + await ActivateSeasonAsync(factory); + var viewerId = await factory.SeedViewerAsync(); + await SetViewerCurrencyAsync(factory, viewerId, crystals: 1000); + + using (var scope = factory.Services.CreateScope()) + { + var db = scope.ServiceProvider.GetRequiredService(); + db.ViewerArenaColosseumRuns.Add(new ViewerArenaColosseumRun + { + ViewerId = viewerId, + EntryId = 999, + SeasonId = 42, + RoundId = 1, + DeckFormat = Format.Rotation, + }); + await db.SaveChangesAsync(); + } + + using var client = factory.CreateAuthenticatedClient(viewerId); + var resp = await client.PostAsync("/arena_colosseum/entry", + JsonContent.Create(new { consume_item_type = 1, now_round_id = 1, viewer_id = "0", steam_id = 0, steam_session_ticket = "" })); + Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); + + var body = await resp.Content.ReadAsStringAsync(); + StringAssert.Contains("arena_colosseum_already_in_progress", body); + } + + [Test] + public async Task Entry_rejects_when_now_round_id_mismatch() + { + using var factory = new SVSimTestFactory(); + await ActivateSeasonAsync(factory); + var viewerId = await factory.SeedViewerAsync(); + await SetViewerCurrencyAsync(factory, viewerId, crystals: 1000); + using var client = factory.CreateAuthenticatedClient(viewerId); + + var resp = await client.PostAsync("/arena_colosseum/entry", + JsonContent.Create(new { consume_item_type = 1, now_round_id = 7, viewer_id = "0", steam_id = 0, steam_session_ticket = "" })); + Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); + + var body = await resp.Content.ReadAsStringAsync(); + StringAssert.Contains("now_round_id_mismatch", body); + } + + [Test] + public async Task RegisterDeck_round_trips_deck_no_list() + { + using var factory = new SVSimTestFactory(); + await ActivateSeasonAsync(factory); + var viewerId = await factory.SeedViewerAsync(); + await factory.SeedDeckAsync(viewerId, Format.Rotation, number: 3, name: "Colo Deck 3"); + + using (var scope = factory.Services.CreateScope()) + { + var db = scope.ServiceProvider.GetRequiredService(); + db.ViewerArenaColosseumRuns.Add(new ViewerArenaColosseumRun + { + ViewerId = viewerId, + EntryId = 999, + SeasonId = 42, + RoundId = 1, + DeckFormat = Format.Rotation, + }); + await db.SaveChangesAsync(); + } + + using var client = factory.CreateAuthenticatedClient(viewerId); + var resp = await client.PostAsync("/arena_colosseum/register_deck", + JsonContent.Create(new { deck_no_list = "[3]", is_published = true, viewer_id = "0", steam_id = 0, steam_session_ticket = "" })); + Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + + using var verifyScope = factory.Services.CreateScope(); + var verifyDb = verifyScope.ServiceProvider.GetRequiredService(); + var run = await verifyDb.ViewerArenaColosseumRuns.FirstAsync(r => r.ViewerId == viewerId); + Assert.That(run.RegisteredDeckNoListJson, Is.EqualTo("[3]")); + Assert.That(run.IsPublished, Is.True); + } + + [Test] + public async Task RegisterDeck_rejects_when_deck_not_found() + { + using var factory = new SVSimTestFactory(); + await ActivateSeasonAsync(factory); + var viewerId = await factory.SeedViewerAsync(); + + using (var scope = factory.Services.CreateScope()) + { + var db = scope.ServiceProvider.GetRequiredService(); + db.ViewerArenaColosseumRuns.Add(new ViewerArenaColosseumRun + { + ViewerId = viewerId, + EntryId = 999, + SeasonId = 42, + RoundId = 1, + DeckFormat = Format.Rotation, + }); + await db.SaveChangesAsync(); + } + + using var client = factory.CreateAuthenticatedClient(viewerId); + var resp = await client.PostAsync("/arena_colosseum/register_deck", + JsonContent.Create(new { deck_no_list = "[99]", is_published = false, viewer_id = "0", steam_id = 0, steam_session_ticket = "" })); + Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); + + var body = await resp.Content.ReadAsStringAsync(); + StringAssert.Contains("deck_not_found", body); + } +} diff --git a/SVSim.UnitTests/Controllers/ArenaColosseumControllerTests.cs b/SVSim.UnitTests/Controllers/ArenaColosseumControllerTests.cs new file mode 100644 index 00000000..cf7186c0 --- /dev/null +++ b/SVSim.UnitTests/Controllers/ArenaColosseumControllerTests.cs @@ -0,0 +1,138 @@ +using System.Net; +using System.Net.Http.Json; +using System.Text.Json; +using Microsoft.Extensions.DependencyInjection; +using SVSim.Database; +using SVSim.Database.Enums; +using SVSim.Database.Models; +using SVSim.UnitTests.Infrastructure; + +namespace SVSim.UnitTests.Controllers; + +/// +/// Phase 1 lobby read coverage: /arena_colosseum/{top, get_fee_info, event_info}. +/// Defaults (no ColosseumSeason override) must render an empty "no event scheduled" +/// payload — flipping the season on is an admin operation. +/// +public class ArenaColosseumControllerTests +{ + private static readonly object Envelope = + new { viewer_id = "0", steam_id = 0, steam_session_ticket = "" }; + + [Test] + public async Task Top_unauthenticated_returns_401() + { + using var factory = new SVSimTestFactory(); + using var client = factory.CreateClient(); + var resp = await client.PostAsync("/arena_colosseum/top", JsonContent.Create(Envelope)); + Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.Unauthorized)); + } + + [Test] + public async Task Top_returns_no_period_when_no_season_active() + { + using var factory = new SVSimTestFactory(); + var viewerId = await factory.SeedViewerAsync(); + using var client = factory.CreateAuthenticatedClient(viewerId); + + var resp = await client.PostAsync("/arena_colosseum/top", JsonContent.Create(Envelope)); + Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + + var body = await resp.Content.ReadAsStringAsync(); + StringAssert.Contains("\"is_colosseum_period\":false", body); + // leader_skin_id must always be emitted (even when 0) per project_wire_null_policy. + StringAssert.Contains("\"leader_skin_id\":0", body); + } + + [Test] + public async Task GetFeeInfo_returns_no_period_when_no_season_active() + { + using var factory = new SVSimTestFactory(); + var viewerId = await factory.SeedViewerAsync(); + using var client = factory.CreateAuthenticatedClient(viewerId); + + var resp = await client.PostAsync("/arena_colosseum/get_fee_info", JsonContent.Create(Envelope)); + Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + + var body = await resp.Content.ReadAsStringAsync(); + StringAssert.Contains("\"is_colosseum_period\":false", body); + // fee_list, is_unfinished_entry_exists, deck_format must be ABSENT when no event. + StringAssert.DoesNotContain("\"fee_list\"", body); + StringAssert.DoesNotContain("\"is_unfinished_entry_exists\"", body); + } + + [Test] + public async Task EventInfo_returns_empty_rounds_when_default_config() + { + using var factory = new SVSimTestFactory(); + var viewerId = await factory.SeedViewerAsync(); + using var client = factory.CreateAuthenticatedClient(viewerId); + + var resp = await client.PostAsync("/arena_colosseum/event_info", JsonContent.Create(Envelope)); + Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + + var body = await resp.Content.ReadAsStringAsync(); + + // The rounds object MUST be string-keyed "1"/"2"/"3" — locking the wire shape per + // event_info.md. Custom STJ converter avoided; explicit [JsonPropertyName("1"|"2"|"3")] + // produces the same on-the-wire bytes. + using var doc = JsonDocument.Parse(body); + var root = doc.RootElement; + Assert.That(root.TryGetProperty("1", out var r1), Is.True, "round '1' must be present"); + Assert.That(root.TryGetProperty("2", out var r2), Is.True, "round '2' must be present"); + Assert.That(root.TryGetProperty("3", out var r3), Is.True, "round '3' must be present"); + + // Default config → no schedule → is_now_round false on all three. + Assert.That(r1.GetProperty("is_now_round").GetBoolean(), Is.False); + Assert.That(r2.GetProperty("is_now_round").GetBoolean(), Is.False); + Assert.That(r3.GetProperty("is_now_round").GetBoolean(), Is.False); + + Assert.That(r1.GetProperty("round_detail").GetArrayLength(), Is.EqualTo(0)); + } + + [Test] + public async Task Top_round_trips_after_entry_seeded() + { + using var factory = new SVSimTestFactory(); + var viewerId = await factory.SeedViewerAsync(); + + // Seed an active run directly — Task 3's /entry endpoint will own creation, but + // /top must reflect the row's identity when one exists. + const long entryId = 12_345L; + using (var scope = factory.Services.CreateScope()) + { + var db = scope.ServiceProvider.GetRequiredService(); + db.ViewerArenaColosseumRuns.Add(new ViewerArenaColosseumRun + { + ViewerId = viewerId, + EntryId = entryId, + SeasonId = 1, + RoundId = 1, + DeckFormat = Format.Rotation, + LeaderSkinId = 0, + ConsumeItemType = 2, + MaxBattleCountThisRound = 5, + BreakthroughNumberThisRound = 4, + RestEntryNum = 0, + WinCount = 1, + LossCount = 0, + ResultListJson = "[1]", + }); + await db.SaveChangesAsync(); + } + + using var client = factory.CreateAuthenticatedClient(viewerId); + var resp = await client.PostAsync("/arena_colosseum/top", JsonContent.Create(Envelope)); + Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + + var body = await resp.Content.ReadAsStringAsync(); + using var doc = JsonDocument.Parse(body); + var root = doc.RootElement; + + Assert.That(root.GetProperty("entry_info").GetProperty("id").GetInt64(), Is.EqualTo(entryId)); + Assert.That(root.GetProperty("now_round_id").GetInt32(), Is.EqualTo(1)); + Assert.That(root.GetProperty("max_battle_count").GetInt32(), Is.EqualTo(5)); + Assert.That(root.GetProperty("battle_results").GetProperty("win_count").GetInt32(), Is.EqualTo(1)); + Assert.That(root.GetProperty("battle_results").GetProperty("result_list").GetArrayLength(), Is.EqualTo(1)); + } +} diff --git a/SVSim.UnitTests/Database/Config/ColosseumRoundsConfigTests.cs b/SVSim.UnitTests/Database/Config/ColosseumRoundsConfigTests.cs new file mode 100644 index 00000000..3da794b9 --- /dev/null +++ b/SVSim.UnitTests/Database/Config/ColosseumRoundsConfigTests.cs @@ -0,0 +1,46 @@ +using System.Linq; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using NUnit.Framework; +using SVSim.Database; +using SVSim.Database.Models.Config; +using SVSim.EmulatedEntrypoint.Services; +using SVSim.UnitTests.Infrastructure; + +namespace SVSim.UnitTests.Database.Config; + +[TestFixture] +public class ColosseumRoundsConfigTests +{ + [Test] + public void ShippedDefaults_emits_empty_rounds() + { + var cfg = ColosseumRoundsConfig.ShippedDefaults(); + Assert.That(cfg.Rounds, Is.Empty, + "default ship state has no rounds — /event_info renders a benign empty payload"); + } + + [Test] + public void Has_ConfigSection_attribute_with_name_ColosseumRounds() + { + var attr = typeof(ColosseumRoundsConfig) + .GetCustomAttributes(typeof(ConfigSectionAttribute), false) + .Cast() + .FirstOrDefault(); + Assert.That(attr, Is.Not.Null); + Assert.That(attr!.Name, Is.EqualTo("ColosseumRounds")); + } + + [Test] + public void Get_through_GameConfigService_round_trips_shipped_defaults() + { + using var factory = new SVSimTestFactory(); + using var scope = factory.Services.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + var svc = new GameConfigService(db, new ConfigurationBuilder().Build()); + + var cfg = svc.Get(); + + Assert.That(cfg.Rounds, Is.Empty); + } +} diff --git a/SVSim.UnitTests/Database/Config/ColosseumSeasonConfigTests.cs b/SVSim.UnitTests/Database/Config/ColosseumSeasonConfigTests.cs new file mode 100644 index 00000000..a305c40a --- /dev/null +++ b/SVSim.UnitTests/Database/Config/ColosseumSeasonConfigTests.cs @@ -0,0 +1,47 @@ +using System.Linq; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using NUnit.Framework; +using SVSim.Database; +using SVSim.Database.Models.Config; +using SVSim.EmulatedEntrypoint.Services; +using SVSim.UnitTests.Infrastructure; + +namespace SVSim.UnitTests.Database.Config; + +[TestFixture] +public class ColosseumSeasonConfigTests +{ + [Test] + public void ShippedDefaults_emits_no_period() + { + var cfg = ColosseumSeasonConfig.ShippedDefaults(); + Assert.That(cfg.IsColosseumPeriod, Is.False, + "default ship state is no event scheduled — lobby reads must render the empty payload"); + } + + [Test] + public void Has_ConfigSection_attribute_with_name_ColosseumSeason() + { + var attr = typeof(ColosseumSeasonConfig) + .GetCustomAttributes(typeof(ConfigSectionAttribute), false) + .Cast() + .FirstOrDefault(); + Assert.That(attr, Is.Not.Null); + Assert.That(attr!.Name, Is.EqualTo("ColosseumSeason")); + } + + [Test] + public void Get_through_GameConfigService_round_trips_shipped_defaults() + { + using var factory = new SVSimTestFactory(); + using var scope = factory.Services.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + var svc = new GameConfigService(db, new ConfigurationBuilder().Build()); + + var cfg = svc.Get(); + + Assert.That(cfg.IsColosseumPeriod, Is.False); + Assert.That(cfg.PoolCardSetIds, Is.Empty); + } +} diff --git a/SVSim.UnitTests/Integration/ArenaColosseumEndToEndTests.cs b/SVSim.UnitTests/Integration/ArenaColosseumEndToEndTests.cs new file mode 100644 index 00000000..d2bc50d6 --- /dev/null +++ b/SVSim.UnitTests/Integration/ArenaColosseumEndToEndTests.cs @@ -0,0 +1,232 @@ +using System.Net; +using System.Net.Http.Json; +using System.Text.Json; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using SVSim.Database; +using SVSim.Database.Enums; +using SVSim.Database.Models; +using SVSim.UnitTests.Infrastructure; + +namespace SVSim.UnitTests.Integration; + +/// +/// Phase 2 ship gate: a viewer walks the full bracket — entry → register_deck → +/// (battle_finish × N) → /finish (champion path), plus a separate retire-mid-round +/// variant. Exercises every Phase 2 endpoint plus Phase 1's /entry + /register_deck. +/// +public class ArenaColosseumEndToEndTests +{ + private static readonly object Envelope = + new { viewer_id = "0", steam_id = 0, steam_session_ticket = "" }; + + private static async Task ConfigureSeasonAsync(SVSimTestFactory factory) + { + using var scope = factory.Services.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + + // Season active, free entry allowed (so we don't have to seed currency). + var seasonJson = JsonSerializer.Serialize(new + { + IsColosseumPeriod = true, + SeasonId = 100, + ColosseumName = "E2E Cup", + DeckFormat = (int)Format.Rotation, + CrystalCost = 0, + RupyCost = 0, + TicketCost = 0, + IsAllowedFreeEntry = true, + FinalRoundEliminateCount = 100, + }); + await UpsertConfigAsync(db, "ColosseumSeason", seasonJson); + + // 3-round bracket. Round 1: BR=2 (clear with 2 wins). Round 2: BR=2. Round 3: BR=2. + var roundsJson = JsonSerializer.Serialize(new + { + Rounds = new[] + { + BuildRound(1, breakthrough: 2, finishCount: 50), + BuildRound(2, breakthrough: 2, finishCount: 100), + BuildRound(3, breakthrough: 2, finishCount: 500), + }, + ChampionRewards = new[] + { + new { Type = (int)UserGoodsType.Crystal, DetailId = 0L, Count = 9999, Name = "E2E Champion" }, + }, + }); + await UpsertConfigAsync(db, "ColosseumRounds", roundsJson); + } + + private static object BuildRound(int roundId, int breakthrough, int finishCount) => new + { + RoundId = roundId, + Groups = new[] + { + new + { + Group = $"R{roundId}", + MaxBattleCount = 5, + BreakthroughNumber = breakthrough, + EntryNumber = 100, + }, + }, + FinishRewards = new[] + { + new + { + Type = (int)UserGoodsType.Crystal, + DetailId = 0L, + Count = finishCount, + Name = $"R{roundId} finish", + }, + }, + RetireRewards = new object[] + { + new + { + Type = (int)UserGoodsType.Rupy, + DetailId = 0L, + Count = 10 * roundId, + Name = $"R{roundId} retire", + }, + }, + }; + + private static async Task UpsertConfigAsync(SVSimDbContext db, string section, string json) + { + var existing = await db.GameConfigs.FirstOrDefaultAsync(s => s.SectionName == section); + if (existing is null) + db.GameConfigs.Add(new GameConfigSection { SectionName = section, ValueJson = json }); + else + existing.ValueJson = json; + await db.SaveChangesAsync(); + } + + private static HttpContent BattleFinishPayload(int battleResult, int isRetire) => + JsonContent.Create(new + { + battle_result = battleResult, + is_retire = isRetire, + class_id = 1, + total_turn = 5, + evolve_count = 1, + enemy_evolve_count = 0, + recovery_data = "", + viewer_id = "0", + steam_id = 0, + steam_session_ticket = "", + }); + + private static async Task PromoteRunToRoundAsync( + SVSimTestFactory factory, long viewerId, int newRoundId) + { + using var scope = factory.Services.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + var run = await db.ViewerArenaColosseumRuns.FirstAsync(r => r.ViewerId == viewerId); + run.RoundId = newRoundId; + run.WinCount = 0; + run.LossCount = 0; + run.BattleCountThisRound = 0; + run.ResultListJson = "[]"; + // Pull the per-round thresholds for the new round (mirrors what /entry copies on + // initial create — Phase 2 doesn't have a real intra-bracket promotion endpoint yet). + run.MaxBattleCountThisRound = 5; + run.BreakthroughNumberThisRound = 2; + await db.SaveChangesAsync(); + } + + [Test] + public async Task Full_three_round_bracket_walk_ends_as_champion() + { + using var factory = new SVSimTestFactory(); + await ConfigureSeasonAsync(factory); + var vid = await factory.SeedViewerAsync(); + await factory.SeedDeckAsync(vid, Format.Rotation, number: 1); + using var client = factory.CreateAuthenticatedClient(vid); + + // /entry (free) + var entryResp = await client.PostAsync("/arena_colosseum/entry", + JsonContent.Create(new { consume_item_type = 5, now_round_id = 1, viewer_id = "0", steam_id = 0, steam_session_ticket = "" })); + Assert.That(entryResp.StatusCode, Is.EqualTo(HttpStatusCode.OK), "entry must succeed"); + + // /register_deck + var registerResp = await client.PostAsync("/arena_colosseum/register_deck", + JsonContent.Create(new { deck_no_list = "[1]", is_published = true, viewer_id = "0", steam_id = 0, steam_session_ticket = "" })); + Assert.That(registerResp.StatusCode, Is.EqualTo(HttpStatusCode.OK), "register_deck must succeed"); + + // Round 1: 2 wins → clears breakthrough. + for (int i = 0; i < 2; i++) + { + var r = await client.PostAsync("/colosseum_battle/finish", BattleFinishPayload(battleResult: 1, isRetire: 0)); + Assert.That(r.StatusCode, Is.EqualTo(HttpStatusCode.OK), $"R1 battle {i} must succeed"); + } + await PromoteRunToRoundAsync(factory, vid, newRoundId: 2); + + // Round 2: 2 wins. + for (int i = 0; i < 2; i++) + { + var r = await client.PostAsync("/colosseum_battle/finish", BattleFinishPayload(battleResult: 1, isRetire: 0)); + Assert.That(r.StatusCode, Is.EqualTo(HttpStatusCode.OK), $"R2 battle {i} must succeed"); + } + await PromoteRunToRoundAsync(factory, vid, newRoundId: 3); + + // Round 3: 2 wins → champion path on /finish. + for (int i = 0; i < 2; i++) + { + var r = await client.PostAsync("/colosseum_battle/finish", BattleFinishPayload(battleResult: 1, isRetire: 0)); + Assert.That(r.StatusCode, Is.EqualTo(HttpStatusCode.OK), $"R3 battle {i} must succeed"); + } + + // /arena_colosseum/finish (champion path) + var finishResp = await client.PostAsync("/arena_colosseum/finish", JsonContent.Create(Envelope)); + Assert.That(finishResp.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + + var body = await finishResp.Content.ReadAsStringAsync(); + using var doc = JsonDocument.Parse(body); + var root = doc.RootElement; + Assert.That(root.GetProperty("colosseum_status").GetProperty("is_champion").GetBoolean(), Is.True); + // Final R3 finish reward + champion bundle = 2 entries. + Assert.That(root.GetProperty("reward_list").GetArrayLength(), Is.EqualTo(2)); + + using var verifyScope = factory.Services.CreateScope(); + var db = verifyScope.ServiceProvider.GetRequiredService(); + var run = await db.ViewerArenaColosseumRuns.FirstOrDefaultAsync(r => r.ViewerId == vid); + Assert.That(run, Is.Null, "champion run must be deleted on /finish"); + } + + [Test] + public async Task Retire_during_round_2_emits_round_capped_consolation() + { + using var factory = new SVSimTestFactory(); + await ConfigureSeasonAsync(factory); + var vid = await factory.SeedViewerAsync(); + await factory.SeedDeckAsync(vid, Format.Rotation, number: 1); + using var client = factory.CreateAuthenticatedClient(vid); + + // entry + register_deck + clear R1 + promote + await client.PostAsync("/arena_colosseum/entry", + JsonContent.Create(new { consume_item_type = 5, now_round_id = 1, viewer_id = "0", steam_id = 0, steam_session_ticket = "" })); + await client.PostAsync("/arena_colosseum/register_deck", + JsonContent.Create(new { deck_no_list = "[1]", is_published = false, viewer_id = "0", steam_id = 0, steam_session_ticket = "" })); + for (int i = 0; i < 2; i++) + await client.PostAsync("/colosseum_battle/finish", BattleFinishPayload(battleResult: 1, isRetire: 0)); + await PromoteRunToRoundAsync(factory, vid, newRoundId: 2); + + // One mid-round battle, then retire. + await client.PostAsync("/colosseum_battle/finish", BattleFinishPayload(battleResult: 2, isRetire: 0)); + + var retireResp = await client.PostAsync("/arena_colosseum/retire", JsonContent.Create(Envelope)); + Assert.That(retireResp.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + + var body = await retireResp.Content.ReadAsStringAsync(); + using var doc = JsonDocument.Parse(body); + var rewards = doc.RootElement.GetProperty("rewards"); + Assert.That(rewards.GetArrayLength(), Is.EqualTo(1)); + Assert.That(rewards[0].GetProperty("name").GetString(), Is.EqualTo("R2 retire"), + "retire payload must reflect the round the viewer was IN, not their starting round"); + + using var scope = factory.Services.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + Assert.That(await db.ViewerArenaColosseumRuns.AnyAsync(r => r.ViewerId == vid), Is.False); + } +} diff --git a/SVSim.UnitTests/Models/GameConfigurationJsonbTests.cs b/SVSim.UnitTests/Models/GameConfigurationJsonbTests.cs index 5c3c4451..fe9d7ee5 100644 --- a/SVSim.UnitTests/Models/GameConfigurationJsonbTests.cs +++ b/SVSim.UnitTests/Models/GameConfigurationJsonbTests.cs @@ -25,14 +25,14 @@ public class GameConfigurationJsonbTests var rows = await db.GameConfigs.AsNoTracking().ToListAsync(); var byName = rows.ToDictionary(r => r.SectionName); - // One row per [ConfigSection]-marked POCO (13 sections today: Player, DefaultGrants, + // One row per [ConfigSection]-marked POCO (15 sections today: Player, DefaultGrants, // DefaultLoadout, Challenge, Rotation, PackRates, MyRotationSchedule, Story, ResourceConfig, - // Freeplay, ArenaTwoPick, Matching, CardMasterConfig). + // Freeplay, ArenaTwoPick, Matching, CardMasterConfig, ColosseumSeason, ColosseumRounds). Assert.That(byName.Keys, Is.EquivalentTo(new[] { "Player", "DefaultGrants", "DefaultLoadout", "Challenge", "Rotation", "PackRates", "MyRotationSchedule", "Story", "ResourceConfig", "Freeplay", "ArenaTwoPick", "Matching", - "CardMasterConfig", + "CardMasterConfig", "ColosseumSeason", "ColosseumRounds", })); var resources = JsonSerializer.Deserialize(byName["ResourceConfig"].ValueJson)!; diff --git a/SVSim.UnitTests/Services/ArenaColosseum/ColosseumProgressionServiceTests.cs b/SVSim.UnitTests/Services/ArenaColosseum/ColosseumProgressionServiceTests.cs new file mode 100644 index 00000000..9158c651 --- /dev/null +++ b/SVSim.UnitTests/Services/ArenaColosseum/ColosseumProgressionServiceTests.cs @@ -0,0 +1,181 @@ +using NUnit.Framework; +using SVSim.Database.Enums; +using SVSim.Database.Models; +using SVSim.Database.Models.Config; +using SVSim.EmulatedEntrypoint.Services.ArenaColosseum; + +namespace SVSim.UnitTests.Services.ArenaColosseum; + +/// +/// Pure-logic tests for the bracket-advancement / promotion / reward-bundle service. +/// No DB, no controllers, no HTTP — these are the only place to lock the spec README's +/// "< FinalB" cap rule + the 3008 promotion trigger semantics. +/// +[TestFixture] +public class ColosseumProgressionServiceTests +{ + private static ColosseumRoundsConfig BuildThreeRoundConfig() => new() + { + Rounds = new() + { + new ColosseumRoundsConfig.RoundEntry + { + RoundId = 1, + Groups = new() { new() { Group = "", MaxBattleCount = 5, BreakthroughNumber = 3, EntryNumber = 100_000 } }, + FinishRewards = new() + { + new() { Type = UserGoodsType.Crystal, DetailId = 0, Count = 100, Name = "Round 1 bonus" }, + }, + RetireRewards = new() + { + new() { Type = UserGoodsType.Rupy, DetailId = 0, Count = 50, Name = "Consolation" }, + }, + }, + new ColosseumRoundsConfig.RoundEntry + { + RoundId = 2, + Groups = new() { new() { Group = "Group A", MaxBattleCount = 5, BreakthroughNumber = 4, EntryNumber = 10_000 } }, + FinishRewards = new() + { + new() { Type = UserGoodsType.Crystal, DetailId = 0, Count = 250, Name = "Round 2 bonus" }, + }, + }, + new ColosseumRoundsConfig.RoundEntry + { + RoundId = 3, + Groups = new() { new() { Group = "Final", MaxBattleCount = 5, BreakthroughNumber = 4, EntryNumber = 1_000 } }, + FinishRewards = new() + { + new() { Type = UserGoodsType.Crystal, DetailId = 0, Count = 1000, Name = "Final clear" }, + }, + }, + }, + ChampionRewards = new() + { + new() { Type = UserGoodsType.Item, DetailId = 5, Count = 1, Name = "Champion Pack" }, + }, + }; + + [Test] + public void Win_threshold_advances_round_1_to_round_2() + { + var svc = new ColosseumProgressionService(); + var rounds = BuildThreeRoundConfig(); + var run = new ViewerArenaColosseumRun { RoundId = 1, WinCount = 3, BattleCountThisRound = 3 }; + + var decision = svc.DecideAdvancement(run, rounds); + + Assert.That(decision.NextRoundId, Is.EqualTo(2)); + Assert.That(decision.IsBracketEnd, Is.False); + Assert.That(decision.IsChampion, Is.False); + } + + [Test] + public void Loss_cap_ends_bracket_at_current_round() + { + var svc = new ColosseumProgressionService(); + var rounds = BuildThreeRoundConfig(); + var run = new ViewerArenaColosseumRun + { + RoundId = 2, + WinCount = 3, // one short of breakthrough (4) + BattleCountThisRound = 5, // hit the cap + LossCount = 2, + }; + + var decision = svc.DecideAdvancement(run, rounds); + + Assert.That(decision.NextRoundId, Is.EqualTo(2)); + Assert.That(decision.IsBracketEnd, Is.True); + Assert.That(decision.IsChampion, Is.False); + } + + [Test] + public void Final_round_breakthrough_marks_champion() + { + var svc = new ColosseumProgressionService(); + var rounds = BuildThreeRoundConfig(); + var run = new ViewerArenaColosseumRun + { + RoundId = 3, + WinCount = 4, // hit breakthrough on the final round + BattleCountThisRound = 4, + }; + + var decision = svc.DecideAdvancement(run, rounds); + + Assert.That(decision.NextRoundId, Is.EqualTo(3)); + Assert.That(decision.IsBracketEnd, Is.True); + Assert.That(decision.IsChampion, Is.True); + } + + [Test] + public void ShouldPromoteToRankMatching_flips_once_on_3008() + { + var svc = new ColosseumProgressionService(); + var run = new ViewerArenaColosseumRun { IsRankMatching = false }; + + Assert.That(svc.ShouldPromoteToRankMatching(run, 3004), Is.False, + "3004 SUCCEEDED is not the promotion signal"); + Assert.That(svc.ShouldPromoteToRankMatching(run, 3008), Is.True, + "3008 is the colosseum-specific promotion trigger per do-matching.md"); + + run.IsRankMatching = true; + Assert.That(svc.ShouldPromoteToRankMatching(run, 3008), Is.False, + "already promoted — no second flip"); + } + + [Test] + public void BuildRetireRewards_returns_round_specific_bundle() + { + var svc = new ColosseumProgressionService(); + var rounds = BuildThreeRoundConfig(); + var run = new ViewerArenaColosseumRun { RoundId = 1 }; + + var rewards = svc.BuildRetireRewards(run, rounds); + + Assert.That(rewards.Count, Is.EqualTo(1)); + Assert.That(rewards[0].Type, Is.EqualTo(UserGoodsType.Rupy)); + Assert.That(rewards[0].Count, Is.EqualTo(50)); + } + + [Test] + public void BuildRetireRewards_returns_empty_when_round_has_none() + { + var svc = new ColosseumProgressionService(); + var rounds = BuildThreeRoundConfig(); + // Round 2 has no RetireRewards configured — server still emits an empty list per spec. + var run = new ViewerArenaColosseumRun { RoundId = 2 }; + + var rewards = svc.BuildRetireRewards(run, rounds); + + Assert.That(rewards, Is.Empty); + } + + [Test] + public void BuildFinishRewards_appends_champion_bundle_when_champion() + { + var svc = new ColosseumProgressionService(); + var rounds = BuildThreeRoundConfig(); + var run = new ViewerArenaColosseumRun { RoundId = 3, IsChampion = true }; + + var rewards = svc.BuildFinishRewards(run, rounds); + + Assert.That(rewards.Count, Is.EqualTo(2), "round 3 finish + champion bundle"); + Assert.That(rewards.Any(r => r.Name == "Final clear"), Is.True); + Assert.That(rewards.Any(r => r.Name == "Champion Pack"), Is.True); + } + + [Test] + public void BuildFinishRewards_omits_champion_bundle_when_not_champion() + { + var svc = new ColosseumProgressionService(); + var rounds = BuildThreeRoundConfig(); + var run = new ViewerArenaColosseumRun { RoundId = 1, IsChampion = false }; + + var rewards = svc.BuildFinishRewards(run, rounds); + + Assert.That(rewards.Count, Is.EqualTo(1)); + Assert.That(rewards[0].Name, Is.EqualTo("Round 1 bonus")); + } +} diff --git a/SVSim.UnitTests/Services/ArenaTwoPickServiceDraftTests.cs b/SVSim.UnitTests/Services/ArenaTwoPickServiceDraftTests.cs index e23331ca..d6aa9fae 100644 --- a/SVSim.UnitTests/Services/ArenaTwoPickServiceDraftTests.cs +++ b/SVSim.UnitTests/Services/ArenaTwoPickServiceDraftTests.cs @@ -24,6 +24,8 @@ public class ArenaTwoPickServiceDraftTests new() { Id = startingPairId + 1, Turn = turn, SetNum = 2, CardId1 = 2000 + turn * 10 + 1, CardId2 = 2000 + turn * 10 + 2, IsSelected = false }, }; + public List GeneratePickSetsForTurn(int classId, int turn, long startingPairId, IRandom rng, IReadOnlyList? poolCardSetIds) + => GeneratePickSetsForTurn(classId, turn, startingPairId, rng); } private static async Task<(IArenaTwoPickService, IArenaTwoPickRunRepository, long viewerId)> SetupWithActiveRunAsync(int classChosen = 0) diff --git a/SVSim.UnitTests/Services/ArenaTwoPickServiceEntryTests.cs b/SVSim.UnitTests/Services/ArenaTwoPickServiceEntryTests.cs index faf1c8a9..86491a12 100644 --- a/SVSim.UnitTests/Services/ArenaTwoPickServiceEntryTests.cs +++ b/SVSim.UnitTests/Services/ArenaTwoPickServiceEntryTests.cs @@ -22,6 +22,8 @@ public class ArenaTwoPickServiceEntryTests { public List GeneratePickSetsForTurn(int classId, int turn, long startingPairId, IRandom rng) => throw new NotSupportedException("pool not used in EntryAsync"); + public List GeneratePickSetsForTurn(int classId, int turn, long startingPairId, IRandom rng, IReadOnlyList? poolCardSetIds) + => throw new NotSupportedException("pool not used in EntryAsync"); } private static async Task<(SVSimDbContext db, IArenaTwoPickService svc, long viewerId)> SetupAsync( diff --git a/SVSim.UnitTests/Services/ArenaTwoPickServiceFinishTests.cs b/SVSim.UnitTests/Services/ArenaTwoPickServiceFinishTests.cs index 20696643..dddaae60 100644 --- a/SVSim.UnitTests/Services/ArenaTwoPickServiceFinishTests.cs +++ b/SVSim.UnitTests/Services/ArenaTwoPickServiceFinishTests.cs @@ -21,6 +21,7 @@ public class ArenaTwoPickServiceFinishTests private sealed class FakePool : IArenaTwoPickCardPoolService { public List GeneratePickSetsForTurn(int classId, int turn, long startingPairId, IRandom rng) => new(); + public List GeneratePickSetsForTurn(int classId, int turn, long startingPairId, IRandom rng, IReadOnlyList? poolCardSetIds) => new(); } private static async Task<(SVSimDbContext db, IArenaTwoPickService svc, long viewerId)> SetupWithRunAsync( diff --git a/SVSim.UnitTests/Services/ArenaTwoPickServiceWeightedRewardsTests.cs b/SVSim.UnitTests/Services/ArenaTwoPickServiceWeightedRewardsTests.cs index f4596afe..591b24d5 100644 --- a/SVSim.UnitTests/Services/ArenaTwoPickServiceWeightedRewardsTests.cs +++ b/SVSim.UnitTests/Services/ArenaTwoPickServiceWeightedRewardsTests.cs @@ -21,6 +21,7 @@ public class ArenaTwoPickServiceWeightedRewardsTests private sealed class FakePool : IArenaTwoPickCardPoolService { public List GeneratePickSetsForTurn(int classId, int turn, long startingPairId, IRandom rng) => new(); + public List GeneratePickSetsForTurn(int classId, int turn, long startingPairId, IRandom rng, IReadOnlyList? poolCardSetIds) => new(); } ///