using System.Text.Json.Serialization;

namespace NeonSprawl.Server.Game.Gathering;

/// <summary>JSON body for <c>GET /game/world/resource-node-definitions</c> (NEO-60).</summary>
public sealed class ResourceNodeDefinitionsListResponse
{
    public const int CurrentSchemaVersion = 1;

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

    /// <summary>Loaded node defs ordered by stable <c>id</c> (ordinal), matching <see cref="IResourceNodeDefinitionRegistry.GetDefinitionsInIdOrder"/>.</summary>
    [JsonPropertyName("nodes")]
    public required IReadOnlyList<ResourceNodeDefinitionJson> Nodes { get; init; }
}

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

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

    [JsonPropertyName("gatherLens")]
    public required string GatherLens { get; init; }

    [JsonPropertyName("maxGathers")]
    public required int MaxGathers { get; init; }

    [JsonPropertyName("yield")]
    public required ResourceNodeYieldJson Yield { get; init; }
}

/// <summary>Fixed yield summary for one resource node def.</summary>
public sealed class ResourceNodeYieldJson
{
    [JsonPropertyName("itemId")]
    public required string ItemId { get; init; }

    [JsonPropertyName("quantity")]
    public required int Quantity { get; init; }
}
