/// <summary> /// Initializes a new instance of the <see cref="RiotClient"/> class. /// </summary> /// <param name="apiKey">The API key.</param> public RiotClient(string apiKey) { IChampion champion = new Champion(apiKey); ICurrentGame currentGame = new CurrentGame(apiKey); IFeaturedGames featuredGames = new FeaturedGames(apiKey); IGame game = new Game(apiKey); ILeague league = new League(apiKey); ILolStaticData lolStaticData = new LolStaticData(apiKey); ILolStatus lolStatus = new LolStatus(); IMatch match = new Match(apiKey); IMatchList matchList = new MatchList(apiKey); IStats stats = new Stats(apiKey); ISummoner summoner = new Summoner(apiKey); ITeam team = new Team(apiKey); IChampionMastery championMastery = new ChampionMastery(apiKey); this.Champion = champion; this.CurrentGame = currentGame; this.FeaturedGames = featuredGames; this.Game = game; this.League = league; this.LolStaticData = lolStaticData; this.LolStatus = lolStatus; this.Match = match; this.MatchList = matchList; this.Stats = stats; this.Summoner = summoner; this.Team = team; this.ChampionMastery = championMastery; }
public void GetChampionMastery() { ApiService.ApiKey = APIKEY;//you must add your project, if you dont use ninject NonStaticApi api = new NonStaticApi(new Api.Cache.ApiCache()); ChampionMastery data = api.GetChampionMastery(summonerId1, championId1, Region); Assert.IsNotNull(data); }
private void GotChampionMasteryPoints(ChampionMastery item) { int gainedChampionMasteryPoints = item.championPointsUntilNextLevelAfterGame - item.championPointsUntilNextLevelBeforeGame; TotalChampionXP.Content = (item.championPointsBeforeGame + gainedChampionMasteryPoints).ToString() + "Total CP"; GainedChampionXP.Content = "+" + gainedChampionMasteryPoints + " CP"; NextLvlChampionXP.Content = item.championPointsUntilNextLevelAfterGame.ToString() + " to Next Lvl"; ChampionMasteryGrid.Visibility = Visibility.Visible; }
/// <summary> /// /// </summary> /// <param name="summoner"></param> /// <returns></returns> public static Dictionary <String, Object> ChampionMasteryToDictionary(ChampionMastery championMastery) { if (championMastery == null) { throw new ArgumentException("parameter player is required."); } Dictionary <String, Object> propToValueMap = new Dictionary <String, Object>(); return(propToValueMap); }
void DisplayMatch() { //clears the notes MatchupNotes.Text = ""; for (int i = 0; i < 5; i++) { ChampionMastery mastery = championMastery[i]; Champion champion = (Champion)mastery.ChampionId; MatchupNotes.Text = string.Concat(MatchupNotes.Text, (i + 1) + ")", champion.Name(), $": {mastery.ChampionPoints} \n"); string champShell = champion.Name().Replace(" ", string.Empty); champShell = champShell.Replace("'", string.Empty); Team1ChampIcons[i].Source = new BitmapImage(new Uri(@"/Images/champion/" + champShell + ".png", UriKind.Relative)); } ChangeProfileIcon(searchedSummoner.ProfileIconId); }
public static ChampionMastery fromJSON(object rawResponse) { if (rawResponse is String) { String json = (String)rawResponse; JsonFx.Json.JsonReader reader = JSONUtils.getJsonReader(json); ChampionMastery championMastery = new ChampionMastery(); championMastery = reader.Deserialize <ChampionMastery>(); return(championMastery); } return(new ChampionMastery()); }
/// <summary> /// /// </summary> /// <param name="propToValueMap"></param> /// <returns></returns> public static ChampionMasteryList DictionaryToChampionMasteryList(Dictionary <String, Object> propToValueMap) { ChampionMasteryList championMasteryList = new ChampionMasteryList(); #region ChampionId Property if (propToValueMap.ContainsKey(ChampionMasteryList.PropertyNames.Masteries) && propToValueMap[ChampionMasteryList.PropertyNames.Masteries] is Dictionary <String, Object> ) { Dictionary <String, Object> championMasteryPropValueMap = (Dictionary <String, Object>)propToValueMap[ChampionDB.PropertyNames.Data]; foreach (KeyValuePair <String, Object> championMasteryDict in championMasteryPropValueMap) { ChampionMastery championMastery = ChampionMasteryConverter.DictionaryToChampionMastery(championMasteryDict.Value as Dictionary <String, Object>); //championMasteryList.Data.Add(championMastery); } } #endregion return(championMasteryList); }
public ChampionMastery ChampionMastery(string summonerId, string championId) { string request = requestStringHolder.ChampionMastery.ChampionMasteriesBySummonerByChampion(summonerId, championId); string json = null; ChampionMastery result = null; try { json = requester.Fetch(request); if (json == EXCEEDED_LIMIT) { onRateLimitExceeded(); return(ChampionMastery(summonerId, championId)); } result = RiotDtoFromJson.GetChampionMastery(json); } catch { Console.WriteLine("Something went wrong in ChampionMastery({summonerId}, {championId}) : returning null"); return(null); } return(result); }
public static void CheckGetChampion(ChampionMastery result) { Assert.IsNotNull(result); Assert.AreEqual(7, result.ChampionLevel, result.ChampionLevel.ToString()); Assert.IsTrue(result.ChampionPoints >= 389_578, result.ChampionPoints.ToString()); }
/// <summary> /// /// </summary> /// <param name="propToValueMap"></param> /// <returns></returns> public static ChampionMastery DictionaryToChampionMastery(Dictionary <String, Object> propToValueMap) { ChampionMastery championMastery = new ChampionMastery(); #region ChampionId Property if (propToValueMap[ChampionMastery.PropertyNames.ChampionId] is long) { championMastery.ChampionId = (long)propToValueMap[ChampionMastery.PropertyNames.ChampionId]; } else if (propToValueMap[ChampionMastery.PropertyNames.ChampionId] is int) { championMastery.ChampionId = (int)propToValueMap[ChampionMastery.PropertyNames.ChampionId]; } #endregion #region ChampionLevel Property if (propToValueMap[ChampionMastery.PropertyNames.ChampionLevel] is int) { championMastery.ChampionLevel = (int)propToValueMap[ChampionMastery.PropertyNames.ChampionLevel]; } #endregion #region ChampionPoints Property if (propToValueMap[ChampionMastery.PropertyNames.ChampionPoints] is int) { championMastery.ChampionPoints = (int)propToValueMap[ChampionMastery.PropertyNames.ChampionPoints]; } #endregion #region ChampionPointsSinceLastLevel Property if (propToValueMap[ChampionMastery.PropertyNames.ChampionPointsSinceLastLevel] is long) { championMastery.ChampionPointsSinceLastLevel = (long)propToValueMap[ChampionMastery.PropertyNames.ChampionPointsSinceLastLevel]; } else if (propToValueMap[ChampionMastery.PropertyNames.ChampionPointsSinceLastLevel] is int) { championMastery.ChampionPointsSinceLastLevel = (int)propToValueMap[ChampionMastery.PropertyNames.ChampionPointsSinceLastLevel]; } #endregion #region ChampionPointsUntilNextLevel Property if (propToValueMap[ChampionMastery.PropertyNames.ChampionPointsUntilNextLevel] is long) { championMastery.ChampionPointsUntilNextLevel = (long)propToValueMap[ChampionMastery.PropertyNames.ChampionPointsUntilNextLevel]; } else if (propToValueMap[ChampionMastery.PropertyNames.ChampionPointsUntilNextLevel] is int) { championMastery.ChampionPointsUntilNextLevel = (int)propToValueMap[ChampionMastery.PropertyNames.ChampionPointsUntilNextLevel]; } #endregion #region ChestGranted Property if (propToValueMap[ChampionMastery.PropertyNames.ChestGranted] is bool) { championMastery.ChestGranted = (bool)propToValueMap[ChampionMastery.PropertyNames.ChestGranted]; } #endregion #region HighestGrade Property if (propToValueMap.ContainsKey(ChampionMastery.PropertyNames.HighestGrade) && propToValueMap[ChampionMastery.PropertyNames.HighestGrade] is string) { championMastery.HighestGrade = (string)propToValueMap[ChampionMastery.PropertyNames.HighestGrade]; } #endregion #region LastPlayTime Property if (propToValueMap[ChampionMastery.PropertyNames.LastPlayTime] is long) { championMastery.LastPlayTime = (long)propToValueMap[ChampionMastery.PropertyNames.LastPlayTime]; } else if (propToValueMap[ChampionMastery.PropertyNames.LastPlayTime] is int) { championMastery.LastPlayTime = (int)propToValueMap[ChampionMastery.PropertyNames.LastPlayTime]; } #endregion #region PlayerId Property if (propToValueMap[ChampionMastery.PropertyNames.PlayerId] is long) { championMastery.PlayerId = (long)propToValueMap[ChampionMastery.PropertyNames.PlayerId]; } else if (propToValueMap[ChampionMastery.PropertyNames.PlayerId] is int) { championMastery.PlayerId = (int)propToValueMap[ChampionMastery.PropertyNames.PlayerId]; } #endregion return(championMastery); }
/// <summary> /// Converts a Summoner into a dictionary /// </summary> /// <param name="type">Optional - the type of the value parameter</param> /// <param name="value">Optional - the instance that is to be converted into a dictionary</param> /// <returns>A Dictionary containing the data contained in the value parameter</returns> public override Dictionary <String, Object> WriteJson(Type type, Object value) { ChampionMastery championMastery = (ChampionMastery)value; return(ChampionMasteryToDictionary(championMastery)); }