コード例 #1
0
        public async Task UploadToClient(IPerks perks)
        {
            if (!GameState.CanUpload)
            {
                return;
            }

            VerifyRunes();

            var page = new LolPerksPerkPageResource
            {
                primaryStyleId  = PrimaryTree,
                subStyleId      = SecondaryTree,
                selectedPerkIds = RuneIDs,
                name            = this.Name ?? Riot.GetChampion(ChampionID).Name + " - " + Enum.GetName(typeof(Position), Position)
            };

            LogTo.Debug("Uploading rune page with name '{0}' and runes [ {1} ]", page.name, string.Join(", ", RuneIDs));

            if (Config.Current.LastRunePageId != default)
            {
                try
                {
                    await perks.DeletePageAsync(Config.Current.LastRunePageId);
                }
                catch
                {
                }
            }

            try
            {
                var pageRet = await perks.PostPageAsync(page);

                Config.Current.LastRunePageId = pageRet.id;
            }
            catch (APIErrorException ex) when(ex.Message == "Max pages reached")
            {
                LogTo.Info("Max number of rune pages reached, deleting current page and trying again");

                var currentPage = await perks.GetCurrentPageAsync();

                if (currentPage.isDeletable)
                {
                    await perks.DeletePageAsync(currentPage.id);
                    await UploadToClient(perks);
                }
                else
                {
                    MainWindow.ShowNotification(Text.CantUploadPageTitle, Text.CantUploadPageMessage);
                    return;
                }
            }
        }
コード例 #2
0
        public async Task UploadToClient(IPerks perks)
        {
            if (!GameState.CanUpload)
            {
                return;
            }

            var page = new LolPerksPerkPageResource {
                primaryStyleId  = PrimaryTree,
                subStyleId      = SecondaryTree,
                selectedPerkIds = RuneIDs,
                name            = this.Name ?? (await Riot.GetChampion(ChampionID)).Name + " - " + Enum.GetName(typeof(Position), Position)
            };

            LogTo.Debug("Uploading rune page with name '{0}' and runes [ {1} ]", page.name, string.Join(", ", RuneIDs));

            if (Config.Current.LastRunePageId != default)
            {
                try {
                    await perks.DeletePageAsync(Config.Current.LastRunePageId);
                } catch {
                }
            }

            try {
                var pageRet = await perks.PostPageAsync(page);

                Config.Current.LastRunePageId = pageRet.id;
            } catch (APIErrorException ex) when(ex.Message == "Max pages reached")
            {
                LogTo.Info("Max number of rune pages reached, deleting previous page and trying again");

                var pages = await perks.GetPagesAsync();

                var replacedPage = pages.FirstOrDefault(p => p.name.StartsWith(Config.Current.LockLoadProvider));

                if (replacedPage == null)
                {
                    replacedPage = await perks.GetCurrentPageAsync();
                }

                if (replacedPage.isDeletable)
                {
                    await perks.DeletePageAsync(replacedPage.id);
                    await UploadToClient(perks);
                }
                else
                {
                    LCUApp.MainWindow.ShowNotification("Couldn't upload rune page", "There is no room for more pages.");
                    return;
                }
            }
        }
コード例 #3
0
ファイル: Perks.cs プロジェクト: pipe01/LCU.NET
 /// <summary>
 /// Creates a new rune page.
 /// </summary>
 /// <param name="page">The new page.</param>
 public Task <LolPerksPerkPageResource> PostPageAsync(LolPerksPerkPageResource page)
 => Client.MakeRequestAsync <LolPerksPerkPageResource>("/lol-perks/v1/pages", Method.POST, page);
コード例 #4
0
ファイル: Perks.cs プロジェクト: pipe01/LCU.NET
 /// <summary>
 /// Updates a rune page.
 /// </summary>
 /// <param name="id">The page's ID.</param>
 /// <param name="page">The new page.</param>
 public Task <LolPerksPerkPageResource> PutPageAsync(int id, LolPerksPerkPageResource page)
 => Client.MakeRequestAsync <LolPerksPerkPageResource>($"/lol-perks/v1/pages/{id}", Method.PUT, page);
コード例 #5
0
 /// <summary>
 /// </summary>
 /// <param name="session">The session object</param>
 /// <param name="id"></param>
 /// <param name="page"></param>
 /// <returns></returns>
 public static Task <dynamic> Put(LeagueClientSession session, int id, LolPerksPerkPageResource page) =>
 session.SendRequestAsync <dynamic>("PUT", $"/lol-perks/v1/pages/{id}", body: page);
コード例 #6
0
 /// <summary>
 /// </summary>
 /// <param name="session">The session object</param>
 /// <param name="page"></param>
 /// <returns></returns>
 public static Task <LolPerksPerkPageResource> Post(LeagueClientSession session,
                                                    LolPerksPerkPageResource page) =>
 session.SendRequestAsync <LolPerksPerkPageResource>("POST", "/lol-perks/v1/pages", body: page);
コード例 #7
0
ファイル: LolPerks.cs プロジェクト: pipe01/lcu-api-generator
 public static Task <object> PutLolPerksV1PagesById([Parameter("id", "path")] int id, [Parameter("page", "body")] LolPerksPerkPageResource page)
 => Sender.Request <object>("put", $"/lol-perks/v1/pages/{id}", page);
コード例 #8
0
ファイル: LolPerks.cs プロジェクト: pipe01/lcu-api-generator
 public static Task <LolPerksPerkPageResource> PostLolPerksV1Pages([Parameter("page", "body")] LolPerksPerkPageResource page)
 => Sender.Request <LolPerksPerkPageResource>("post", $"/lol-perks/v1/pages", page);