// Pull live stats of the user. public static async void GetSummoner() { using (var client = new HttpClient()) { HttpResponseMessage response = await client.GetAsync(GetSummonerURL()); string responseBody = await response.Content.ReadAsStringAsync(); System.Diagnostics.Debug.WriteLine(responseBody); string statusCode = response.StatusCode.ToString(); if (statusCode == "NotFound") { SynthesisHandler.Synthesise("That Summoner does not exist, try again."); } else { js = new JavaScriptSerializer(); summoner = js.Deserialize <Summoner>(responseBody); SynthesisHandler.Synthesise("Welcome " + summoner.name + "to Rift Buddy. Say on while in game to get some help."); } } }
private void buttonUpdate_Click(object sender, EventArgs e) { if (textBoxSummonerName.Text.Length != 0) { if (comboBoxServer.SelectedIndex > -1) { APIHandler.Username = textBoxSummonerName.Text; APIHandler.Server = comboBoxServer.SelectedItem.ToString(); APIHandler.GetSummoner(); } else { SynthesisHandler.Synthesise("You must select your server."); } } else { SynthesisHandler.Synthesise("You must enter your summoner name."); } }
// Pull live game stats of the user. public static async void GetCurrentGame() { using (var client = new HttpClient()) { HttpResponseMessage response = await client.GetAsync(GetCurrentGameURL()); string responseBody = await response.Content.ReadAsStringAsync(); System.Diagnostics.Debug.WriteLine(responseBody); string statusCode = response.StatusCode.ToString(); if (statusCode == "NotFound") { SynthesisHandler.Synthesise("You are not currently in a game. Say on while in game to get some help."); } else { SynthesisHandler.Synthesise("You are in a live game! One second please, pulling data..."); js = new JavaScriptSerializer(); liveGame = js.Deserialize <LiveGame>(responseBody); long champId = -1; foreach (LiveGame.CurrentGameParticipant participant in liveGame.participants) { if (participant.summonerId == summoner.id) { champId = participant.championId; } } GetChampionData(champId); } } }
// Synthesise advice for the enemy champions. public static void GetChampAdviceEnemy() { SynthesisHandler.Synthesise(champDataEnemyTips[rnd.Next(0, champDataEnemyTips.Count + 1)]); }
// Synthesise advice for the user's champion. public static void GetChampAdviceSelf() { SynthesisHandler.Synthesise(champDataSelf.allytips[rnd.Next(0, champDataSelf.allytips.Count + 1)]); }
// Pull static champion data. public static async void GetChampionData(long champId) { using (var client = new HttpClient()) { HttpResponseMessage response = await client.GetAsync(GetChampionDataURL(champId)); string responseBody = await response.Content.ReadAsStringAsync(); System.Diagnostics.Debug.WriteLine(responseBody); string statusCode = response.StatusCode.ToString(); js = new JavaScriptSerializer(); champDataSelf = js.Deserialize <ChampDataSelf>(responseBody); } long teamId = -1; foreach (LiveGame.CurrentGameParticipant participant in liveGame.participants) { if (participant.summonerId == summoner.id) { teamId = participant.teamID; } } foreach (LiveGame.CurrentGameParticipant participant in liveGame.participants) { if (participant.teamID != teamId) { using (var client = new HttpClient()) { HttpResponseMessage response = await client.GetAsync(GetChampionDataURL(participant.championId)); string responseBody = await response.Content.ReadAsStringAsync(); System.Diagnostics.Debug.WriteLine(responseBody); string statusCode = response.StatusCode.ToString(); js = new JavaScriptSerializer(); champDataEnemy = js.Deserialize <ChampDataEnemy>(responseBody); } foreach (string tip in champDataEnemy.enemytips) { champDataEnemyTips.Add(tip); } } } using (var client = new HttpClient()) { HttpResponseMessage response = await client.GetAsync(GetChampionDataURL(champId)); string responseBody = await response.Content.ReadAsStringAsync(); System.Diagnostics.Debug.WriteLine(responseBody); string statusCode = response.StatusCode.ToString(); js = new JavaScriptSerializer(); champDataSelf = js.Deserialize <ChampDataSelf>(responseBody); SynthesisHandler.Synthesise("You are playing " + champDataSelf.name + ", " + champDataSelf.title); SynthesisHandler.Synthesise("Say go whenever you would like some advice, or off to disable Rift Buddy until you say on again."); CommandHandler.helpState = 1; } }