diff --git a/SVSim.Database/Models/CandidatePair.cs b/SVSim.Database/Models/CandidatePair.cs new file mode 100644 index 0000000..33a6780 --- /dev/null +++ b/SVSim.Database/Models/CandidatePair.cs @@ -0,0 +1,16 @@ +namespace SVSim.Database.Models; + +/// +/// One of the 2 pick-sets offered to the player on the current draft turn. Persisted as +/// part of . is the +/// monotonic counter the client sends back as selected_id on /card_choose. +/// +public class CandidatePair +{ + public long Id { get; set; } + public int Turn { get; set; } + public int SetNum { get; set; } + public long CardId1 { get; set; } + public long CardId2 { get; set; } + public bool IsSelected { get; set; } +} diff --git a/SVSim.Database/Models/ViewerArenaTwoPickRun.cs b/SVSim.Database/Models/ViewerArenaTwoPickRun.cs new file mode 100644 index 0000000..a9c9784 --- /dev/null +++ b/SVSim.Database/Models/ViewerArenaTwoPickRun.cs @@ -0,0 +1,64 @@ +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; } +}