using System.Text.Json.Serialization;

namespace NeonSprawl.Server.Game.Crafting;

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

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

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

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

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

    [JsonPropertyName("recipeKind")]
    public required string RecipeKind { get; init; }

    [JsonPropertyName("requiredSkillId")]
    public required string RequiredSkillId { get; init; }

    [JsonPropertyName("inputs")]
    public required IReadOnlyList<RecipeIoJson> Inputs { get; init; }

    [JsonPropertyName("outputs")]
    public required IReadOnlyList<RecipeIoJson> Outputs { get; init; }
}

/// <summary>One input or output row in the read-only recipe definition projection.</summary>
public sealed class RecipeIoJson
{
    [JsonPropertyName("itemId")]
    public required string ItemId { get; init; }

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