Esempio n. 1
0
        public async void RetrieveChallengerLeagueTest()
        {
            League challenger = await creepScore.RetrieveChallengerLeague(CreepScore.Region.NA, GameConstants.Queue.Solo5);

            LeagueEntry wildTurtle  = null;
            LeagueEntry zionSpartan = null;

            foreach (LeagueEntry entry in challenger.entries)
            {
                if (entry.playerOrTeamName == "Turtle the Cat")
                {
                    wildTurtle = entry;
                }
                else if (entry.playerOrTeamName == "ZionSpartan")
                {
                    zionSpartan = entry;
                }
            }

            if (wildTurtle != null)
            {
                Assert.Equal("Turtle the Cat", wildTurtle.playerOrTeamName);
                Assert.Equal("I", wildTurtle.division);
            }
            else if (zionSpartan != null)
            {
                Assert.Equal("ZionSpartan", zionSpartan.playerOrTeamName);
                Assert.Equal("I", zionSpartan.division);
            }
            else
            {
                Assert.True(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Stores player data.
        /// </summary>
        /// <param name="entry"></param>
        /// <param name="playerData"></param>
        public static void SetPlayerData(LeagueEntry entry, PlayerData playerData)
        {
            string filename = GetPlayerFilename(entry);
            string json     = JsonConvert.SerializeObject(playerData, Formatting.Indented);

            File.WriteAllText(filename, json);
        }
Esempio n. 3
0
        /// <summary>
        /// Set the update status of the current league
        /// </summary>
        /// <param name="leagueName">Shortname of the league</param>
        /// <param name="principal">Principal of the current User</param>
        protected void UpdateLeague(string leagueName, IPrincipal principal)
        {
            var register = LeagueRegister.Get();

            LeagueEntry leagueEntry = null;

            if (register.Leagues.Any(x => x.Name == leagueName) == false)
            {
                leagueEntry = new LeagueEntry()
                {
                    Name        = leagueName,
                    CreatorName = principal.Identity.Name,
                    OwnerId     = Guid.Parse(principal.Identity.GetUserId()),
                    CreatorId   = Guid.Parse(principal.Identity.GetUserId()),
                    CreatedOn   = DateTime.Now,
                    PrettyName  = leagueName
                };
                register.Leagues.Add(leagueEntry);
            }
            else
            {
                leagueEntry = register.Leagues.SingleOrDefault(x => x.Name == leagueName);
            }
            leagueEntry.LastUpdate = DateTime.Now;
            if (leagueEntry.OwnerId == null)
            {
                leagueEntry.OwnerId = leagueEntry.CreatorId;
            }

            register.Save();
        }
        public ActionResult DeleteConfirmed(int id)
        {
            LeagueEntry leagueEntry = db.LeagueEntries.Find(id);

            db.LeagueEntries.Remove(leagueEntry);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "id,LeagueId,TeamId")] LeagueEntry leagueEntry)
 {
     if (ModelState.IsValid)
     {
         db.Entry(leagueEntry).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.LeagueId = new SelectList(db.Leagues, "id", "LeagueName", leagueEntry.LeagueId);
     ViewBag.TeamId   = new SelectList(db.Teams, "id", "TeamName", leagueEntry.TeamId);
     return(View(leagueEntry));
 }
Esempio n. 6
0
        int CompareLadderPoints(LeagueEntry x, LeagueEntry y)
        {
            int returnValue = y.leaguePoints - x.leaguePoints;

            if (returnValue == 0)
            {
                return(CompareWins(x, y));
            }
            else
            {
                return(returnValue);
            }
        }
Esempio n. 7
0
        public static LeagueParsedData ParseLeague(LeagueEntry entry)
        {
            var data = new LeagueParsedData();

            data.FirstLine = PrettyQueue(entry.QueueType) + ": " + PrettyTier(entry.Tier) + " " + entry.Rank;
            data.LP        = entry.LeaguePoints + "LP ";
            var wr = (float)entry.Wins / entry.Losses * 50f;

            data.WinRatio      = (wr).ToString("0.00") + "% WR";
            data.WinRatioColor = GetWinRatioColor(wr);
            data.WinLoss       = "(" + entry.Wins + "W/" + entry.Losses + "L)";
            data.ImagePath     = GetLeaguePath(entry.Tier);
            return(data);
        }
        // GET: LeagueEntries/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LeagueEntry leagueEntry = db.LeagueEntries.Find(id);

            if (leagueEntry == null)
            {
                return(HttpNotFound());
            }
            return(View(leagueEntry));
        }
        // GET: LeagueEntries/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LeagueEntry leagueEntry = db.LeagueEntries.Find(id);

            if (leagueEntry == null)
            {
                return(HttpNotFound());
            }
            ViewBag.LeagueId = new SelectList(db.Leagues, "id", "LeagueName", leagueEntry.LeagueId);
            ViewBag.TeamId   = new SelectList(db.Teams, "id", "TeamName", leagueEntry.TeamId);
            return(View(leagueEntry));
        }
Esempio n. 10
0
        public void AddSummoner(string nickname, string server)
        {
            Summoner summoner = client.GetSummoner(nickname, server);

            if (summoner == null)
            {
                return;
            }
            foreach (LCGBSummoner sum in summoners)
            {
                if (sum.nickname == summoner.Name)
                {
                    MessageBox.Show("Player is already in pool.", "Warning");
                    return;
                }
            }
            string      iconurl = "https://opgg-static.akamaized.net/images/profile_icons/profileIcon" + summoner.ProfileIconId + ".jpg";
            LeagueEntry league  = client.GetLeaguePosition(summoner.Id, server);


            if (league != null)
            {
                string formattedRank = textInfo.ToTitleCase(league.Tier.ToLower()) + " " + league.Rank;
                int    points        = Balancer.RankToPoints(league.Tier + " " + Balancer.RomanToArabic(league.Rank)) + league.LeaguePoints;
                string rankurl       = Balancer.GetRankIcon(league.Tier + " " + Balancer.RomanToArabic(league.Rank));
                summoners.Add(new LCGBSummoner(summoner.Name, formattedRank, points, iconurl, rankurl));
                DisplaySummoners();
            }
            else
            {
                string lastRank = client.LastRank(summoner.AccountId, server);
                if (lastRank != null && lastRank != "UNRANKED")
                {
                    string formattedRank = "=*" + textInfo.ToTitleCase(lastRank.ToLower()) + "*=";
                    int    points        = Balancer.RankToPoints(lastRank + " 2");
                    string rankurl       = Balancer.GetRankIcon(lastRank + " 2");
                    summoners.Add(new LCGBSummoner(summoner.Name, formattedRank, points, iconurl, rankurl));
                    DisplaySummoners();
                }
                else
                {
                    string rankurl = "https://opgg-static.akamaized.net/images/medals/default.png";
                    summoners.Add(new LCGBSummoner(summoner.Name, "Unranked", 1050, iconurl, rankurl));
                    DisplaySummoners();
                }
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Gets player data.
        /// </summary>
        public static PlayerData GetPlayerData(LeagueEntry entry)
        {
            string filename = GetPlayerFilename(entry);

            if (!File.Exists(filename))
            {
                PlayerData data = new PlayerData(entry.PlayerOrTeamId);
                SetPlayerData(entry, data);
                return(data);
            }
            else
            {
                string     json = File.ReadAllText(filename);
                PlayerData data = JsonConvert.DeserializeObject <PlayerData>(json);
                return(data);
            }
        }
Esempio n. 12
0
        public async Task <List <LeagueEntry> > getLeagueTable(int leagueCode = 2016, int leagueTypeCode = 0)
        {
            using (HttpResponseMessage response = await client.GetAsync("https://api.football-data.org/v2/competitions/" + leagueCode + "/standings"))
            {
                if (response.IsSuccessStatusCode)
                {
                    try
                    {
                        JObject jsonObject = JObject.Parse(await response.Content.ReadAsStringAsync());
                        shortLeagueName = jsonObject["competition"]["name"].ToString();
                        longLeagueName  = jsonObject["competition"]["area"]["name"].ToString() + " - " + shortLeagueName;
                        JArray             standings     = (JArray)jsonObject["standings"];
                        List <LeagueEntry> leagueEntries = new List <LeagueEntry>();
                        for (int i = 0; i < standings[leagueTypeCode]["table"].Count(); i++)
                        {
                            Dictionary <int, string> teams = await teamDatabase.getTeamsFromDatabase(leagueCode, standings);

                            LeagueEntry entry = new LeagueEntry
                            {
                                name           = teams[int.Parse(standings[leagueTypeCode]["table"][i]["team"]["id"].ToString())],
                                position       = int.Parse(standings[leagueTypeCode]["table"][i]["position"].ToString()),
                                matchesPlayed  = int.Parse(standings[leagueTypeCode]["table"][i]["playedGames"].ToString()),
                                won            = int.Parse(standings[leagueTypeCode]["table"][i]["won"].ToString()),
                                drawn          = int.Parse(standings[leagueTypeCode]["table"][i]["draw"].ToString()),
                                lost           = int.Parse(standings[leagueTypeCode]["table"][i]["lost"].ToString()),
                                goalsFor       = int.Parse(standings[leagueTypeCode]["table"][i]["goalsFor"].ToString()),
                                goalsAgainst   = int.Parse(standings[leagueTypeCode]["table"][i]["goalsAgainst"].ToString()),
                                goalDifference = int.Parse(standings[leagueTypeCode]["table"][i]["goalDifference"].ToString()),
                                points         = int.Parse(standings[leagueTypeCode]["table"][i]["points"].ToString())
                            };
                            leagueEntries.Add(entry);
                        }
                        return(leagueEntries);
                    }
                    catch
                    {
                        throw new Exception("API LIMIT HIT, PLEASE WAIT TIL THE ALLOWANCE RESTORES(EVERY MINUTE)");
                    }
                }
                else
                {
                    throw new Exception(response.ReasonPhrase);
                }
            }
        }
Esempio n. 13
0
        public async void RetrieveLeagueTest()
        {
            List <string> summonerNames = new List <string>();

            summonerNames.Add("HentaiGoddess");
            List <Summoner> summoners = new List <Summoner>();

            summoners = await creepScore.RetrieveSummoners(CreepScore.Region.NA, summonerNames);

            Dictionary <string, List <League> > teamData = await summoners[0].RetrieveLeague();
            League participantLeague = teamData["35788975"].FirstOrDefault(t => t.participantId == "TEAM-fbe31d30-c08b-11e4-ad89-c81f66dd45c9");

            Assert.NotNull(participantLeague);

            Dictionary <string, List <League> > leagueData = await golf1052.RetrieveLeague();

            League      league   = null;
            LeagueEntry inSeries = null;

            foreach (KeyValuePair <string, List <League> > id in leagueData)
            {
                if (id.Key == "26040955")
                {
                    league = id.Value[0];
                    break;
                }
            }

            foreach (LeagueEntry entry in league.entries)
            {
                if (entry.miniSeries != null)
                {
                    inSeries = entry;
                    break;
                }
            }

            Assert.Equal("Karthus's Horde", league.name);
            Assert.Equal(26040955, long.Parse(league.participantId));
            Assert.Equal(GameConstants.Queue.Solo5, league.queue);
        }
Esempio n. 14
0
        private void queueTypeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (!justLoaded)
            {
                upDivisionButton.IsEnabled   = true;
                downDivisionButton.IsEnabled = true;
                League      league = leagueKey[queueTypeComboBox.SelectedIndex];
                LeagueEntry participantLeagueId = FindLeagueEntry(league, league.participantId);

                if (participantLeagueId == null)
                {
                    currentDivision = "I";
                }
                else
                {
                    currentDivision = participantLeagueId.division;
                }
                currentLeague = league;
                DisplayDisvison(league, currentDivision);
            }
        }
Esempio n. 15
0
        public string getQueueData(CurrentGame game, long summonerid)
        {
            Participant summoner = null;

            game.Participants.ForEach(user => {
                long userid = user.SummonerId;
                if (userid == summonerid)
                {
                    summoner = user;
                }
            });
            List <long> summonerList = new List <long>();

            summonerList.Add(unchecked ((int)summoner.SummonerId));
            try
            {
                Dictionary <long, List <RiotSharp.LeagueEndpoint.League> > dict = ApiFetcher.api.GetLeagues(Region.euw, summonerList);
                League league = dict.First().Value[0];

                Tier tier = league.Tier;

                String name = league.Tier.ToString();

                LeagueEntry entry = league.Entries[0];

                int    wins     = entry.Wins;
                int    losses   = entry.Losses;
                int    points   = entry.LeaguePoints;
                string division = entry.Division;
                return(FileWriter.WriteToFile(name, division, points, wins, losses));
            } catch (Exception e)
            {
                Console.WriteLine(e);
                return(FileWriter.WriteToFile("Placements"));
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            List <object> parameters = e.Parameter as List <object>;

            summoner = parameters[0] as Summoner;

            summonerNameTextBlock.Text      = summoner.name;
            summonerProfileIconImage.Source = AppConstants.SetImageSource(new Uri(AppConstants.SummonerProfileIconUrl() + summoner.profileIconId.ToString() + ".png"));

            if (summoner.summonerLevel == 30)
            {
                leagues = await summoner.RetrieveLeague();

                if (leagues != null)
                {
                    League      league = null;
                    LeagueEntry summonerLeagueEntry = null;

                    foreach (League l in leagues[summoner.id.ToString()])
                    {
                        if (l.queue == GameConstants.Queue.Solo5)
                        {
                            league = l;
                            ComboBoxItem temp = new ComboBoxItem();
                            temp.Content = "Solo";
                            queueTypeComboBox.Items.Add(temp);
                        }
                        else if (l.queue == GameConstants.Queue.Team5)
                        {
                            ComboBoxItem temp = new ComboBoxItem();
                            temp.Content = "5 v 5";
                            queueTypeComboBox.Items.Add(temp);
                        }
                        else if (l.queue == GameConstants.Queue.Team3)
                        {
                            ComboBoxItem temp = new ComboBoxItem();
                            temp.Content = "3 v 3";
                            queueTypeComboBox.Items.Add(temp);
                        }

                        leagueKey.Add(l);
                    }

                    if (queueTypeComboBox.Items.Count != 0)
                    {
                        queueTypeComboBox.SelectedIndex = 0;
                    }

                    if (league != null)
                    {
                        summonerLeagueEntry = FindLeagueEntry(league, summoner.id.ToString());
                        currentDivision     = summonerLeagueEntry.division;
                        currentLeague       = league;
                        DisplayDisvison(league, summonerLeagueEntry.division);
                    }
                }
                else
                {
                    rankedLeaguesHubSection.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                }
            }
            justLoaded = false;
        }
Esempio n. 17
0
 public static string PrintLeagueData(LeagueEntry entry)
 {
     return(PrettyQueue(entry.QueueType) + ": " + PrettyTier(entry.Tier) + " " + entry.Rank + ", " + entry.LeaguePoints + "LP \n" + ((float)entry.Wins / entry.Losses * 50f).ToString("0.00") + " % WR ");
 }
Esempio n. 18
0
 public PlayerEntry(LeagueEntry player, Region region)
 {
     Player = player;
     Region = region;
 }
Esempio n. 19
0
 int CompareWins(LeagueEntry x, LeagueEntry y)
 {
     return(y.wins - x.wins);
 }
Esempio n. 20
0
 private static string GetPlayerFilename(LeagueEntry entry)
 {
     // We store minimal information here, so no need to compress
     return(Path.Combine(PlayerRoot, entry.PlayerOrTeamId + ".json"));
 }
Esempio n. 21
0
 public PlayerEntry(LeagueEntry player, Region region)
 {
     Player = player;
     Region = region;
 }
Esempio n. 22
0
        public string getQueueData(CurrentGame game, long summonerid)
        {
            List <Participant> participants = game.Participants;
            long     teamId = participants.Find(x => x.SummonerId.Equals(summonerid)).TeamId;
            TeamInfo info;

            if (teamId == 100)
            {
                info = game.teamInfoOne;
            }
            else
            {
                info = game.teamInfoTwo;
            }

            if (info != null)
            {
                List <long> ids = new List <long>();
                ids.Add((long)summonerid);

                Dictionary <long, List <Team> > teams = ApiFetcher.api.GetTeams(Region.euw, ids);


                string rankedteamid = null;
                info.teamId.TryGetValue("fullId", out rankedteamid);
                GameQueueType type        = game.GameQueueType;
                List <Team>   teamlist    = teams.Values.First <List <Team> >();
                Team          currentTeam = teamlist.Find(team => team.FullId.Equals(rankedteamid));

                TeamStatDetail details = null;
                if (type == GameQueueType.RankedTeam5x5)
                {
                    details = currentTeam.TeamStatDetails.Find(queue => queue.TeamStatType.Equals("RANKED_TEAM_5x5"));
                }
                else
                {
                    details = currentTeam.TeamStatDetails.Find(queue => queue.TeamStatType.Equals("RANKED_TEAM_3x3"));
                }

                string name = currentTeam.Name;

                try
                {
                    List <string> teamids = new List <string>();
                    teamids.Add(currentTeam.FullId);
                    Dictionary <string, List <League> > leaguedict = ApiFetcher.api.GetLeagues(Region.euw, teamids);
                    List <League> leagues = leaguedict.Values.First <List <League> >();
                    League        league  = leagues.Find(l => l.Queue.ToString().Equals(type.ToString()));
                    LeagueEntry   entry   = league.Entries[0];

                    string tier     = league.Tier.ToString();
                    string division = entry.Division;
                    int    points   = entry.LeaguePoints;
                    int    wins     = entry.Wins;
                    int    losses   = entry.Losses;
                    return(FileWriter.WriteToFile(String.Format("{0}{1}{2} {3} ({4}LP) {5}/{6}", name, Environment.NewLine, tier, division, points, wins, losses)));
                } catch (RiotSharpException e)
                {
                    return(FileWriter.WriteToFile(String.Format("{0}{1}{2} ({3}/{4})", name, Environment.NewLine, "Placements", details.Wins, details.Losses)));
                }
            }
            else
            {
                return("meem");
            }
        }