using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;

namespace PkmnLib.Dynamic.Libraries.DataLoaders.Models;

/// <summary>
/// A wrapper class for serialized move data.
/// </summary>
public class SerializedMoveDataWrapper
{
    /// <summary>
    /// The name of the move data file.
    /// </summary>
    public List<SerializedMove> Data { get; set; } = null!;
}

/// <summary>
/// A class representing a serialized move.
/// </summary>
public class SerializedMove
{
    /// <inheritdoc cref="PkmnLib.Static.Utils.INamedValue.Name" />
    public string Name { get; set; } = null!;

    /// <inheritdoc cref="PkmnLib.Static.Moves.IMoveData.MoveType" />
    public string Type { get; set; } = null!;

    /// <inheritdoc cref="PkmnLib.Static.Moves.IMoveData.BasePower" />
    public byte Power { get; set; }

    /// <inheritdoc cref="PkmnLib.Static.Moves.IMoveData.BaseUsages" />
    public byte PP { get; set; }

    /// <inheritdoc cref="PkmnLib.Static.Moves.IMoveData.Accuracy" />
    public byte Accuracy { get; set; }

    /// <inheritdoc cref="PkmnLib.Static.Moves.IMoveData.Priority" />
    public sbyte Priority { get; set; }

    /// <inheritdoc cref="PkmnLib.Static.Moves.IMoveData.Target" />
    public string Target { get; set; } = null!;

    /// <inheritdoc cref="PkmnLib.Static.Moves.IMoveData.Category" />
    public string Category { get; set; } = null!;

    /// <summary>
    /// Arbitrary flags that can be applied to the move.
    /// </summary>
    public string[] Flags { get; set; } = null!;

    /// <inheritdoc cref="PkmnLib.Static.Moves.IMoveData.SecondaryEffect" />
    public SerializedMoveEffect? Effect { get; set; }

    /// <summary>
    /// Additional non-standard data that can be added to the move.
    /// </summary>
    [JsonExtensionData]
    public Dictionary<string, JsonElement>? ExtensionData { get; set; }
}

/// <summary>
/// A class representing a serialized move effect.
/// </summary>
public class SerializedMoveEffect
{
    /// <inheritdoc cref="PkmnLib.Static.Moves.ISecondaryEffect.Name" />
    public string Name { get; set; } = null!;

    /// <inheritdoc cref="PkmnLib.Static.Moves.ISecondaryEffect.Chance" />
    public float? Chance { get; set; }

    /// <inheritdoc cref="PkmnLib.Static.Moves.ISecondaryEffect.Parameters" />
    public Dictionary<string, JsonNode>? Parameters { get; set; } = null!;
}