using System.Text.Json.Serialization;

namespace NeonSprawl.Server.Game.AbilityInput;

/// <summary>POST body for ability cast intent (NEO-31).</summary>
public sealed class AbilityCastRequest
{
    public const int CurrentSchemaVersion = 1;

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

    [JsonPropertyName("slotIndex")]
    public int SlotIndex { get; init; }

    [JsonPropertyName("abilityId")]
    public string? AbilityId { get; init; }

    /// <summary>
    /// Must match the server's current combat lock (same string as <c>GET …/target</c> <c>lockedTargetId</c>) for
    /// <c>accepted: true</c>; NEO-28 adds <c>invalid_target</c> / <c>out_of_range</c> denies when it does not.
    /// </summary>
    [JsonPropertyName("targetId")]
    public string? TargetId { get; init; }
}

/// <summary>POST response for cast submit (prototype accept/deny; NEO-31 + NEO-28 target rules).</summary>
public sealed class AbilityCastResponse
{
    public const int CurrentSchemaVersion = 1;

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

    [JsonPropertyName("accepted")]
    public bool Accepted { get; init; }

    [JsonPropertyName("reasonCode")]
    [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
    public string? ReasonCode { get; init; }
}
