//Updates a champion from the Champions Dictionary private Champion updateChampion(Dictionary<uint, Champion> champions, uint ID, JToken item) { for (int i = 0, max = 6; i < max; i++) { Items Item = new Items(); Item.ID = (uint)item["stats"]["item" + i]; if (champions[ID].itemStats.ContainsKey(Item.ID)) { champions[ID].itemStats[Item.ID].numberOfTimesUsed++; } else { Item.numberOfTimesUsed++; champions[ID].itemStats.Add(Item.ID, Item); } } champions[ID].totalDeaths += (uint)item["stats"]["deaths"]; champions[ID].totalKills += (uint)item["stats"]["kills"]; champions[ID].gameCount++; switch ((string)item["timeline"]["lane"]) { case "TOP": { if (champions[ID].lanePrefCount.ContainsKey(Champion.Lanes.TOP)) { champions[ID].lanePrefCount[Champion.Lanes.TOP]++; } else { champions[ID].lanePrefCount.Add(Champion.Lanes.TOP, 0); } } break; case "JUNGLE": { if (champions[ID].lanePrefCount.ContainsKey(Champion.Lanes.JUNGLE)) { champions[ID].lanePrefCount[Champion.Lanes.JUNGLE]++; } else { champions[ID].lanePrefCount.Add(Champion.Lanes.JUNGLE, 0); } } break; case "BOTTOM": { if (champions[ID].lanePrefCount.ContainsKey(Champion.Lanes.BOTTOM)) { champions[ID].lanePrefCount[Champion.Lanes.BOTTOM]++; } else { champions[ID].lanePrefCount.Add(Champion.Lanes.BOTTOM, 0); } } break; case "MIDDLE": { if (champions[ID].lanePrefCount.ContainsKey(Champion.Lanes.MIDDLE)) { champions[ID].lanePrefCount[Champion.Lanes.MIDDLE]++; } else { champions[ID].lanePrefCount.Add(Champion.Lanes.MIDDLE, 0); } } break; } return champions[ID]; }
//Adds new champion to the Champions dictionary private Champion addNewChampion(uint ID, JToken item) { Champion Champ = new Champion(); Champ.itemStats = new Dictionary<uint, Items>(); Champ.ID = ID; Champ.totalDeaths += (uint)item["stats"]["deaths"]; Champ.totalKills += (uint)item["stats"]["kills"]; Champ.lanePrefCount = new Dictionary<Champion.Lanes, int>(); for (int i = 0, max = 6; i < max; i++) { Items Item = new Items(); Item.ID = (uint)item["stats"]["item" + i]; if (Champ.itemStats.ContainsKey(Item.ID)) { Champ.itemStats[Item.ID].numberOfTimesUsed++; } else { Item.numberOfTimesUsed++; Champ.itemStats.Add(Item.ID, Item); } } switch ((string)item["timeline"]["lane"]) { case "TOP": { Champ.lanePrefCount.Add(Champion.Lanes.TOP, 0); } break; case "JUNGLE": { Champ.lanePrefCount.Add(Champion.Lanes.JUNGLE, 0); } break; case "BOTTOM": { Champ.lanePrefCount.Add(Champion.Lanes.BOTTOM, 0); } break; case "MIDDLE": { Champ.lanePrefCount.Add(Champion.Lanes.MIDDLE, 0); } break; } Champ.gameCount++; return Champ; }