context: using System;
  using System.Linq;
  
  using LeagueSharp;
  using LeagueSharp.Common;
  
  using EloBuddy; 
   using LeagueSharp.Common; 
   namespace Mundo_Sharpy
  {
      static class ExtraExtensions
      {
          internal static bool isReadyPerfectly(this Spell spell)
          {
              return spell != null && spell.Slot != SpellSlot.Unknown && spell.Instance.State != SpellState.Cooldown && spell.Instance.State != SpellState.Disabled && spell.Instance.State != SpellState.NoMana && spell.Instance.State != SpellState.NotLearned && spell.Instance.State != SpellState.Surpressed && spell.Instance.State != SpellState.Unknown && spell.Instance.State == SpellState.Ready;
          }
  
          internal static bool isKillableAndValidTarget(this AIHeroClient Target, double CalculatedDamage, TargetSelector.DamageType damageType, float distance = float.MaxValue)
          {
              if (Target == null || !Target.IsValidTarget(distance) || Target.Health <= 0 || Target.CharData.BaseSkinName == "gangplankbarrel")
                  return false;
  
              if (Target.HasBuff("kindredrnodeathbuff"))
              {
                  return false;
              }
  
              // Tryndamere's Undying Rage (R)
              if (Target.HasBuff("Undying Rage") && Target.Health <= Target.MaxHealth * 0.10f)
              {
                  return false;
              }
  
              // Kayle's Intervention (R)
              if (Target.HasBuff("JudicatorIntervention"))
              {
                  return false;
              }
  
              // Poppy's Diplomatic Immunity (R)
              if (Target.HasBuff("DiplomaticImmunity") && !ObjectManager.Player.HasBuff("poppyulttargetmark"))
              {
                  //TODO: Get the actual target mark buff name
                  return false;
              }
  
              // Banshee's Veil (PASSIVE)
              if (Target.HasBuff("BansheesVeil"))
              {
                  // TODO: Get exact Banshee's Veil buff name.
                  return false;
              }
  
              // Sivir's Spell Shield (E)
              if (Target.HasBuff("SivirShield"))
              {
                  // TODO: Get exact Sivir's Spell Shield buff name
                  return false;
              }
  
              // Nocturne's Shroud of Darkness (W)
              if (Target.HasBuff("ShroudofDarkness"))
              {
                  // TODO: Get exact Nocturne's Shourd of Darkness buff name
                  return false;
              }
  
              if (ObjectManager.Player.HasBuff("summonerexhaust"))
                  CalculatedDamage *= 0.6;
  
              if (Target.ChampionName == "Blitzcrank")
                  if (!Target.HasBuff("manabarriercooldown"))
                      if (Target.Health + Target.HPRegenRate + (damageType == TargetSelector.DamageType.Physical ? Target.AttackShield : Target.MagicShield) + (Target.Mana * 0.6) + Target.PARRegenRate < CalculatedDamage)
                          return true;
  
              if (Target.ChampionName == "Garen")
                  if (Target.HasBuff("GarenW"))
                      CalculatedDamage *= 0.7;
  
              if (Target.HasBuff("FerociousHowl"))
                  CalculatedDamage *= 0.3;
  
              return Target.Health + Target.HPRegenRate + (damageType == TargetSelector.DamageType.Physical ? Target.AttackShield : Target.MagicShield) < CalculatedDamage - 2;
          }
  
          internal static bool isKillableAndValidTarget(this Obj_AI_Minion Target, double CalculatedDamage, TargetSelector.DamageType damageType, float distance = float.MaxValue)
          {
              if (Target == null || !Target.IsValidTarget(distance) || Target.Health <= 0 || Target.HasBuffOfType(BuffType.SpellImmunity) || Target.HasBuffOfType(BuffType.SpellShield) || Target.CharData.BaseSkinName == "gangplankbarrel")
                  return false;
  
              if (ObjectManager.Player.HasBuff("summonerexhaust"))
                  CalculatedDamage *= 0.6;
  
              BuffInstance dragonSlayerBuff = ObjectManager.Player.GetBuff("s5test_dragonslayerbuff");
              if (dragonSlayerBuff != null)
              {
                  if (dragonSlayerBuff.Count >= 4)
                      CalculatedDamage += dragonSlayerBuff.Count == 5 ? CalculatedDamage * 0.30 : CalculatedDamage * 0.15;
  
                  if (Target.CharData.BaseSkinName.ToLowerInvariant().Contains("dragon"))
                      CalculatedDamage *= 1 - (dragonSlayerBuff.Count * 0.07);
              }
  
              if (Target.CharData.BaseSkinName.ToLowerInvariant().Contains("baron") && ObjectManager.Player.HasBuff("barontarget"))
                  CalculatedDamage *= 0.5;
  
              return Target.Health + Target.HPRegenRate + (damageType == TargetSelector.DamageType.Physical ? Target.AttackShield : Target.MagicShield) < CalculatedDamage - 2;
          }
  
          internal static bool isKillableAndValidTarget(this Obj_AI_Base Target, double CalculatedDamage, TargetSelector.DamageType damageType, float distance = float.MaxValue)
          {
              if (Target == null || !Target.IsValidTarget(distance) || Target.Health <= 0 || Target.CharData.BaseSkinName == "gangplankbarrel")
                  return false;
  
              if (Target.HasBuff("kindredrnodeathbuff"))
              {
                  return false;
              }
  
              // Tryndamere's Undying Rage (R)
              if (Target.HasBuff("Undying Rage") && Target.Health <= Target.MaxHealth * 0.10f)
              {
                  return false;
              }
  
              // Kayle's Intervention (R)
              if (Target.HasBuff("JudicatorIntervention"))
              {
                  return false;
              }
  
              // Poppy's Diplomatic Immunity (R)
              if (Target.HasBuff("DiplomaticImmunity") && !ObjectManager.Player.HasBuff("poppyulttargetmark"))
              {
                  //TODO: Get the actual target mark buff name
                  return false;
              }
  
              // Banshee's Veil (PASSIVE)
              if (Target.HasBuff("BansheesVeil"))
              {
                  // TODO: Get exact Banshee's Veil buff name.
                  return false;
              }
  
              // Sivir's Spell Shield (E)
              if (Target.HasBuff("SivirShield"))
              {
                  // TODO: Get exact Sivir's Spell Shield buff name
                  return false;
              }
  
              // Nocturne's Shroud of Darkness (W)
              if (Target.HasBuff("ShroudofDarkness"))
              {
                  // TODO: Get exact Nocturne's Shourd of Darkness buff name
                  return false;
              }
  
              if (ObjectManager.Player.HasBuff("summonerexhaust"))
                  CalculatedDamage *= 0.6;
  
              if (Target.CharData.BaseSkinName == "Blitzcrank")
                  if (!Target.HasBuff("manabarriercooldown"))
                      if (Target.Health + Target.HPRegenRate + (damageType == TargetSelector.DamageType.Physical ? Target.AttackShield : Target.MagicShield) + (Target.Mana * 0.6) + Target.PARRegenRate < CalculatedDamage)
                          return true;
  
              if (Target.CharData.BaseSkinName == "Garen")
                  if (Target.HasBuff("GarenW"))
                      CalculatedDamage *= 0.7;
  
  
              if (Target.HasBuff("FerociousHowl"))
                  CalculatedDamage *= 0.3;
  
              BuffInstance dragonSlayerBuff = ObjectManager.Player.GetBuff("s5test_dragonslayerbuff");
              if (dragonSlayerBuff != null)
                  if (Target.IsMinion)
                  {
                      if (dragonSlayerBuff.Count >= 4)
                          CalculatedDamage += dragonSlayerBuff.Count == 5 ? CalculatedDamage * 0.30 : CalculatedDamage * 0.15;
  
                      if (Target.CharData.BaseSkinName.ToLowerInvariant().Contains("dragon"))
                          CalculatedDamage *= 1 - (dragonSlayerBuff.Count * 0.07);
                  }
  
              if (Target.CharData.BaseSkinName.ToLowerInvariant().Contains("baron") && ObjectManager.Player.HasBuff("barontarget"))
                  CalculatedDamage *= 0.5;
  
              return Target.Health + Target.HPRegenRate + (damageType == TargetSelector.DamageType.Physical ? Target.AttackShield : Target.MagicShield) < CalculatedDamage - 2;
          }
  
          internal static bool isManaPercentOkay(this AIHeroClient hero, int ManaPercent)
          {
              return hero.ManaPercent > ManaPercent;
          }
  
          internal static double isImmobileUntil(this AIHeroClient unit)
          {
              var result =
                  unit.Buffs.Where(
                      buff =>
  
gt:                         buff.IsActive && Game.Time <= buff.EndTime &&