context: using System;
  using System.Drawing;
  using System.Linq;
  using LeagueSharp;
  using LeagueSharp.Common;
  
  using EloBuddy; 
   using LeagueSharp.Common; 
   namespace EasyPeasyRivenSqueezy
  {
      /// <summary>
      ///     Manages Riven's stuff, such as Passive, Q, Ult, etc., and loads stuff :D
      /// </summary>
      internal class Riven
      {
          //TODO: organize this shit
          public static int QCount
          {
              get
              {
                  return Player.HasBuff("RivenTriCleave", true)
                      ? Player.Buffs.FirstOrDefault(x => x.Name == "RivenTriCleave").Count
                      : 0;
              }
          }
  
          public static Menu Menu { get; set; }
          public static Orbwalking.Orbwalker Orbwalker { get; set; }
  
          public static float EWRange
          {
              get { return E.Range + W.Range/2 + Player.BoundingRadius; }
          }
  
          public static Spell Q { get; internal set; }
          public static Spell W { get; internal set; }
          public static Spell E { get; internal set; }
          public static Spell R { get; internal set; }
          public static Spell Ignite { get; internal set; }
          public static int LastQ { get; internal set; }
  
          public static bool RActivated
          {
              get { return Player.HasBuff("RivenFengShuiEngine", true); }
          }
  
          public static bool CanWindSlash
          {
              get { return Player.HasBuff("rivenwindslashready", true); }
          }
  
          public static float PassiveDmg
          {
              get
              {
                  double[] dmgMult = {0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5};
                  var dmg = (Player.FlatPhysicalDamageMod + Player.BaseAttackDamage)*dmgMult[Player.Level/3];
                  return (float) dmg;
              }
          }
  
          public static AIHeroClient Player
          {
              get { return ObjectManager.Player; }
          }
  
          public static int QDelay { get; set; }
          public static Obj_AI_Base LastTarget { get; set; }
          public static bool CanQ { get; set; }
  
          public static void OnGameLoad()
          {
              if (Player.ChampionName != "Riven")
              {
                  return; // This guy is missing out..
              }
  
              CreateMenu();
  
              Q = new Spell(SpellSlot.Q, 260) {Delay = 0.5f};
              W = new Spell(SpellSlot.W, 260);
              E = new Spell(SpellSlot.E, 250) {Delay = 0.3f, Speed = 1450};
              R = new Spell(SpellSlot.R, 1100);
              Ignite = new Spell(Player.GetSpellSlot("summonerdot"), 600);
  
              Q.SetSkillshot(0.5f, 100, 1400, false, SkillshotType.SkillshotCone);
              R.SetSkillshot(0.25f, 150, 2200, false, SkillshotType.SkillshotCone);
  
              Obj_AI_Base.OnPlayAnimation += Obj_AI_Base_OnPlayAnimation;
              Obj_AI_Base.OnProcessSpellCast += Obj_AI_Base_OnProcessSpellCast;
  
              Game.OnUpdate += RivenCombo.OnGameUpdate;
              Drawing.OnDraw += DrawingOnOnDraw;
  
              AntiGapcloser.OnEnemyGapcloser += AntiGapcloserOnOnEnemyGapcloser;
              Interrupter2.OnInterruptableTarget += Interrupter2OnOnInterruptableTarget;
  
              LeagueSharp.Common.Utility.HpBarDamageIndicator.Enabled = true;
              LeagueSharp.Common.Utility.HpBarDamageIndicator.DamageToUnit = RivenCombo.GetDamage;
  
              NotificationHandler.ShowWelcome();
  
              Chat.Print("<font color=\"#7CFC00\"><b>EasyPeasyRivenSqueezy:</b></font> Loaded");
          }
  
          private static void Interrupter2OnOnInterruptableTarget(AIHeroClient sender,
              Interrupter2.InterruptableTargetEventArgs args)
          {
              if (!sender.IsValidTarget(EWRange) || !GetBool("InterruptEW"))
              {
                  NotificationHandler.ShowInterrupterAlert(false);
                  return;
              }
  
              E.Cast(sender.Position);
              W.Cast();
  
              NotificationHandler.ShowInterrupterAlert(true);
          }
  
          private static void AntiGapcloserOnOnEnemyGapcloser(ActiveGapcloser gapcloser)
          {
              if (!gapcloser.Sender.IsValidTarget() || !GetBool("HandleGapclosers"))
              {
                  return;
              }
  
              if (Orbwalker.ActiveMode == Orbwalking.OrbwalkingMode.Combo && RivenCombo.CanHardEngage(gapcloser.Sender))
              {
                  R.Cast();
                  RivenCombo.CastCircleThing();
                  W.Cast();
              }
              else if (gapcloser.Sender.IsValidTarget(Q.Range + Player.BoundingRadius) && QCount == 2)
              {
                  Q.Cast(gapcloser.Sender.ServerPosition);
              }
              else if (gapcloser.Sender.IsValidTarget(W.Range))
              {
                  W.Cast();
              }
  
              NotificationHandler.ShowGapcloserAlert();
          }
  
          private static void DrawingOnOnDraw(EventArgs args)
          {
              var drawEngage = Menu.Item("DrawEngageRange").GetValue<bool>();
              var drawQ = Menu.Item("DrawQ").GetValue<bool>();
              var drawW = Menu.Item("DrawW").GetValue<bool>();
              var drawE = Menu.Item("DrawE").GetValue<bool>();
              var drawR = Menu.Item("DrawR").GetValue<bool>();
              var p = Player.Position;
  
              if (drawEngage)
              {
                  Render.Circle.DrawCircle(p, EWRange, E.IsReady() && W.IsReady() ? Color.Aqua : Color.Red);
              }
  
              if (drawQ)
              {
                  Render.Circle.DrawCircle(p, Q.Range, Q.IsReady() ? Color.Aqua : Color.Red);
              }
  
              if (drawW)
              {
                  Render.Circle.DrawCircle(p, W.Range, W.IsReady() ? Color.Aqua : Color.Red);
              }
  
              if (drawE)
              {
                  Render.Circle.DrawCircle(p, E.Range, E.IsReady() ? Color.Aqua : Color.Red);
              }
  
              if (drawR)
              {
                  Render.Circle.DrawCircle(p, R.Range, R.IsReady() ? Color.Aqua : Color.Red);
              }
          }
  
          private static void Obj_AI_Base_OnProcessSpellCast(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args)
          {
              if (!sender.IsMe)
              {
                  return;
              }
  
              if (args.SData.Name == "RivenFengShuiEngine" && GetBool("KeepRAlive"))
              {
                  LeagueSharp.Common.Utility.DelayAction.Add(
                      (int) (15000 - Game.Ping/2 - R.Delay*1000), delegate
                      {
                          if (CanWindSlash)
                          {
                              var bestTarget =
                                  ObjectManager.Get<AIHeroClient>()
                                      .Where(x => x.IsValidTarget(R.Range))
                                      .OrderBy(x => x.Health)
                                      .FirstOrDefault();
  
                              if (bestTarget != null)
                              {
                                  R.Cast(bestTarget);
                              }
                          }
                      });
              }
          }
  
          public static bool GetBool(string item)
          {
              return Menu.Item(item).GetValue<bool>();
          }
  
          private static void CreateMenu()
          {
              (Menu = new Menu("EasyPeasyRivenSqueezy", "cmEZPZ_Riven", true)).AddToMainMenu();
  
              var orbwalkMenu = new Menu("Orbwalker", "orbwalk");
              Orbwalker = new Orbwalking.Orbwalker(orbwalkMenu);
              Menu.AddSubMenu(orbwalkMenu);
  
              var tsMenu = new Menu("Target Selector", "ts");
              TargetSelector.AddToMenu(tsMenu);
              Menu.AddSubMenu(tsMenu);
  
  
gt:             var comboMenu = new Menu("Combo", "combo_kek");