//Looks at banned characters and manipulates them private void workOnBans(Dictionary<uint, Champion> champions, JToken bans, Games newGame) { if (bans != null) { foreach (var ban in bans) { uint ID = (uint)ban["championId"]; if (champions.ContainsKey(ID)) { champions[ID].banCount++; } else { Champion dchamp = new Champion(); dchamp.ID = ID; dchamp.banCount++; newGame.championsBanned.Add(dchamp); } } } }
//Parses through Match Json file for champion information private Dictionary<uint, Champion> parseThroughJsonFileForChampData(string s, Dictionary<uint, Champion> champions) { JObject Match = new JObject(); using (StreamReader textReader = System.IO.File.OpenText(s)) { using (JsonTextReader jsonReader = new JsonTextReader(textReader)) { Match = (JObject)JToken.ReadFrom(jsonReader); Games newGame = new Games(); newGame.championsBanned = new List<Champion>(); newGame.championsInGame = new List<Champion>(); newGame.MatchID = (uint)Match["matchId"]; if (Match.HasValues) { var parTemp = Match.GetValue("participants"); foreach (var item in parTemp) { uint ID = (uint)item["championId"]; if (champions.ContainsKey(ID)) { champions[ID] = updateChampion(champions, ID, item); } else { Champion newChamp = addNewChampion(ID, item); champions.Add(newChamp.ID, newChamp); } } var banChamps = Match.GetValue("teams"); foreach (var team in banChamps) { var bans = team["bans"]; workOnBans(champions, bans, newGame); } } } } return champions; }