﻿#region

using System;
using Infected_Twitch.Core;
using Infected_Twitch.Menus;
using EloBuddy;
using LeagueSharp.SDK;
using static Infected_Twitch.Core.Spells;
using LeagueSharp.Common;

#endregion

 namespace Infected_Twitch.Event
{
    internal class Exploit : Core.Core
    {
        public static void Update(EventArgs args)
        {
            if (!SafeTarget(Target)) return;

            if (!MenuConfig.UseExploit) return;

            if (!Q.IsReady()) return;

            if (!(Target.Distance(Player) < Player.AttackRange)) return;

            if (MenuConfig.Eaaq)
            {
                if (!E.IsReady()) return;
                /*
                if (Target.Health <= Dmg.EDamage(Target) * 1.1 + Player.GetAutoAttackDamage(Target) && Items.HasItem(3153))
                {
                    Usables.Botrk();
                    E.Cast();
                    if (MenuConfig.Debug)
                    {
                        Game.PrintChat("Exploit: Casting Botrk E AA Q");
                    }
                }
                */
                if (Target.Health <= Dmg.EDamage(Target) + Player.LSGetAutoAttackDamage(Target))
                {
                    E.Cast();
                    if (MenuConfig.Debug)
                    {
                        Chat.Print("Exploit: Casting E AA Q");
                    }
                }
            }


            if (MenuConfig.Eaaaaq)
            {
                if (!E.IsReady()) return;

                if (!(Target.Health <= Dmg.EDamage(Target) + Player.LSGetAutoAttackDamage(Target)) || !(Player.HealthPercent >= 65)) return;

                E.Cast();

                if (!MenuConfig.Debug) return;

                do
                {
                    Chat.Print("Exploit: Casting E AA AA Q");
                } while (E.Cast());
            }

            if (!(Target.Health <= Player.LSGetAutoAttackDamage(Target)) || !Player.Spellbook.IsAutoAttacking) return;

            EloBuddy.Player.IssueOrder(GameObjectOrder.AttackUnit, Target);
            Q.Cast();
            if (MenuConfig.Debug)
            {
                Chat.Print("Exploit Active...");
            }
        }
    }
}
