using System.ComponentModel.DataAnnotations.Schema; using Microsoft.EntityFrameworkCore; namespace SVSim.Database.Models; /// /// One active Take Two run per viewer. Standalone (not a Viewer owned collection) to avoid /// the EF nav-include pitfalls in project_ef_nav_include_pitfall and to keep /load/index cheap. /// Row is deleted on /retire and /finish completion. Unique index on ViewerId enforces /// "one active run per viewer". /// /// Lists are stored as jsonb strings ({Field}Json) per the project's inline-JSON column /// pattern (see DefaultDeckEntry.CardIdArray). Repos own (de)serialization. /// /// [Index(nameof(ViewerId), IsUnique = true)] public class ViewerArenaTwoPickRun { public long Id { get; set; } public long ViewerId { get; set; } /// Wire entry_info.id / two_pick_entry_id. Set to on insert. public long EntryId { get; set; } public int RewardScheduleId { get; set; } public int ChallengeId { get; set; } /// MAX(reward.WinCount) at creation time. Stamped on the row so mid-run reward-table edits don't change the cap. public int MaxBattleCount { get; set; } /// 0 until /class_choose. public int ClassId { get; set; } /// 0 until first battle; set to class default on /class_choose. public long LeaderSkinId { get; set; } [Column(TypeName = "jsonb")] public string CandidateClassIdsJson { get; set; } = "[]"; /// 1..15. 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; [Column(TypeName = "jsonb")] public string ResultListJson { get; set; } = "[]"; public int WinCount { get; set; } public int LossCount { get; set; } public bool IsRetire { get; set; } public DateTime CreatedAt { get; set; } public DateTime UpdatedAt { get; set; } }