using MessagePack;
using System.Text.Json.Serialization;

namespace SVSim.EmulatedEntrypoint.Models.Dtos;

/// <summary>
/// colosseum_info on /mypage/index, consumed by ColosseumEntryInfoTask.SetColosseumInfo
/// (Wizard/ColosseumEntryInfoTask.cs:99). The outer object is read unconditionally, and
/// is_colosseum_period gates everything else. When a cup IS active, the client reads
/// many more sub-fields inside the gate (deck_format, now_round, start_time, end_time,
/// sales_period_info, etc.) — we now mirror the full prod shape so the gate-true branch
/// works once we have colosseum data seeded.
///
/// Prod-captured shape (15 fields):
/// <code>
/// {"colosseum_id":"165","is_display_tips":"0","tips_id":"0",
///  "card_pool_name":"Take Two (Dragonblade–Rivenbrandt)",
///  "is_colosseum_period":true,"is_round_period":true,"deck_format":"3",
///  "is_normal_two_pick":"1","is_special_mode":"10","is_all_card_enabled":0,
///  "start_time":"2026-05-21 06:00:00","colosseum_name":"Rivenbrandt Take Two Cup",
///  "now_round":"1","end_time":"2026-05-25 19:59:59",
///  "sales_period_info":{"sales_period_time":"2026-05-25 19:59:59"}}
/// </code>
/// </summary>
[MessagePackObject]
public class ColosseumInfo
{
    [JsonPropertyName("colosseum_id")]
    [Key("colosseum_id")]
    public string ColosseumId { get; set; } = string.Empty;

    /// <summary>Wire is "0"/"1" string. Client compares with == "1" (GetValueOrDefault-guarded).</summary>
    [JsonPropertyName("is_display_tips")]
    [Key("is_display_tips")]
    public string IsDisplayTips { get; set; } = "0";

    [JsonPropertyName("tips_id")]
    [Key("tips_id")]
    public string TipsId { get; set; } = "0";

    [JsonPropertyName("card_pool_name")]
    [Key("card_pool_name")]
    public string CardPoolName { get; set; } = string.Empty;

    [JsonPropertyName("is_colosseum_period")]
    [Key("is_colosseum_period")]
    public bool IsColosseumPeriod { get; set; }

    [JsonPropertyName("is_round_period")]
    [Key("is_round_period")]
    public bool IsRoundPeriod { get; set; }

    /// <summary>
    /// Wire is a stringified int in prod (e.g. "3"). DB stores as string. Client calls
    /// <c>jsonData["deck_format"].ToInt()</c> inside the IsColosseumPeriod gate.
    /// </summary>
    [JsonPropertyName("deck_format")]
    [Key("deck_format")]
    public string DeckFormat { get; set; } = "0";

    /// <summary>Wire is "1"/"0" string. Client compares with == "1".</summary>
    [JsonPropertyName("is_normal_two_pick")]
    [Key("is_normal_two_pick")]
    public string IsNormalTwoPick { get; set; } = "0";

    /// <summary>Used as ColorCodeId (stringified int).</summary>
    [JsonPropertyName("is_special_mode")]
    [Key("is_special_mode")]
    public string IsSpecialMode { get; set; } = "0";

    [JsonPropertyName("is_all_card_enabled")]
    [Key("is_all_card_enabled")]
    public int IsAllCardEnabled { get; set; }

    /// <summary>"yyyy-MM-dd HH:mm:ss" wire format.</summary>
    [JsonPropertyName("start_time")]
    [Key("start_time")]
    public string StartTime { get; set; } = string.Empty;

    [JsonPropertyName("colosseum_name")]
    [Key("colosseum_name")]
    public string ColosseumName { get; set; } = string.Empty;

    /// <summary>Round number as string (e.g. "1"). Client casts to int.</summary>
    [JsonPropertyName("now_round")]
    [Key("now_round")]
    public string NowRound { get; set; } = "0";

    /// <summary>"yyyy-MM-dd HH:mm:ss" wire format.</summary>
    [JsonPropertyName("end_time")]
    [Key("end_time")]
    public string EndTime { get; set; } = string.Empty;

    [JsonPropertyName("sales_period_info")]
    [Key("sales_period_info")]
    public ColosseumSalesPeriodInfo SalesPeriodInfo { get; set; } = new();
}
