using Model.Entity;
using Model.Entity.Parts;

namespace API.GraphQL.Types;

public class EntityGraphType : ObjectType<EntityModel>
{
    protected override void Configure(IObjectTypeDescriptor<EntityModel> descriptor)
    {
        descriptor.Name("Entity");

        descriptor.Field(e => e.DataType).Name("id");
        descriptor.Field(e => e.EntityType).Name("type");
        descriptor.Field(e => e.IsSpeculative);
        descriptor.Field(e => e.Descriptive).Name("descriptiveType");

        descriptor.Ignore(e => e.EntityParts);

        descriptor.Field("name")
            .Resolve(ctx => ctx.Parent<EntityModel>().GetName());

        descriptor.Field("factionName")
            .Resolve(ctx => ctx.Parent<EntityModel>().GetFaction());

        descriptor.Field("info")
            .Type<EntityInfoGraphType>()
            .Resolve(ctx => ctx.Parent<EntityModel>().Info());

        descriptor.Field("production")
            .Type<EntityProductionGraphType>()
            .Resolve(ctx => ctx.Parent<EntityModel>().Production());

        descriptor.Field("supply")
            .Type<EntitySupplyGraphType>()
            .Resolve(ctx => ctx.Parent<EntityModel>().Supply());

        descriptor.Field("tier")
            .Type<EntityTierGraphType>()
            .Resolve(ctx => ctx.Parent<EntityModel>().Tier());

        descriptor.Field("movement")
            .Type<EntityMovementGraphType>()
            .Resolve(ctx => ctx.Parent<EntityModel>().Movement());

        descriptor.Field("vitality")
            .Type<EntityVitalityGraphType>()
            .Resolve(ctx => ctx.Parent<EntityModel>().Vitality());

        descriptor.Field("requirements")
            .Type<ListType<EntityRequirementGraphType>>()
            .Resolve(ctx => ctx.Parent<EntityModel>().Requirements());

        descriptor.Field("weapons")
            .Type<ListType<EntityWeaponGraphType>>()
            .Resolve(ctx => ctx.Parent<EntityModel>().Weapons());

        descriptor.Field("hotkey")
            .Type<EntityHotkeyGraphType>()
            .Resolve(ctx => ctx.Parent<EntityModel>().Hotkey());

        descriptor.Field("faction")
            .Type<EntityFactionGraphType>()
            .Resolve(ctx => ctx.Parent<EntityModel>().Faction());

        descriptor.Field("harvest")
            .Type<EntityHarvestGraphType>()
            .Resolve(ctx => ctx.Parent<EntityModel>().Harvest());

        descriptor.Field("idAbilities")
            .Type<ListType<EntityIdReferenceGraphType>>()
            .Resolve(ctx => ctx.Parent<EntityModel>().IdAbilities());

        descriptor.Field("idArmies")
            .Type<ListType<EntityIdReferenceGraphType>>()
            .Resolve(ctx => ctx.Parent<EntityModel>().IdArmies());

        descriptor.Field("idPassives")
            .Type<ListType<EntityIdReferenceGraphType>>()
            .Resolve(ctx => ctx.Parent<EntityModel>().IdPassives());

        descriptor.Field("idUpgrades")
            .Type<ListType<EntityIdReferenceGraphType>>()
            .Resolve(ctx => ctx.Parent<EntityModel>().IdUpgrades());

        descriptor.Field("idVanguards")
            .Type<ListType<EntityIdReferenceGraphType>>()
            .Resolve(ctx => ctx.Parent<EntityModel>().IdVanguards());

        descriptor.Field("idPyreSpells")
            .Type<ListType<EntityIdReferenceGraphType>>()
            .Resolve(ctx => ctx.Parent<EntityModel>().IdPyreSpells());

        descriptor.Field("mechanics")
            .Type<ListType<EntityMechanicGraphType>>()
            .Resolve(ctx => ctx.Parent<EntityModel>().Mechanics());

        descriptor.Field("passives")
            .Type<ListType<EntityNamedDescGraphType>>()
            .Resolve(ctx => ctx.Parent<EntityModel>().Passives());

        descriptor.Field("strategies")
            .Type<ListType<EntityStrategyGraphType>>()
            .Resolve(ctx => ctx.Parent<EntityModel>().Strategies());

        descriptor.Field("replaceds")
            .Type<ListType<EntityVanguardReplacedGraphType>>()
            .Resolve(ctx => ctx.Parent<EntityModel>().Replaceds());

        descriptor.Field("vanguardAdded")
            .Type<EntityVanguardAddedGraphType>()
            .Resolve(ctx => ctx.Parent<EntityModel>().VanguardAdded());
    }
}

public class EntityInfoGraphType : ObjectType<EntityInfoModel>
{
    protected override void Configure(IObjectTypeDescriptor<EntityInfoModel> descriptor)
    {
        descriptor.Ignore(e => e.Parent);
        descriptor.Field(e => e.Name);
        descriptor.Field(e => e.Descriptive).Name("descriptiveType");
        descriptor.Field(e => e.Description);
        descriptor.Field(e => e.Notes);
        descriptor.Field(e => e.FlavorText);
    }
}

public class EntityProductionGraphType : ObjectType<EntityProductionModel>
{
    protected override void Configure(IObjectTypeDescriptor<EntityProductionModel> descriptor)
    {
        descriptor.Ignore(e => e.Parent);
    }
}

public class EntitySupplyGraphType : ObjectType<EntitySupplyModel>
{
    protected override void Configure(IObjectTypeDescriptor<EntitySupplyModel> descriptor)
    {
        descriptor.Ignore(e => e.Parent);
    }
}

public class EntityTierGraphType : ObjectType<EntityTierModel>
{
    protected override void Configure(IObjectTypeDescriptor<EntityTierModel> descriptor)
    {
        descriptor.Ignore(e => e.Parent);
    }
}

public class EntityMovementGraphType : ObjectType<EntityMovementModel>
{
    protected override void Configure(IObjectTypeDescriptor<EntityMovementModel> descriptor)
    {
        descriptor.Ignore(e => e.Parent);
    }
}

public class EntityVitalityGraphType : ObjectType<EntityVitalityModel>
{
    protected override void Configure(IObjectTypeDescriptor<EntityVitalityModel> descriptor)
    {
        descriptor.Ignore(e => e.Parent);
    }
}

public class EntityRequirementGraphType : ObjectType<EntityRequirementModel>
{
    protected override void Configure(IObjectTypeDescriptor<EntityRequirementModel> descriptor)
    {
        descriptor.Ignore(e => e.Parent);
    }
}

public class EntityWeaponGraphType : ObjectType<EntityWeaponModel>
{
    protected override void Configure(IObjectTypeDescriptor<EntityWeaponModel> descriptor)
    {
        descriptor.Ignore(e => e.Parent);
    }
}

public class EntityHotkeyGraphType : ObjectType<EntityHotkeyModel>
{
    protected override void Configure(IObjectTypeDescriptor<EntityHotkeyModel> descriptor)
    {
        descriptor.Ignore(e => e.Parent);
    }
}

public class EntityFactionGraphType : ObjectType<EntityFactionModel>
{
    protected override void Configure(IObjectTypeDescriptor<EntityFactionModel> descriptor)
    {
        descriptor.Ignore(e => e.Parent);
    }
}

public class EntityHarvestGraphType : ObjectType<EntityHarvestModel>
{
    protected override void Configure(IObjectTypeDescriptor<EntityHarvestModel> descriptor)
    {
        descriptor.Ignore(e => e.Parent);
    }
}

public class EntityIdReferenceGraphType : ObjectType<EntityIdAbilityModel>
{
    protected override void Configure(IObjectTypeDescriptor<EntityIdAbilityModel> descriptor)
    {
        descriptor.Ignore(e => e.Parent);
    }
}

public class EntityMechanicGraphType : ObjectType<EntityMechanicModel>
{
    protected override void Configure(IObjectTypeDescriptor<EntityMechanicModel> descriptor)
    {
        descriptor.Ignore(e => e.Parent);
    }
}

public class EntityNamedDescGraphType : ObjectType<EntityPassiveModel>
{
    protected override void Configure(IObjectTypeDescriptor<EntityPassiveModel> descriptor)
    {
        descriptor.Ignore(e => e.Parent);
    }
}

public class EntityStrategyGraphType : ObjectType<EntityStrategyModel>
{
    protected override void Configure(IObjectTypeDescriptor<EntityStrategyModel> descriptor)
    {
        descriptor.Ignore(e => e.Parent);
    }
}

public class EntityVanguardReplacedGraphType : ObjectType<EntityVanguardReplacedModel>
{
    protected override void Configure(IObjectTypeDescriptor<EntityVanguardReplacedModel> descriptor)
    {
        descriptor.Ignore(e => e.Parent);
    }
}

public class EntityVanguardAddedGraphType : ObjectType<EntityVanguardAddedModel>
{
    protected override void Configure(IObjectTypeDescriptor<EntityVanguardAddedModel> descriptor)
    {
        descriptor.Ignore(e => e.Parent);
    }
}