Exemplo n.º 1
0
    public static void WriteRuneTotals(SummonerDto summoner, RunePagesDtoManager runePagesManager, string region, HttpServerUtility server)
    {
        List <string> lines = new List <string>();

        if (runePagesManager.CurrentPage != null)
        {
            lines.Add(runePagesManager.CurrentPage.name);
            lines.Add(runePagesManager.RunePageTotalsTable(runePagesManager.CurrentPage));
        }
        else
        {
            lines.Add("");
            lines.Add("");
        }

        foreach (RunePageDto runePage in runePagesManager.runePagesDto.pages)
        {
            if (!runePage.current)
            {
                lines.Add(runePage.name);
                lines.Add(runePagesManager.RunePageTotalsTable(runePage));
            }
        }

        File.WriteAllLines(server.MapPath(@"~/App_Data/Summoner_Data/" + region + '/' + summoner.id + @"/runetotals.dat"), lines);
    }
Exemplo n.º 2
0
        static void Cmd()
        {
            string cmd = Console.ReadLine();

            if (cmd.StartsWith("getCurGame"))
            {
                string[] pieces = cmd.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                if (pieces.Length == 2)
                {
                    string      ID     = pieces[1];
                    SummonerDto Chuvak = GetData.GetSummonerByName(ID);
                    if (Chuvak == null)
                    {
                        Out("Cant find that dude", ConsoleColor.DarkYellow);
                    }
                    else
                    {
                        CurrentGameInfo Data = GetData.GetCurrentGameInfo(Chuvak.id.ToString());
                        if (Data == null)
                        {
                            Out("Cant find game", ConsoleColor.DarkYellow);
                        }
                        else
                        {
                            Out(Data.gameMode + " " + Data.gameType, ConsoleColor.DarkCyan);
                            foreach (CurrentGameParticipant Chelik in Data.participants)
                            {
                                if (Chelik.summonerId == Chuvak.id)
                                {
                                    try
                                    {
                                        Static.ChampionDto Champ = GetData.GetChampById(Chelik.championId.ToString());
                                        Static.TempRune    Rune  = RitoPls.OfflineData.OfflineData.GetRune(Chelik.perks.perkIds[0]);
                                        Out(Champ.name + " with " + Rune.name, ConsoleColor.DarkGreen);
                                    }
                                    catch (Exception e)
                                    {
                                        Out(@"\\\\\ Exception \\\\\", ConsoleColor.DarkGray);
                                        Out(e.ToString());
                                        Out(@"/////////////////////", ConsoleColor.DarkGray);
                                        break;
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    Ebanuty();
                }
            }
            else
            {
                Ebanuty();
            }

            Cmd();
        }
Exemplo n.º 3
0
    string buildOtherRunePagesFromFile(SummonerDto summoner)
    {
        string[] lines = SummonerDataManager.ReadRuneTotals(summoner, regionRadioList.SelectedValue, Server);

        StringBuilder sb = new StringBuilder();

        for (int i = 2; i < lines.Length; i += 2)
        {
            if (lines[i + 1] != "")
            {
                sb.Append("<span class=\"PageName\">");
                sb.Append(lines[i]);
                sb.Append("</span><br/><br/>");

                sb.Append("<span class=\"RuneTotals\">");
                sb.Append(lines[i + 1]);
                sb.Append("</span><br/><br/>");
            }
        }

        if (sb.Length > 10)
        {
            sb.Remove(sb.Length - 10, 10);
        }

        if (sb.Length == 0)
        {
            sb.Append("<span class=\"PageName\">none</span><br/>");
        }

        return(sb.ToString());
    }
Exemplo n.º 4
0
        public static MatchDto GetMostRecentMatch(string summonerName)
        {
            SummonerDto needTheId = GetSummonerMetaByName(summonerName);

            MatchReferenceDto mostRecentMatch = GetRecentMatchesBySummonerId(needTheId.AccountId).Matches.OrderByDescending(x => x.TimeStamp).First();

            return(GetMatchByMatchId(mostRecentMatch.GameId));
        }
Exemplo n.º 5
0
        public static ChampionDto GetMostRecentlyPlayedChamp(string summonerName)
        {
            SummonerDto needTheId = GetSummonerMetaByName(summonerName);

            MatchReferenceDto mostRecentMatch = GetRecentMatchesBySummonerId(needTheId.Id).Matches.OrderByDescending(x => x.TimeStamp).First();

            int mostRecentChampId = Convert.ToInt32(mostRecentMatch.Champion);

            return(GetChampionFromIDHttpClient(mostRecentChampId));
        }
Exemplo n.º 6
0
        private async void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            string      nameSummoner = NavigationContext.QueryString["name"];
            SummonerDto summoner     = new SummonerDto();

            try
            {
                summoner = await summoner.SearchSummoner(nameSummoner);

                textBlockNomeInv.Text = summoner.Nome;
            }
            catch
            {
                MessageBox.Show("Não existe um invocador com esse nome.");
                NavigationService.GoBack();
                return;
            }
            textBlockLevel.Text += summoner.SummonerLevel.ToString();
            try
            {
                LeagueDto leagueSummoner = new LeagueDto();
                leagueSummoner = await leagueSummoner.SearchLeague(summoner.Id);

                textBlockElo.Text = leagueSummoner.Tier + " " + leagueSummoner.Entries[0].Division;
                textBlockVit.Text = leagueSummoner.Entries[0].Wins > 1 ? leagueSummoner.Entries[0].Wins.ToString() + " vitórias" : leagueSummoner.Entries[0].Wins.ToString() + " vitória";
                textBlockDer.Text = leagueSummoner.Entries[0].Losses > 1 ? leagueSummoner.Entries[0].Losses.ToString() + " derrotas" : leagueSummoner.Entries[0].Losses.ToString() + " derrota";
            }
            catch
            {
                MessageBox.Show("Informações de derrotas e vitórias são apenas para jogadores ranqueados.", "Informação", MessageBoxButton.OK);
                textBlockElo.Text = "Unranked";
                textBlockVit.Text = "0 vitória";
                textBlockDer.Text = "0 derrota";
            }
            imageInvocador.Source = await summoner.GetProfileIcon();

            RecentGamesDto gamesRecent         = await new RecentGamesDto().GetLatestGamesById(summoner.Id);
            List <int>     lastChampionsPlayed = new List <int>();

            foreach (GameDto game in gamesRecent.Games)
            {
                lastChampionsPlayed.Add(game.ChampionId);
                LastMatches controlMatch = new LastMatches(game);
                controlMatch.Margin = new Thickness(0, 0, 0, 10);
                controlMatch.Load();
                listboxPartidas.Items.Add(controlMatch);
            }
            int         idChampPref = lastChampionsPlayed[new Random().Next(lastChampionsPlayed.Count - 1)];
            ImageBrush  imgBrush    = new ImageBrush();
            BitmapImage source      = (await ChampionDto.SearchChampionAllData(idChampPref)).GetChampionSplash(0);

            imgBrush.ImageSource  = source;
            imgBrush.Stretch      = Stretch.UniformToFill;
            LayoutRoot.Background = imgBrush;
        }
Exemplo n.º 7
0
    public static void ResetSummonerRevisionDate(SummonerDto summoner, string region, HttpServerUtility server)
    {
        string summonerFilePath = server.MapPath(@"~/App_Data/Summoner_Data/" + region + '/' + summoner.id);

        if (Directory.Exists(summonerFilePath))
        {
            string[] lines = File.ReadAllLines(summonerFilePath + @"/info.txt");

            lines[0] = "0";

            File.WriteAllLines(summonerFilePath + @"/info.txt", lines);
        }
    }
Exemplo n.º 8
0
    public static MasteryPagesDto ReadSummonerMasteriesFile(SummonerDto summoner, string region, HttpServerUtility server)
    {
        string summonerMasteriesPath = server.MapPath(@"~/App_Data/Summoner_Data/" + region + '/' + summoner.id + @"/masteries.json");

        FileStream fin = File.OpenRead(summonerMasteriesPath);

        JsonSerializer  serializer     = new JsonSerializer();
        JsonTextReader  jsonTextReader = new JsonTextReader(new StreamReader(fin));
        MasteryPagesDto masterypages   = (MasteryPagesDto)serializer.Deserialize(jsonTextReader, typeof(MasteryPagesDto));

        fin.Close();

        return(masterypages);
    }
Exemplo n.º 9
0
    public static bool HasSummonerChanged(SummonerDto summoner, string region, HttpServerUtility server)
    {
        string summonerFilePath = server.MapPath(@"~/App_Data/Summoner_Data/" + region + '/' + summoner.id);

        if (Directory.Exists(summonerFilePath))
        {
            long revisionDate = long.Parse(File.ReadAllLines(summonerFilePath + @"/info.txt")[0]);

            return(revisionDate != summoner.revisionDate);
        }
        else
        {
            return(true);
        }
    }
Exemplo n.º 10
0
        public static CurrentGameInfo GetCurrentGameBySummonerName(string name, string platform)
        {
            CurrentGameInfo result;

            try
            {
                SummonerDto summoners = Summoner.GetSummonerByName(name, platform);
                result = Request.GetData(platform, String.Format("observer-mode/rest/consumer/getSpectatorGameInfo/{0}/{1}?", platform.ToUpperInvariant(), summoners.id), typeof(CurrentGameInfo));
            }
            catch (Exception)
            {
                return(null);
            }
            return(result);
        }
Exemplo n.º 11
0
    public static void WriteSummonerMasteriesFile(SummonerDto summoner, MasteryPagesDto masteryPages, string region, HttpServerUtility server)
    {
        string summonerMasteriesPath = server.MapPath(@"~/App_Data/Summoner_Data/" + region + '/' + summoner.id + @"/masteries.json");

        FileStream fout = File.OpenWrite(summonerMasteriesPath);

        JsonSerializer serializer     = new JsonSerializer();
        JsonTextWriter jsonTextWriter = new JsonTextWriter(new StreamWriter(fout));

        serializer.Serialize(jsonTextWriter, masteryPages);

        jsonTextWriter.Flush();
        jsonTextWriter.Close();

        fout.Close();
    }
Exemplo n.º 12
0
    public static void WriteSummonerInfoFile(SummonerDto summoner, string region, HttpServerUtility server)
    {
        string summonerFilePath = server.MapPath(@"~/App_Data/Summoner_Data/" + region + '/' + summoner.id);

        string str = summoner.revisionDate + "\n" +
                     summoner.id + "\n" +
                     summoner.name + "\n" +
                     summoner.profileIconId + "\n" +
                     summoner.summonerLevel;

        if (!Directory.Exists(summonerFilePath))
        {
            Directory.CreateDirectory(summonerFilePath);
        }

        File.WriteAllText(summonerFilePath + @"/info.txt", str);
    }
Exemplo n.º 13
0
        static void Main(string[] args)
        {
            string APIKeyFile = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "APIKey.txt");

            if (!File.Exists(APIKeyFile))
            {
                Console.WriteLine("Please enter in your API Key");
                string apiKey = Console.ReadLine();
                LeagueAPIStaticFunctions.ApiClient.DefaultRequestHeaders.Add(LeagueURLConstants.HeaderConstants.APIKeyHeader, apiKey);
                File.WriteAllText(APIKeyFile, apiKey);
            }
            else
            {
                LeagueAPIStaticFunctions.ApiClient.DefaultRequestHeaders.Add(LeagueURLConstants.HeaderConstants.APIKeyHeader, File.ReadAllText(APIKeyFile));
            }

            ChampionMetaDtoList freeToPlayMetaList = LeagueAPIStaticFunctions.GetCurrentFreeToPlayListHttpClient();

            List <ChampionDto> freeToPlayList = new List <ChampionDto>();

            foreach (ChampionMetaDto champMeta in freeToPlayMetaList.Champions)
            {
                freeToPlayList.Add(LeagueAPIStaticFunctions.GetChampionFromIDHttpClient(Convert.ToInt32(champMeta.Id)));
            }

            foreach (ChampionDto champ in freeToPlayList)
            {
                Console.WriteLine(string.Format("{0:000}: {1}", champ.Id, champ.Name));
            }

            Console.WriteLine("Please enter the name of a summoner to get information for");
            string summonerName = Console.ReadLine();

            //This name should really be checked before doing this
            //Riot would probably yell at me.
            SummonerDto summoner = LeagueAPIStaticFunctions.GetSummonerMetaByName(summonerName);

            Console.WriteLine(string.Format("The ID for Summoner with name {0} is {1}", summonerName, summoner.Id));

            ChampionDto MostRecentChamp = LeagueAPIStaticFunctions.GetMostRecentlyPlayedChamp(summonerName);

            Console.WriteLine(string.Format("The most recent champt that {0} played is {1}", summonerName, MostRecentChamp.Name));

            Console.ReadLine();
        }
Exemplo n.º 14
0
    string buildCurrentRunePageFromFile(SummonerDto summoner)
    {
        string[] lines = SummonerDataManager.ReadRuneTotals(summoner, regionRadioList.SelectedValue, Server);

        string str = "";

        if (lines[1] == "")
        {
            str += "<span class=\"PageName\">none</span><br/>";
        }
        else
        {
            str += "<span class=\"PageName\">" + lines[0] + "</span><br/><br/>";
            str += "<span class=\"RuneTotals\">" + lines[1] + "</span>";
        }

        return(str);
    }
Exemplo n.º 15
0
        // GET: api/RiotGames
        public SummonerDto Get()
        {
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri("https://euw.api.pvp.net/api/lol/euw/v1.4/summoner/by-name/xFlawZy?api_key=RGAPI-fcc50458-8344-4759-9ebd-30716cb922e9");
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            var response = client.GetAsync("").Result;
            var summoner = new SummonerDto();

            if (response.IsSuccessStatusCode)
            {
                summoner = response.Content.ReadAsAsync <SummonerDto>().Result;
            }

            return(summoner);
        }
Exemplo n.º 16
0
        public async new Task <ActionResult> Profile()
        {
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri("http://localhost:60030/api/RiotGames");
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            HttpResponseMessage response = await client.GetAsync("");

            var summoner = new SummonerDto();

            if (response.IsSuccessStatusCode)
            {
                summoner = await response.Content.ReadAsAsync <SummonerDto>();
            }

            return(View(summoner));
        }
Exemplo n.º 17
0
        public static SummonerDto GetSummonerByName(string name, string platform)
        {
            SummonerDto summoner = null;

            try
            {
                string encodedName = System.Web.HttpUtility.UrlPathEncode(name);
                Dictionary <String, SummonerDto> result = Request.GetData(platform, String.Format("api/lol/{0}/v1.4/summoner/by-name/{1}?", Request.RegionName[platform], encodedName), typeof(Dictionary <String, SummonerDto>));
                summoner = result.Values.First();
                BaronReplays.Database.PublicDatabaseManager.Instance.AddSummonerId(summoner.id, summoner.name, platform);
                Logger.Instance.WriteLog(String.Format("Summoner Id of {0} in {1} is {2}", name, platform, summoner.id));
            }
            catch (Exception e)
            {
                Logger.Instance.WriteLog(String.Format("GetSummonerByName failed: {0}", e.Message));
            }

            return(summoner);
        }
Exemplo n.º 18
0
        public static SummonerDto GetSummonerMetaByName(string name)
        {
            string sURL = String.Format(LeagueURLConstants.APIPaths.SummonerMetaPath, name);

            SummonerDto summoner = null;

            using (StreamReader response = new StreamReader(ApiClient.GetStreamAsync(sURL).Result))
                using (JsonReader jsonResponse = new JsonTextReader(response))
                {
                    JsonSerializer serializer = new JsonSerializer();
                    summoner = serializer.Deserialize <SummonerDto>(jsonResponse);
                }

            if (summoner == null)
            {
                Console.WriteLine("Error occured while trying to retreive summoner information for {0}", name);
            }

            return(summoner);
        }
Exemplo n.º 19
0
        private async void buttonCadastro_Click(object sender, RoutedEventArgs e)
        {
            if (nomeInvocador.Text == string.Empty)
            {
                MessageBox.Show("Digite o nome do invocador antes de se cadastrar.");
            }
            else
            {
                summoner = new SummonerDto();
                try
                {
                    summoner = await summoner.SearchSummoner(nomeInvocador.Text);

                    ls = new LeagueWS.LeagueServiceClient();
                    ls.encontrarUsuarioCompleted += Ls_encontrarUsuarioCompleted;
                    ls.encontrarUsuarioAsync(nomeInvocador.Text);
                }
                catch (Exception)
                {
                    MessageBox.Show("Erro ao procurar invocador.");
                }
            }
        }
Exemplo n.º 20
0
 void showPlayerInfo(SummonerDto summoner)
 {
     playerInfoLabel.Text = "<div id=\"playerInfoBorder\"><span style=\"margin-bottom: 0px; padding-bottom: 0px; font-size: x-large; font-weight: bold\">" + summoner.name + "</span><br/><span style=\"font-size: 12px; margin-top: 0px; padding-top: 0px\">Level " + summoner.summonerLevel + "</span></div>";
 }
Exemplo n.º 21
0
        public void ThenIVeGottenInformationForSummonerId(int id)
        {
            SummonerDto summoner = ScenarioContext.Current["SUMMONER_DTO"] as SummonerDto;

            Assert.IsTrue(summoner.Id.Equals(id));
        }
Exemplo n.º 22
0
 public static bool MasteriesFileExists(SummonerDto summoner, string region, HttpServerUtility server)
 {
     return(File.Exists(server.MapPath(@"~/App_Data/Summoner_Data/" + region + '/' + summoner.id + @"/masteries.json")));
 }
Exemplo n.º 23
0
 public static bool RunesFileExists(SummonerDto summoner, string region, HttpServerUtility server)
 {
     return(File.Exists(server.MapPath(@"~/App_Data/Summoner_Data/" + region + '/' + summoner.id + @"/runetotals.dat")));
 }
        public async Task <Summoner> GetSummoner(string summonerName)
        {
            try
            {
                using (CancellationTokenSource cts = new CancellationTokenSource(_timeout))
                {
                    if (summonerName.Length > 16)
                    {
                        return(new Summoner(summonerName, SummonerNameAvailability.TooLong));
                    }

                    // Fetch Summoner
                    SummonerDto summonerDto = null;
                    try
                    {
                        summonerDto = await ApiRequestAsync <SummonerDto>($"summoner/v4/summoners/by-name/{summonerName}?api_key={_apiKey}", cts.Token);
                    }
                    catch (ApiRequestException e)
                    {
                        if (e.StatusCode == HttpStatusCode.NotFound)
                        {
                            // 404 = summoner does not exist
                            return(new Summoner(summonerName, SummonerNameAvailability.AvailableNotFound));
                        }
                        throw;
                    }

                    if (summonerDto == null)
                    {
                        return(new Summoner(summonerName, SummonerNameAvailability.Unknown));
                    }

                    // Fetch Summoner's match history
                    MatchListDto matchListDto = null;
                    try
                    {
                        matchListDto = await ApiRequestAsync <MatchListDto>($"match/v4/matchlists/by-account/{summonerDto.AccountId}?api_key={_apiKey}", cts.Token);
                    }
                    catch (ApiRequestException e)
                    {
                        if (e.StatusCode == HttpStatusCode.NotFound)
                        {
                            // 404 = no matches played
                            return(new Summoner(summonerName, SummonerNameAvailability.UnknownNeverPlayed));
                        }
                        throw;
                    }

                    if (matchListDto == null || !matchListDto.Matches.Any())
                    {
                        return(new Summoner(summonerName, SummonerNameAvailability.UnknownNeverPlayed));
                    }

                    return(new Summoner(
                               summonerDto.Name,
                               summonerDto.SummonerLevel,
                               summonerDto.Id,
                               summonerDto.AccountId,
                               DateTimeOffset.FromUnixTimeMilliseconds(matchListDto.Matches.First().Timestamp).UtcDateTime));
                }
            }
            catch (Exception e) when(e is ApiRequestException || e is OperationCanceledException)
            {
                return(new Summoner(summonerName, SummonerNameAvailability.Unknown));
            }
        }
Exemplo n.º 25
0
 public static string[] ReadRuneTotals(SummonerDto summoner, string region, HttpServerUtility server)
 {
     return(File.ReadAllLines(server.MapPath(@"~/App_Data/Summoner_Data/" + region + '/' + summoner.id + @"/runetotals.dat")));
 }
Exemplo n.º 26
0
        public async Task <IActionResult> Index(SummonerDto dto)
        {
            dto = await _service.UpdateSummonerAsync(dto.Name);

            return(View("Detail", dto));
        }