Esempio n. 1
0
        public void Initialise(AllPublicSummonerDataDTO publicSummoner, RegionType summonerRegion)
        {
            //Id cannot be set yet

            Region = summonerRegion;

            var summoner = publicSummoner.summoner;

            AccountId  = summoner.acctId;
            SummonerId = summoner.sumId;

            SummonerName = summoner.name;
            InternalName = summoner.internalName;

            SummonerLevel = publicSummoner.summonerLevel.summonerLevel;
            ProfileIcon   = summoner.profileIconId;

            HasBeenUpdated = false;

            UpdateAutomatically = false;

            int time = (int)Time.UnixTime();

            TimeCreated = time;
            TimeUpdated = time;
        }
Esempio n. 2
0
        void UpdateRunes(Summoner summoner, AllPublicSummonerDataDTO publicSummonerData, DbConnection connection)
        {
            //Remove old rune pages from the database first
            using (var delete = Command("delete from rune_page where summoner_id = :summoner_id", connection))
            {
                delete.Set("summoner_id", summoner.Id);
                delete.Execute();
            }

            foreach (var page in publicSummonerData.spellBook.bookPages)
            {
                string[] pageFields =
                {
                    "summoner_id",
                    "name",
                    "is_current_rune_page",
                    "time_created",
                };

                using (var insert = Command("insert into rune_page ({0}) values ({1})", connection, GetGroupString(pageFields), GetPlaceholderString(pageFields)))
                {
                    insert.SetFieldNames(pageFields);

                    insert.Set(summoner.Id);
                    insert.Set(page.name);
                    insert.Set(page.current);
                    insert.Set(page.createDate.ToUnixTime());

                    insert.Execute();
                }

                int runePageId = GetInsertId("rune_page", connection);

                string[] runeFields =
                {
                    "rune_page_id",
                    "rune_slot",
                    "rune",
                };

                foreach (var rune in page.slotEntries)
                {
                    using (var insert = Command("insert into rune_slot ({0}) values ({1})", connection, GetGroupString(runeFields), GetPlaceholderString(runeFields)))
                    {
                        insert.SetFieldNames(runeFields);

                        insert.Set(runePageId);
                        insert.Set(rune.runeSlotId);
                        insert.Set(rune.runeId);

                        insert.Execute();
                    }
                }
            }
        }
Esempio n. 3
0
        public async Task <AllPublicSummonerDataDTO> GetAllPublicSummonerDataByAccount(Double accountId)
        {
            int Id = Invoke("summonerService", "getAllPublicSummonerDataByAccount", new object[] { accountId });

            while (!results.ContainsKey(Id))
            {
                await Task.Delay(10);
            }
            TypedObject messageBody         = results[Id].GetTO("data").GetTO("body");
            AllPublicSummonerDataDTO result = new AllPublicSummonerDataDTO(messageBody);

            results.Remove(Id);
            return(result);
        }
Esempio n. 4
0
        void RunePages(List <string> arguments)
        {
            string         summonerName = GetSummonerName(arguments[0]);
            PublicSummoner summoner     = RPC.GetSummonerByName(summonerName);

            if (summoner == null)
            {
                NoSuchSummoner();
                return;
            }

            AllPublicSummonerDataDTO allSummonerData = RPC.GetAllPublicSummonerDataByAccount(summoner.acctId);

            if (allSummonerData == null)
            {
                Console.WriteLine("Unable to retrieve all public summoner data");
                return;
            }

            if (allSummonerData.spellBook == null)
            {
                Console.WriteLine("Spell book not available");
                return;
            }

            if (allSummonerData.spellBook.bookPages == null)
            {
                Console.WriteLine("Spell book pages not available");
                return;
            }

            foreach (var page in allSummonerData.spellBook.bookPages)
            {
                Console.WriteLine("[{0}] {1} ({2})", page.createDate, page.name, page.current ? "active" : "not active");
                foreach (var slot in page.slotEntries)
                {
                    Console.WriteLine("Slot {0}: {1}", slot.runeSlotId, slot.runeId);
                }
            }
        }
Esempio n. 5
0
        void UpdateSummoner(Summoner summoner, AllPublicSummonerDataDTO publicSummonerData, AggregatedStats[] aggregatedStats, PlayerLifeTimeStats lifeTimeStatistics, RecentGames recentGames, DbConnection connection)
        {
            int accountId = summoner.AccountId;

            lock (ActiveAccountIds)
            {
                // Avoid concurrent updates of the same account, it's asking for trouble and is redundant anyways
                // We might obtain outdated results in one query but that's a minor issue in comparison to corrupted database results
                if (ActiveAccountIds.Contains(accountId))
                {
                    return;
                }

                ActiveAccountIds.Add(accountId);
            }

            // Use a transaction because we're going to insert a fair amount of data
            using (var transaction = connection.BeginTransaction())
            {
                UpdateSummonerFields(summoner, connection, true);
                UpdateRunes(summoner, publicSummonerData, connection);

                UpdateSummonerRatings(summoner, lifeTimeStatistics, connection);
                // A season value of zero indicates the current season only
                for (int season = 0; season < aggregatedStats.Length; season++)
                {
                    UpdateSummonerRankedStatistics(summoner, season, aggregatedStats[season], connection);
                }
                UpdateSummonerGames(summoner, recentGames, connection);

                transaction.Commit();
            }

            lock (ActiveAccountIds)
                ActiveAccountIds.Remove(accountId);
        }
Esempio n. 6
0
 public Summoner(AllPublicSummonerDataDTO publicSummoner, RegionType summonerRegion)
 {
     Initialise(publicSummoner, summonerRegion);
 }
Esempio n. 7
0
        public void Initialise(AllPublicSummonerDataDTO publicSummoner, RegionType summonerRegion)
        {
            //Id cannot be set yet

            Region = summonerRegion;

            var summoner = publicSummoner.summoner;

            AccountId = summoner.acctId;
            SummonerId = summoner.sumId;

            SummonerName = summoner.name;
            InternalName = summoner.internalName;

            SummonerLevel = publicSummoner.summonerLevel.summonerLevel;
            ProfileIcon = summoner.profileIconId;

            HasBeenUpdated = false;

            UpdateAutomatically = false;

            int time = (int)Time.UnixTime();

            TimeCreated = time;
            TimeUpdated = time;

            RevisionDate = 0;
            LastUpdateTrial = 0;
        }
Esempio n. 8
0
 void GetPublicSummonerData(AllPublicSummonerDataDTO publicSummonerData)
 {
     PublicSummonerData = publicSummonerData;
     ProcessReply();
 }
Esempio n. 9
0
 public SummonerDetails(AllPublicSummonerDataDTO all) : base(all.Summoner)
 {
     Level = all.SummonerLevel.Level;
 }
Esempio n. 10
0
        /// 34.)
        public void GetAllPublicSummonerDataByAccount(Double accountId, AllPublicSummonerDataDTO.Callback callback)
        {
            AllPublicSummonerDataDTO cb = new AllPublicSummonerDataDTO(callback);

            InvokeWithCallback("summonerService", "getAllPublicSummonerDataByAccount", new object[] { accountId }, cb);
        }
Esempio n. 11
0
 public Summoner(AllPublicSummonerDataDTO publicSummoner, RegionType summonerRegion)
 {
     Initialise(publicSummoner, summonerRegion);
 }
Esempio n. 12
0
        public async void InitializePop(GameDTO InitialDTO)
        {
            List <Participant> AllParticipants = InitialDTO.TeamOne;

            AllParticipants.AddRange(InitialDTO.TeamTwo);
            if (InitialDTO.TeamOne[0] is ObfuscatedParticipant)
            {
                ReverseString = true;
            }

            foreach (Participant p in AllParticipants)
            {
                QueuePopPlayer player = new QueuePopPlayer();
                player.Width  = 300;
                player.Height = 100;
                if (p is PlayerParticipant)
                {
                    PlayerParticipant playerPart = (PlayerParticipant)p;
                    if (!String.IsNullOrEmpty(playerPart.SummonerName))
                    {
                        player.PlayerLabel.Content = playerPart.SummonerName;
                        player.RankLabel.Content   = "";
                        Team1ListBox.Items.Add(player);
                    }
                    else
                    {
                        AllPublicSummonerDataDTO Summoner = await Client.PVPNet.GetAllPublicSummonerDataByAccount(playerPart.SummonerId);

                        player.PlayerLabel.Content = Summoner.Summoner.Name;
                        player.RankLabel.Content   = "";
                        Team2ListBox.Items.Add(player);
                    }
                }
                else
                {
                    player.PlayerLabel.Content = "Enemy";
                    player.RankLabel.Content   = "";
                    Team2ListBox.Items.Add(player);
                }
            }

            int i = 0;

            foreach (Participant p in AllParticipants)
            {
                try
                {
                    if (p is PlayerParticipant)
                    {
                        QueuePopPlayer     player        = (QueuePopPlayer)Team1ListBox.Items[i];
                        PlayerParticipant  playerPart    = (PlayerParticipant)p;
                        SummonerLeaguesDTO playerLeagues = await Client.PVPNet.GetAllLeaguesForPlayer(playerPart.SummonerId);

                        foreach (LeagueListDTO x in playerLeagues.SummonerLeagues)
                        {
                            if (x.Queue == "RANKED_SOLO_5x5")
                            {
                                player.RankLabel.Content = x.Tier + " " + x.RequestorsRank;
                            }
                        }
                        //People can be ranked without having solo queue so don't put if statement checking List.Length
                        if (String.IsNullOrEmpty((string)player.RankLabel.Content))
                        {
                            player.RankLabel.Content = "Unranked";
                        }
                        i++;
                    }
                }
                catch
                {
                }
            }

            if (Client.AutoAcceptQueue)
            {
                await Client.PVPNet.AcceptPoppedGame(true);
            }
        }
Esempio n. 13
0
        private void updateSummoner(PublicSummoner pSumm, PlayerLifeTimeStats summStats, AggregatedStats aggStats, AllPublicSummonerDataDTO summPages, MasteryBook masteries)
        {
            PlayerStatSummary rSolo5x5;
            PlayerStatSummary rTeam5x5;
            PlayerStatSummary normal5x5;
            List<ChampionStatistics> champStats = ChampionStatistics.GetChampionStatistics(aggStats);

            db.updateSummoner("summonerLevel", pSumm.summonerLevel.ToString(), pSumm.summonerId);
            db.updateSummoner("profileIconId", pSumm.profileIconId.ToString(), pSumm.summonerId);

            if ((rSolo5x5 = summStats.getRankedSolo5x5()) != null)
            {
                db.updateSummoner("solo5x5_elo", rSolo5x5.rating.ToString(), pSumm.summonerId);
                db.updateSummoner("solo5x5_wins", rSolo5x5.wins.ToString(), pSumm.summonerId);
                db.updateSummoner("solo5x5_losses", rSolo5x5.losses.ToString(), pSumm.summonerId);
                db.updateSummoner("solo5x5_maxElo", rSolo5x5.maxRating.ToString(), pSumm.summonerId);
            }

            if ((rTeam5x5 = summStats.getRankedTeam5x5()) != null)
            {
                db.updateSummoner("team5x5_elo", rTeam5x5.rating.ToString(), pSumm.summonerId);
                db.updateSummoner("team5x5_wins", rTeam5x5.wins.ToString(), pSumm.summonerId);
                db.updateSummoner("team5x5_losses", rTeam5x5.losses.ToString(), pSumm.summonerId);
                db.updateSummoner("team5x5_maxElo", rTeam5x5.maxRating.ToString(), pSumm.summonerId);
            }

            if ((normal5x5 = summStats.getNormal5x5()) != null)
            {
                db.updateSummoner("normal5x5_elo", normal5x5.rating.ToString(), pSumm.summonerId);
                db.updateSummoner("normal5x5_wins", normal5x5.wins.ToString(), pSumm.summonerId);
                db.updateSummoner("normal5x5_losses", normal5x5.losses.ToString(), pSumm.summonerId);
                db.updateSummoner("normal5x5_maxElo", normal5x5.maxRating.ToString(), pSumm.summonerId);
            }

            db.updateSummoner("ranked_kills", ChampionStatistics.totalRankedKills(champStats).ToString(), pSumm.summonerId);
            db.updateSummoner("ranked_assists", ChampionStatistics.totalRankedAssists(champStats).ToString(), pSumm.summonerId);
            db.updateSummoner("ranked_deaths", ChampionStatistics.totalRankedDeaths(champStats).ToString(), pSumm.summonerId);
            db.updateSummoner("ranked_pentaKills", ChampionStatistics.totalRankedPentaKills(champStats).ToString(), pSumm.summonerId);
            db.updateSummoner("ranked_quadraKills", ChampionStatistics.totalRankedQuadraKills(champStats).ToString(), pSumm.summonerId);
            db.updateSummoner("ranked_tripleKills", ChampionStatistics.totalRankedTripleKills(champStats).ToString(), pSumm.summonerId);
            db.updateSummoner("ranked_doubleKills", ChampionStatistics.totalRankedDoubleKills(champStats).ToString(), pSumm.summonerId);
            db.updateSummoner("ranked_minionKills", ChampionStatistics.totalRankedMinionKills(champStats).ToString(), pSumm.summonerId);
            db.updateSummoner("ranked_goldEarned", ChampionStatistics.totalRankedGoldEarned(champStats).ToString(), pSumm.summonerId);
            db.updateSummoner("ranked_turretsDestroyed", ChampionStatistics.totalRankedTurretsDestroyed(champStats).ToString(), pSumm.summonerId);
            db.updateSummoner("ranked_mostKills", ChampionStatistics.rankedMostKills(champStats).ToString(), pSumm.summonerId);
            db.updateSummoner("ranked_mostDeaths", ChampionStatistics.rankedMostDeaths(champStats).ToString(), pSumm.summonerId);

            /** Update Runes and Masteries */
        }