using System.Text.Json.Serialization;

namespace NeonSprawl.Server.Game.AbilityInput;

/// <summary>GET response for per-slot cooldown ends (NEO-32).</summary>
public sealed class CooldownSnapshotResponse
{
    public const int CurrentSchemaVersion = 1;

    [JsonPropertyName("schemaVersion")]
    public int SchemaVersion { get; init; } = CurrentSchemaVersion;

    [JsonPropertyName("playerId")]
    public required string PlayerId { get; init; }

    /// <summary>Authoritative instant for remaining-time math on the client.</summary>
    [JsonPropertyName("serverTimeUtc")]
    public DateTimeOffset ServerTimeUtc { get; init; }

    /// <summary>Slots 0..7 in ascending order.</summary>
    [JsonPropertyName("slots")]
    public required IReadOnlyList<CooldownSlotSnapshotJson> Slots { get; init; }
}

/// <summary>Cooldown end for one hotbar slot; <see cref="CooldownEndsAtUtc"/> null when ready.</summary>
public sealed class CooldownSlotSnapshotJson
{
    [JsonPropertyName("slotIndex")]
    public required int SlotIndex { get; init; }

    /// <summary>UTC instant when the slot leaves cooldown, or null when not cooling.</summary>
    [JsonPropertyName("cooldownEndsAtUtc")]
    [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
    public DateTimeOffset? CooldownEndsAtUtc { get; init; }
}
