public async Task UploadRunePage(Position pos, int championId)
        {
            LogTo.Debug("Trying to upload rune page");

            string champion = Riot.GetChampion(championId).Name;

            LogTo.Debug("for champion {0}", champion);

            Main.ShowNotification(Text.LockedInMessage, champion + ", " + pos.ToString().ToLower(), NotificationType.Success);

            var page = RuneBook.Instance.Get(championId, pos, false);

            if (page == null)
            {
                LogTo.Info("Invalid current rune page");

                if (Config.Current.LoadOnLock)
                {
                    LogTo.Info("Downloading from provider");
                    page = await Main.SafeInvoke(async() => await Main.LoadPageFromDefaultProvider(championId));

                    LogTo.Debug("Downloaded from provider");
                }
                else
                {
                    Main.ShowNotification(Text.PageChampNotSet.FormatStr(champion), null, NotificationType.Error);
                    return;
                }
            }

            LogTo.Debug("Uploading rune page to client");
            await page.UploadToClient(LoL.Perks);

            LogTo.Debug("Uploaded rune page to client");
        }
Beispiel #2
0
        public override async Task <ItemSet> GetItemSet(int championId, Position position)
        {
            if (position == Position.Fill)
            {
                position = (await GetPossibleRoles(championId))[0];
            }

            string champ = (await Riot.GetChampion(championId)).Key;
            var    json  = await WebCache.String($"http://lolflavor.com/champions/{champ}/Recommended/{champ}_{PositionToName[position]}_scrape.json", soft : true);

            if (json == null)
            {
                return(null);
            }

            var lolItemSet = JsonConvert.DeserializeObject <LolItemSetsItemSet> (json);

            return(new ItemSet {
                Champion = championId,
                Position = position,
                Name = Name + ": " + position,
                Blocks = lolItemSet.blocks.Select(o => new ItemSet.SetBlock {
                    Name = o.type,
                    Items = o.items.Select(i => int.Parse(i.id)).ToArray()
                }).ToArray()
            });
        }
Beispiel #3
0
        public override async Task <Position[]> GetPossibleRoles(int championId)
        {
            string champ = (await Riot.GetChampion(championId)).Key;

            var ret = new SynchronizedCollection <Position> ();

            await Task.WhenAll(PositionToName.Select(async item => {
                if (item.Key == Position.Fill)
                {
                    return;
                }

                var data = await WebCache.String($"http://lolflavor.com/champions/{champ}/Recommended/{champ}_{item.Value}_scrape.json", soft: true);

                if (data != null)
                {
                    ret.Add(item.Key);
                }
            }));

            return(ret.ToArray());
        }
        public async Task BanChampion(Position pos, LolChampSelectChampSelectAction myAction, LolChampSelectChampSelectPlayerSelection[] myTeam)
        {
            LogTo.Debug("Trying to ban champion");

            Dictionary <Position, int> bans = Config.Current.ChampionsToBan;
            var bannable = await LoL.ChampSelect.GetBannableChampions();

            var possibleBans = new List <int>();

            possibleBans.Add(bans[pos]);
            possibleBans.Add(bans[Position.Fill]);
            LogTo.Debug("possibleBans: {0}", string.Join(", ", possibleBans));

            int preferredBan = possibleBans.FirstOrDefault(bannable.championIds.Contains);
            var banName      = preferredBan > 0 ? Riot.GetChampion(preferredBan).Name : "None";

            LogTo.Debug("Preferred ban: {0}", banName);

            if (preferredBan == 0)
            {
                LogTo.Debug("Couldn't ban any champion");

                //TODO Add translatable string
                Main.ShowNotification("Couldn't ban any champion",
                                      "Maybe all of your selected champions were banned", NotificationType.Error);
                return;
            }

            var teamIntents = myTeam.Select(o => o.championPickIntent);

            if (teamIntents.Contains(preferredBan))
            {
                LogTo.Info("Wanted to ban {0}, but someone wants to play it", banName);

                Main.ShowNotification("Hey", $"Couldn't ban {banName} because someone wants to play it", NotificationType.Error);
                SystemSounds.Exclamation.Play();

                return;
            }

            LogTo.Debug("Candidate found ({0}), banning...", banName);
            myAction.championId = preferredBan;
            myAction.completed  = true;

            try
            {
                await LoL.ChampSelect.PatchActionById(myAction, myAction.id);

                LogTo.Debug("Champion banned");
            }
            catch (APIErrorException ex)
            {
                LogTo.DebugException("Couldn't ban champion", ex);
            }

            if (Config.DisableBanChampion)
            {
                LogTo.Debug("Unset auto ban champion");

                Config.AutoBanChampion = false;
                Config.Save();
            }
        }
Beispiel #5
0
 private static string GetChampionKey(int championId) => Riot.GetChampion(championId).Key;
 private static string GetChampionURL(int championId, Position?pos = null)
 => $"https://champion.gg/champion/{Riot.GetChampion(championId).Key}/"
 + (pos != null ? PositionToName[pos.Value] : "");
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            //Don't regenerate controls if coming back from another page
            if (Picks.Count > 0)
            {
                return;
            }

            GenerateControls();

            foreach (var item in Actuator.RuneProviders)
            {
                if (!(item is ClientProvider))
                {
                    if (item.Supports(Provider.Options.RunePages))
                    {
                        Providers.Items.Add(item);
                    }

                    if (item.Supports(Provider.Options.ItemSets))
                    {
                        ItemProviders.Items.Add(item);
                    }

                    if (item.Supports(Provider.Options.SkillOrder))
                    {
                        SkillProviders.Items.Add(item);
                    }


                    if (item.Name == Config.LockLoadProvider)
                    {
                        Providers.SelectedItem = item;
                    }

                    if (item.Name == Config.ItemSetProvider)
                    {
                        ItemProviders.SelectedItem = item;
                    }

                    if (item.Name == Config.SkillOrderProvider)
                    {
                        SkillProviders.SelectedItem = item;
                    }
                }
            }

            int i = 0;

            foreach (var item in Config.ChampionsToPick)
            {
                Picks[i++].Champion = Riot.GetChampion(item.Value);
            }

            i = 0;
            foreach (var item in Config.ChampionsToBan)
            {
                Bans[i++].Champion = Riot.GetChampion(item.Value);
            }

            var spells = await Riot.GetSummonerSpellsAsync();

            i = 0;
            foreach (var item in Config.SpellsToPick)
            {
                Spells[i++].Spell = spells.SingleOrDefault(o => o.ID == item.Value[0]);
                Spells[i++].Spell = spells.SingleOrDefault(o => o.ID == item.Value[1]);
            }
        }
Beispiel #8
0
 private static async Task <string> GetChampionKey(int championId) => (await Riot.GetChampion(championId)).Key;
Beispiel #9
0
 private static async Task <string> GetRoleUrl(int championId, Position position)
 => $"https://op.gg/champion/{(await Riot.GetChampion (championId)).Key}/statistics/{PositionToName[position]}";
Beispiel #10
0
 private static async Task <string> GetChampionURL(int championId, Position?pos = null)
 => $"https://champion.gg/champion/{(await Riot.GetChampion (championId)).Key}/"
 + (pos != null ? PositionToName[pos.Value] : "");
 private static string GetRoleUrl(int championId, Position position)
 => $"https://op.gg/champion/{Riot.GetChampion(championId).Key}/statistics/{PositionToName[position]}";