Exemple #1
0
        public string ChampionStatsData(string summonerName)
        {
            List <ChampionStatisticsRow> champStats = new List <ChampionStatisticsRow>();

            using (LoLGTContext context = new LoLGTContext())
            {
                var statsRanking = context.StatsRanking.Where(x => x.SummonerName == summonerName).FirstOrDefault();
                if (statsRanking == null)
                {
                    return("#08");
                }
                foreach (var champion in statsRanking.Champions)
                {
                    ChampionStatisticsRow newChampionDTO = new ChampionStatisticsRow();
                    var kills   = champion.Stats.TotalChampionKills;
                    var deaths  = champion.Stats.TotalDeathsPerSession;
                    var assists = champion.Stats.TotalAssists;
                    newChampionDTO.ChampionName = champion.ChampionName;
                    newChampionDTO.Wins         = champion.Stats.TotalSessionsWon;
                    newChampionDTO.Loses        = champion.Stats.TotalSessionsLost;
                    newChampionDTO.KDA          = deaths == 0 ? kills + assists : (kills + assists) / deaths;
                    double totalGamePlayed = champion.Stats.TotalSessionsWon + champion.Stats.TotalSessionsLost;
                    newChampionDTO.WinRatePercentage = (((double)champion.Stats.TotalSessionsWon / totalGamePlayed) * 100).ToString();
                    newChampionDTO.MinionKills       = champion.Stats.TotalMinionKills;
                    champStats.Add(newChampionDTO);
                }
            };
            return("#05" + JsonConvert.SerializeObject(champStats));
        }
Exemple #2
0
        public string MatchHistoryData(string summonerName)
        {
            List <MatchHistoryRow> matchHistoryList = new List <MatchHistoryRow>();

            using (LoLGTContext context = new LoLGTContext())
            {
                var summonerGames = context.SummonerGames.Where(x => x.SummonerName == summonerName).FirstOrDefault();
                if (summonerGames == null)
                {
                    return("#09");
                }
                foreach (var game in summonerGames.Games)
                {
                    MatchHistoryRow matchHistoryDTO = new MatchHistoryRow();
                    matchHistoryDTO.ChampionName = game.ChampionName;
                    matchHistoryDTO.Outcome      = game.Gamestatistics.Win == true ? "Win" : "Loss";
                    matchHistoryDTO.Kills        = game.Gamestatistics.ChampionsKilled;
                    matchHistoryDTO.Deaths       = game.Gamestatistics.numDeaths;
                    matchHistoryDTO.Assists      = game.Gamestatistics.Assists;
                    matchHistoryList.Add(matchHistoryDTO);
                }
            }
            return("#07" + JsonConvert.SerializeObject(matchHistoryList));
        }
Exemple #3
0
        public static void LaunchDB()
        {
            var context = new LoLGTContext();

            context.Database.Initialize(true);
        }
Exemple #4
0
        static void Main(string[] args)
        {
            // INit DB
            //    Utility.LaunchDB();

            LoLClient lol = new LoLClient();

            lol.GetSummonerIdByName("Hades Underworld");
            //lol.GetSummonerMatchesById();
            lol.GetSummonerRankingById();
            lol.GetSummonerGamesById();

            LoLGTContext context = new LoLGTContext();

            //   context.
            //context.Matches.Add(lol.Matches);
            context.StatsRanking.Add(lol.Ranking);
            context.SummonerGames.Add(lol.SummonerGames);
            context.SaveChanges();
            DateTime timeAtSendToClients = new DateTime();
            DateTime timeNow             = new DateTime();
            // ↓ Connect to ipaddress:4649/SendData
            WebSocketServer wssv = new WebSocketServer(System.Net.IPAddress.Any, 4649);

#if DEBUG
            wssv.Log.Level = LogLevel.Trace;
#endif
            wssv.KeepClean    = true;
            wssv.WaitTime     = TimeSpan.FromSeconds(120);
            wssv.ReuseAddress = false;
            // ↓ Implement Server activies in SendData.cs
            wssv.AddWebSocketService <SendData>("/SendData");

            //     LoLClient lol = new LoLClient();

            Console.WriteLine();

            wssv.Start();
            timeAtSendToClients = DateTime.Now;

            string input = "";
            while (input != "stop")
            {
                //timeNow = DateTime.Now;
                //if (timeNow == timeAtSendToClients+TimeSpan.FromMinutes(5))
                //{
                //    // ↓ Tony add the data to send to the clients in SendData
                //    string dataToBroadcast = "";
                //    wssv.WebSocketServices["/SendData"].Sessions.Broadcast(dataToBroadcast);
                //}
                //if (input.Take(5).ToString().ToLower() == "send ")
                //{
                //    string dataToBroadcast = input.Skip(5).ToString();
                //    wssv.WebSocketServices["/SendData"].Sessions.Broadcast(dataToBroadcast);
                //}

                input = "";
                try
                {
                    input = ReaderForLoops.ReadLine(150000);
                }
                catch (TimeoutException)
                {
                    //Console.WriteLine("Next loop init");
                }
            }
            wssv.Stop();
        }