using System.Text.Json.Serialization;

namespace NeonSprawl.Server.Game.Combat;

/// <summary>JSON body for <c>GET /game/world/ability-definitions</c> (NEO-78).</summary>
public sealed class AbilityDefinitionsListResponse
{
    public const int CurrentSchemaVersion = 1;

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

    /// <summary>Loaded abilities ordered by stable <c>id</c> (ordinal), matching <see cref="IAbilityDefinitionRegistry.GetDefinitionsInIdOrder"/>.</summary>
    [JsonPropertyName("abilities")]
    public required IReadOnlyList<AbilityDefinitionJson> Abilities { get; init; }
}

/// <summary>One row in the read-only ability definition projection.</summary>
public sealed class AbilityDefinitionJson
{
    [JsonPropertyName("id")]
    public required string Id { get; init; }

    [JsonPropertyName("displayName")]
    public required string DisplayName { get; init; }

    [JsonPropertyName("baseDamage")]
    public required int BaseDamage { get; init; }

    [JsonPropertyName("cooldownSeconds")]
    public required double CooldownSeconds { get; init; }

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