namespace SOR.Database.Entities.Game; using SOR.Database.Enums; /// /// Represents a single game match between two players. /// /// Live game state is stored as JSONB in StateJson and is updated after every action. /// The full GameState object (board, hands, decks, etc.) is serialized there. /// /// Cross-schema: all account and deck IDs are bare Guids — no EF foreign keys. /// public sealed class GameSession { public Guid Id { get; set; } = Guid.NewGuid(); // ── Players ────────────────────────────────────────────────────────────── public Guid PlayerOneAccountId { get; set; } public Guid PlayerOneDeckId { get; set; } public Guid PlayerTwoAccountId { get; set; } public Guid PlayerTwoDeckId { get; set; } // ── Readiness ──────────────────────────────────────────────────────────── /// Set to true when player one sends game.ready. public bool PlayerOneReady { get; set; } /// Set to true when player two sends game.ready. public bool PlayerTwoReady { get; set; } // ── Lifecycle ──────────────────────────────────────────────────────────── public GameSessionStatus Status { get; set; } = GameSessionStatus.Initializing; public DateTimeOffset CreatedAt { get; set; } public DateTimeOffset? StartedAt { get; set; } public DateTimeOffset? EndedAt { get; set; } // ── Result ─────────────────────────────────────────────────────────────── /// AccountId of the winning player. Null until game ends. public Guid? WinnerAccountId { get; set; } /// /// "concede" | "health" (ArchSpirit destroyed) | "disconnect" | "timeout" /// public string? WinCondition { get; set; } // ── Live state ─────────────────────────────────────────────────────────── /// /// JSONB blob — the full live GameState object. /// Updated after every game action. /// The GameEngine reads and writes this exclusively. /// public string? StateJson { get; set; } // ── Navigation ─────────────────────────────────────────────────────────── public ICollection ActionLog { get; set; } = new List(); }