public static bool TryParseData(string data, out Levelset set) { try { dynamic parsed = JObject.Parse(data); int[] arr = parsed.LevelSet.ToObject <int[]>(); set = new Levelset { LevelsetData = arr }; return(true); } catch (JsonSerializationException ex) { Logger.Send("Exception occurred in LevelSet on JSON parse:", ex, Logger.LogLevel.Error); Logger.Send("Exception occurred during LevelSet JSON parse. AutoShop will most likely NOT work properly!", Logger.LogLevel.Warn); set = null; if (Player.Instance.ChampionName.Equals("Ryze")) { set = new Levelset(MaxRyze); } if (MaxQChampions.Any(s => s.Equals(Player.Instance.ChampionName, StringComparison.CurrentCultureIgnoreCase))) { set = new Levelset(MaxQSequence); } if (MaxWChampions.Any(s => s.Equals(Player.Instance.ChampionName, StringComparison.CurrentCultureIgnoreCase))) { set = new Levelset(MaxWSequence); } if (MaxEChampions.Any(s => s.Equals(Player.Instance.ChampionName, StringComparison.CurrentCultureIgnoreCase))) { set = new Levelset(MaxESequence); } return(false); } }
private static void LevelSpells() { var qL = Player.Instance.Spellbook.GetSpell(SpellSlot.Q).Level - R1(); var wL = Player.Instance.Spellbook.GetSpell(SpellSlot.W).Level - R1(); var eL = Player.Instance.Spellbook.GetSpell(SpellSlot.E).Level - R1(); var rL = Player.Instance.Spellbook.GetSpell(SpellSlot.R).Level - R1(); var level = new[] { 0, 0, 0, 0 }; if (qL + wL + eL + rL < Player.Instance.Level) { int[] LevelSet = CurrentLevelset?.LevelsetData; if (CurrentLevelset == null || LevelSet == null) { CurrentLevelset = new Levelset(); if (Player.Instance.ChampionName.Equals("Ryze")) { CurrentLevelset.LevelsetData = MaxRyze; } if (MaxQChampions.Any(s => s.Equals(Player.Instance.ChampionName, StringComparison.CurrentCultureIgnoreCase))) { CurrentLevelset.LevelsetData = MaxQSequence; } if (MaxWChampions.Any(s => s.Equals(Player.Instance.ChampionName, StringComparison.CurrentCultureIgnoreCase))) { CurrentLevelset.LevelsetData = MaxWSequence; } if (MaxEChampions.Any(s => s.Equals(Player.Instance.ChampionName, StringComparison.CurrentCultureIgnoreCase))) { CurrentLevelset.LevelsetData = MaxESequence; } LevelSet = CurrentLevelset.LevelsetData; } for (var i = 0; i < Player.Instance.Level; i++) { if (LevelSet != null) { level[LevelSet[i] - 1] = level[LevelSet[i] - 1] + 1; } } if (qL < level[0] && Player.Instance.Spellbook.CanSpellBeUpgraded(SpellSlot.Q)) { Player.LevelSpell(SpellSlot.Q); } if (wL < level[1] && Player.Instance.Spellbook.CanSpellBeUpgraded(SpellSlot.W)) { Player.LevelSpell(SpellSlot.W); } if (eL < level[2] && Player.Instance.Spellbook.CanSpellBeUpgraded(SpellSlot.E)) { Player.LevelSpell(SpellSlot.E); } if (rL < level[3] && Player.Instance.Spellbook.CanSpellBeUpgraded(SpellSlot.R)) { Player.LevelSpell(SpellSlot.R); } } if (Player.Instance.EvolvePoints > 0) { switch (I) { case 0: Player.EvolveSpell(SpellSlot.Q); I++; return; case 1: Player.EvolveSpell(SpellSlot.W); I++; return; case 2: Player.EvolveSpell(SpellSlot.E); I++; return; case 3: Player.EvolveSpell(SpellSlot.R); I++; return; } } }