public string getQueueData(CurrentGame game, long summonerid) { GameQueueType type = game.GameQueueType; FileWriter.WriteToFile(type.ToString()); return(type.ToString()); }
static void mgmtWtch_EventArrived(object sender, System.Management.EventArrivedEventArgs e) { PropertyData processName = e.NewEvent.Properties["ProcessName"]; string test = "nichts"; if (processName.Value.ToString() != null) { test = processName.Value.ToString(); } Console.WriteLine(test); if (test.Contains("League of Lege")) { if (e.NewEvent.ClassPath.ToString().Equals("Win32_ProcessStartTrace")) { Console.WriteLine("League of Legends launched"); ApiFetcher.getData(0, 3); } else { Console.WriteLine("League of Legends stopped"); FileWriter.WriteToFile("Not Ingame"); ApiFetcher.getData(); } } }
public static int getData() { eventtrigger.onStartedUpdate(); Properties.Settings.Default.Save(); RiotSharp.CurrentGameEndpoint.CurrentGame gameinfo; string retval = "error"; try { gameinfo = api.GetCurrentGame(Platform.EUW1, CURRENT_SUMMONER); GameQueueType qType = gameinfo.GameQueueType; if (isTeamRanked(qType)) { Console.WriteLine("Teamranked"); GameFetcher fetcher = new TeamRankedFetcher(); retval = fetcher.getQueueData(gameinfo, CURRENT_SUMMONER); } else if (isSoloQueue(qType)) { Console.WriteLine("SoloQueue"); GameFetcher fetcher = new SoloQueueFetcher(); retval = fetcher.getQueueData(gameinfo, CURRENT_SUMMONER); } else { Console.WriteLine("Normal or Custom"); GameFetcher fetcher = new NormalCustomFetcher(); retval = fetcher.getQueueData(gameinfo, CURRENT_SUMMONER); } eventtrigger.onFinishedUpdate(retval); return(0); } catch (RiotSharpException e) { Console.WriteLine(e); FileWriter.WriteToFile("Not Ingame"); eventtrigger.onFinishedUpdate("Not Ingame"); return(-1); } catch (JsonSerializationException e) { Console.WriteLine(e); eventtrigger.onFinishedUpdate("Unknown Gamemode"); FileWriter.WriteToFile("Unknown Gamemode"); return(-2); } }
public static void getData(int currenttry, int maxtries) { if (!(currenttry > maxtries)) { Console.WriteLine("Fetch Data from api (Try {0} from {1})", currenttry, maxtries); FileWriter.WriteToFile("Loading..."); if (getData() != 0) { Console.WriteLine("Error"); Thread.Sleep(5000); getData(++currenttry, maxtries); } } else { Console.WriteLine("Max tries used, abort"); } }
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")); } }
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"); } }