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

namespace PkmnLib.Dataloader.Models;

public class SerializedSpecies
{
    public string Species { get; set; } = null!;
    public ushort Id { get; set; }
    public float GenderRatio { get; set; }
    public string GrowthRate { get; set; } = null!;
    public byte BaseHappiness { get; set; }
    public byte CatchRate { get; set; }
    public string Color { get; set; } = null!;
    public bool GenderDifference { get; set; }
    public string[] EggGroups { get; set; } = null!;
    public int EggCycles { get; set; }
    public string[] Flags { get; set; } = [];
    public Dictionary<string, SerializedForm> Formes { get; set; } = null!;
    public SerializedEvolution[] Evolutions { get; set; } = [];
    
    [JsonExtensionData]
    public Dictionary<string, JsonElement>? ExtensionData { get; set; }
}

public class SerializedForm
{
    public string[] Abilities { get; set; } = null!;
    public string[] HiddenAbilities { get; set; } = [];
    public SerializedStats BaseStats { get; set; } = null!;
    public SerializedStats EVReward { get; set; } = null!;
    public string[] Types { get; set; } = null!;
    public float Height { get; set; }
    public float Weight { get; set; }
    public uint BaseExp { get; set; }
    public bool IsMega { get; set; }
    public SerializedMoves Moves { get; set; } = null!;
    public string[] Flags { get; set; } = [];
    
    [JsonExtensionData]
    public Dictionary<string, JsonElement>? ExtensionData { get; set; }
}

public class SerializedEvolution
{
    public string Species { get; set; } = null!;
    public string Method { get; set; } = null!;
    public JsonNode Data { get; set; } = null!;
}

public class SerializedStats
{
    public ushort Hp { get; set; }
    public ushort Attack { get; set; }
    public ushort Defense { get; set; }
    public ushort SpecialAttack { get; set; }
    public ushort SpecialDefense { get; set; }
    public ushort Speed { get; set; }
}

public class SerializedLevelMove
{
    public string Name { get; set; } = null!;
    public uint Level { get; set; }
}

public class SerializedMoves
{
    public SerializedLevelMove[]? LevelMoves { get; set; } = null!;
    public string[]? EggMoves { get; set; } = null!;
    public string[]? TutorMoves { get; set; } = null!;
    public string[]? Machine { get; set; } = null!;
}