public ChampMastery(ChampionDto champ, int rank) { InitializeComponent(); ChampImage.Source = DataDragon.GetChampIconImage(champ).Load(); RankImage.Source = new BitmapImage(new Uri($"pack://application:,,,/RiotAPI;component/Resources/ChampMastery{rank + 1}.png")); }
private void AppendStatisticData(ChampionDto champion, FormattedEmbedBuilder message) { StatsDto stats = champion.Stats; int decimals = 3; NumberAlign statList = new NumberAlign(decimals, stats.GetStats()); NumberAlign statGrowthList = new NumberAlign(decimals, stats.GetStatGrowthList()); string statData = $"Health - {statList.Align(stats.Hp)} | + {statGrowthList.TrimmedAlign(stats.HpPerLevel)}" + Environment.NewLine + $"Health Regen. - {statList.Align(stats.HpRegen)} | + {statGrowthList.TrimmedAlign(stats.HpRegenPerLevel)}" + Environment.NewLine + $"Mana - {statList.Align(stats.Mp)} | + {statGrowthList.TrimmedAlign(stats.MpPerLevel)}" + Environment.NewLine + $"Mana Regen - {statList.Align(stats.MpRegen)} | + {statGrowthList.TrimmedAlign(stats.MpRegenPerLevel)}" + Environment.NewLine + $"Attack Damage - {statList.Align(stats.AttackDamage)} | + {statGrowthList.TrimmedAlign(stats.AttackDamagePerLevel)}" + Environment.NewLine + $"Attack Speed - {statList.Align(stats.GetBaseAttackSpeed())} | + {statGrowthList.TrimmedAlign(stats.AttackSpeedPerLevel)}%" + Environment.NewLine + $"Armor - {statList.Align(stats.Armor)} | + {statGrowthList.TrimmedAlign(stats.ArmorPerLevel)}" + Environment.NewLine + $"Magic Resist - {statList.Align(stats.Spellblock)} | + {statGrowthList.TrimmedAlign(stats.SpellblockPerLevel)}" + Environment.NewLine + $"Attack Range - {statList.Align(stats.AttackRange)}" + Environment.NewLine + $"Movement Speed - {statList.Align(stats.MoveSpeed)}"; message.AddField("Stats", statData, new AppendOption[] { AppendOption.Underscore }, new AppendOption[] { AppendOption.Codeblock }, inline: false); }
//Retrieve champion by ID public async Task <ChampionDto> GetChampionAsync(long championID) { ChampionDto champion = null; string request = "/lol/platform/" + C_VERSION + "/champions/" + championID; string response = await GET(request); champion = JsonConvert.DeserializeObject <ChampionDto>(response); return(champion); }
private async void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) { string nameSummoner = NavigationContext.QueryString["name"]; SummonerDto summoner = new SummonerDto(); try { summoner = await summoner.SearchSummoner(nameSummoner); textBlockNomeInv.Text = summoner.Nome; } catch { MessageBox.Show("Não existe um invocador com esse nome."); NavigationService.GoBack(); return; } textBlockLevel.Text += summoner.SummonerLevel.ToString(); try { LeagueDto leagueSummoner = new LeagueDto(); leagueSummoner = await leagueSummoner.SearchLeague(summoner.Id); textBlockElo.Text = leagueSummoner.Tier + " " + leagueSummoner.Entries[0].Division; textBlockVit.Text = leagueSummoner.Entries[0].Wins > 1 ? leagueSummoner.Entries[0].Wins.ToString() + " vitórias" : leagueSummoner.Entries[0].Wins.ToString() + " vitória"; textBlockDer.Text = leagueSummoner.Entries[0].Losses > 1 ? leagueSummoner.Entries[0].Losses.ToString() + " derrotas" : leagueSummoner.Entries[0].Losses.ToString() + " derrota"; } catch { MessageBox.Show("Informações de derrotas e vitórias são apenas para jogadores ranqueados.", "Informação", MessageBoxButton.OK); textBlockElo.Text = "Unranked"; textBlockVit.Text = "0 vitória"; textBlockDer.Text = "0 derrota"; } imageInvocador.Source = await summoner.GetProfileIcon(); RecentGamesDto gamesRecent = await new RecentGamesDto().GetLatestGamesById(summoner.Id); List <int> lastChampionsPlayed = new List <int>(); foreach (GameDto game in gamesRecent.Games) { lastChampionsPlayed.Add(game.ChampionId); LastMatches controlMatch = new LastMatches(game); controlMatch.Margin = new Thickness(0, 0, 0, 10); controlMatch.Load(); listboxPartidas.Items.Add(controlMatch); } int idChampPref = lastChampionsPlayed[new Random().Next(lastChampionsPlayed.Count - 1)]; ImageBrush imgBrush = new ImageBrush(); BitmapImage source = (await ChampionDto.SearchChampionAllData(idChampPref)).GetChampionSplash(0); imgBrush.ImageSource = source; imgBrush.Stretch = Stretch.UniformToFill; LayoutRoot.Background = imgBrush; }
public CounterControl(ChampionDto champion, Boolean canSelect, Boolean isSelected) { InitializeComponent(); Champion = champion; CanSelect = canSelect; if (canSelect) { IsSelected = IsSelected; } LoadImage(); }
private string BuildChampionStats(ChampionStatsDto championStats, int position) { ChampionDto champion = this._championList.FirstOrDefault(x => x.Id.Equals(championStats.ChampionId)); if (champion != null) { return($"`{position.ToString("00", CultureInfo.InvariantCulture)} - {this.FormatPercentage(championStats.WinRate)} - " + $"{this.FormatPercentage(championStats.PlayRate)}` - {champion.Name}"); } return(string.Empty); }
public ChampionDto CreateChampion(ChampionDto champ) { var champTemp = Mapper.Map <Champion>(champ); var result = _champRepositories.Create(champTemp); if (_champRepositories.SaveChanges() > 0) { return(Mapper.Map <ChampionDto>(result)); } return(null); }
private void AppendMiscData(ChampionDto champion, FormattedEmbedBuilder message) { champion.Tags.Sort(); message .SetThumbnail($"http://ddragon.leagueoflegends.com/cdn/{Property.RiotUrlVersion.Value}/img/champion/{champion.Name}.png") .AppendTitle($"{champion.Name} {champion.Title}", AppendOption.Bold, AppendOption.Underscore) .AppendDescription("Classified as:", AppendOption.Italic) .AppendDescription($" {string.Join(", ", champion.Tags)}") .AppendDescriptionNewLine() .AppendDescription("Resource:", AppendOption.Italic) .AppendDescription($" {champion.Resource}") .AppendDescriptionNewLine() .AppendDescription("Passive:", AppendOption.Italic) .AppendDescription($" {champion.Passive.Name}"); }
private void ChampsGrid_ChampSelected(object sender, ChampionDto e) { switch (state) { case State.Watching: throw new InvalidOperationException("Attempted to select a champion out of turn"); case State.Picking: game.SelectChampion(e.key); break; case State.Banning: game.BanChampion(e.key); break; } }
public async Task <ChampionDto> GetChampionAsync(int id) { ChampionDto returnChamp = null; using (var httpClient = new HttpClient()) { var resp = await httpClient.GetAsync($"{realms.cdn}/{realms.n.champion}/data/{realms.l}/champion.json"); if (resp.IsSuccessStatusCode) { var champs = JsonConvert.DeserializeObject <DdragonDto <ChampionDto> >(await resp.Content.ReadAsStringAsync()).data; returnChamp = champs.FirstOrDefault(x => x.Value.key == id.ToString()).Value; } } return(returnChamp); }
static void Main(string[] args) { string APIKeyFile = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "APIKey.txt"); if (!File.Exists(APIKeyFile)) { Console.WriteLine("Please enter in your API Key"); string apiKey = Console.ReadLine(); LeagueAPIStaticFunctions.ApiClient.DefaultRequestHeaders.Add(LeagueURLConstants.HeaderConstants.APIKeyHeader, apiKey); File.WriteAllText(APIKeyFile, apiKey); } else { LeagueAPIStaticFunctions.ApiClient.DefaultRequestHeaders.Add(LeagueURLConstants.HeaderConstants.APIKeyHeader, File.ReadAllText(APIKeyFile)); } ChampionMetaDtoList freeToPlayMetaList = LeagueAPIStaticFunctions.GetCurrentFreeToPlayListHttpClient(); List <ChampionDto> freeToPlayList = new List <ChampionDto>(); foreach (ChampionMetaDto champMeta in freeToPlayMetaList.Champions) { freeToPlayList.Add(LeagueAPIStaticFunctions.GetChampionFromIDHttpClient(Convert.ToInt32(champMeta.Id))); } foreach (ChampionDto champ in freeToPlayList) { Console.WriteLine(string.Format("{0:000}: {1}", champ.Id, champ.Name)); } Console.WriteLine("Please enter the name of a summoner to get information for"); string summonerName = Console.ReadLine(); //This name should really be checked before doing this //Riot would probably yell at me. SummonerDto summoner = LeagueAPIStaticFunctions.GetSummonerMetaByName(summonerName); Console.WriteLine(string.Format("The ID for Summoner with name {0} is {1}", summonerName, summoner.Id)); ChampionDto MostRecentChamp = LeagueAPIStaticFunctions.GetMostRecentlyPlayedChamp(summonerName); Console.WriteLine(string.Format("The most recent champt that {0} played is {1}", summonerName, MostRecentChamp.Name)); Console.ReadLine(); }
private void AppendSpellData(ChampionDto champion, FormattedEmbedBuilder message) { for (int i = 0; i < champion.Spells.Count; i++) { ChampionSpellDto spell = champion.Spells.ElementAt(i); FormattedTextBuilder spellDetail = new FormattedTextBuilder() .Append("Cost:", AppendOption.Italic) .Append($" {spell.GetCostString()}") .AppendNewLine() .Append("Range:", AppendOption.Italic) .Append($" {spell.GetRangeString()}") .AppendNewLine() .Append("Cooldown:", AppendOption.Italic) .Append($" {spell.GetCooldownString()}"); message.AddField($"{GetSpellKey(i)} - {spell.Name}", spellDetail.ToString(), new AppendOption[] { AppendOption.Underscore }, inline: false); } }
public static async Task <FormattedEmbedBuilder> BuildAsync(string name) { name = name.Trim(); ChampionDataBuilder championBuilder = new ChampionDataBuilder(); FormattedEmbedBuilder message = new FormattedEmbedBuilder(); try { List <ChampionDto> matches = await championBuilder.GetMatchingChampionsAsync(name); if (matches.Count == 0) { message .AppendTitle($"{XayahReaction.Error} This didn't work") .AppendDescription($"Oops! Your bad. I couldn't find a champion (fully or partially) named `{name}`."); } else if (matches.Count > 1) { message .AppendTitle($"{XayahReaction.Warning} This didn't went as expected") .AppendDescription($"I found more than one champion (fully or partially) named `{name}`."); foreach (ChampionDto champion in matches) { message.AppendDescription(Environment.NewLine + champion.Name); } } else { ChampionDto champion = await championBuilder.GetChampionAsync(matches.First().Id); championBuilder.AppendMiscData(champion, message); championBuilder.AppendStatisticData(champion, message); championBuilder.AppendSpellData(champion, message); championBuilder.AppendSkinData(champion, message); } } catch (NoApiResultException) { message = new FormattedEmbedBuilder() .AppendTitle($"{XayahReaction.Error} This didn't work") .AppendDescription("Apparently some random API refuses cooperation. Have some patience while I convince them again..."); } return(message); }
private void AppendSkinData(ChampionDto champion, FormattedEmbedBuilder message) { List <SkinDto> skins = champion.Skins.Where(x => x.Num > 0).ToList(); skins.Sort((a, b) => a.Num.CompareTo(b.Num)); string skinData = string.Empty; foreach (SkinDto skin in skins) { string skinNum = skin.Num.ToString(); while (skinNum.Length < 2) { skinNum = "0" + skinNum; } skinData += $"{Environment.NewLine}`{skinNum}` - {skin.Name}"; } message.AddField("Skins", skinData, new AppendOption[] { AppendOption.Underscore }, inline: false); }
public async void Load() { SolidColorBrush solidColor = new SolidColorBrush(); solidColor.Color = game.Stats.Win ? Colors.Green : Colors.Red; solidColor.Opacity = 0.5; LayoutRoot.Background = solidColor; textBlockAbates.Text += game.Stats.ChampionsKilled.ToString(); textBlockMortes.Text += game.Stats.NumDeaths.ToString(); textBlockAssistencias.Text += game.Stats.Assists.ToString(); textBlockFarm.Text += game.Stats.MinionsKilled.ToString(); textBlockOuro.Text += game.Stats.GoldEarned.ToString(); textBlockTempo.Text += ((int)(game.Stats.TimePlayed / 60)).ToString(); textBlockModo.Text += game.SubType; ChampionDto champion = await ChampionDto.SearchChampionLowData(game.ChampionId); this.imageChampion.Source = await champion.GetChampionSquare(); List <int> idItems = new List <int>() { game.Stats.Item0, game.Stats.Item1, game.Stats.Item2, game.Stats.Item3, game.Stats.Item4, game.Stats.Item5, game.Stats.Item6 }; for (int i = 0; i < 7; i++) { try { if (idItems[i] != 0) { ItemDto item = await new ItemDto().SearchItemLowData(idItems[i]); ImageBrush brush = new ImageBrush(); brush.ImageSource = await item.GetImage(); ((Ellipse)itemsMatch.Children[i]).Fill = brush; } else { ((Ellipse)itemsMatch.Children[i]).Stroke = new SolidColorBrush(SystemColors.ActiveBorderColor); } }catch {} } }
public static ChampionDto GetChampionFromIDHttpClient(int id) { string sURL = String.Format(LeagueURLConstants.APIPaths.ChampPath, id.ToString()); ChampionDto leagueChampion = null; using (StreamReader response = new StreamReader(ApiClient.GetStreamAsync(sURL).Result)) using (JsonReader jsonResponse = new JsonTextReader(response)) { JsonSerializer serializer = new JsonSerializer(); leagueChampion = serializer.Deserialize <ChampionDto>(jsonResponse); } if (leagueChampion == null) { Console.WriteLine("Error occured while trying to retreive information for {0}", id.ToString()); } return(leagueChampion); }
public IActionResult Create(ChampionDto championCreateDto) { if (championCreateDto == null) { return(BadRequest()); } var champion = new Champion(); champion.Role = (Role)championCreateDto.Role; champion.Name = championCreateDto.Name; champion.Overview = championCreateDto.Overview; champion.UltimateDesc = championCreateDto.UltimateDesc; champion.UltimateName = championCreateDto.UltimateName; champion.LinkUrl = championCreateDto.LinkUrl; champion.VideoUrl = championCreateDto.VideoUrl; champData.Create(champion); champData.Commit(); return(CreatedAtRoute("GetChampion", new { id = champion.Id }, champion)); }
public static Champion ConvertChampionDtoToChampion(ChampionDto championDto) { if (championDto == null) { return(new Champion()); } try { return(new Champion { ChampionId = championDto.ChampionId, ChampionName = championDto.ChampionName, ChampionIconPath = ImageLocationStrings.ChampionsImagesPath + championDto.ImageFull }); } catch (Exception e) { Console.WriteLine("Exception caught when converting ChampionDto to Champion : " + e.Message); } return(new Champion()); }
private async void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) { if (!carregado) { ChampionDto champion = new ChampionDto(); champion = await ChampionDto.SearchChampionAllData(Convert.ToInt32(NavigationContext.QueryString["id"])); iconChampion.Source = await champion.GetChampionSquare(); Random randNumSkin = new Random(); int num = randNumSkin.Next(champion.Skins.Count); BitmapImage backGridInfo = champion.GetChampionSplash(num); ImageBrush brush = new ImageBrush(); brush.Stretch = Stretch.UniformToFill; brush.ImageSource = backGridInfo; panorama.Background = brush; panorama.Background.Opacity = 0.5; championName.Text = champion.Name; TextBlock loreDescription = new TextBlock(); lore.Text = Code.HtmlRemoval.StripTagsCharArray(champion.Lore); AddInfoComponent(champion.AllyTips, allytips); AddInfoComponent(champion.EnimyTips, enimytips); attackInfo.Value = champion.Info.Attack; defenseInfo.Value = champion.Info.Defense; magicInfo.Value = champion.Info.Magic; difficultyInfo.Value = champion.Info.Difficulty; //incluir habilidades foreach (ChampionSpellDto spell in champion.Spells) { ControlAbillity controlAbillity = new ControlAbillity(spell); abillityChampions.Children.Add(controlAbillity); } CarregarComentarios(); CarregarCounters(); } }
private void ChampsGrid_SkinSelected(object sender, ChampionDto.SkinDto e) { if (state != State.Banning) game.SelectSkin(Popup.ChampSelector.SelectedChampion.key, e.id); }
public Card GetChampionCardById(int id) { ChampionDto champion = null; foreach (ChampionDto cdto in GameWorld.Instance.Champions.Data) { if (cdto.Id == id) { champion = cdto; break; } } if (null == champion) { return(null); } GameObject cardObject = new GameObject(); cardObject.name = champion.Name; GameObject cardArtObject = GameObject.CreatePrimitive(PrimitiveType.Quad); cardArtObject.name = "Card Mesh"; //a mesh collider is created by CreatePrimitive(). We don't need it Destroy(cardArtObject.GetComponent <MeshCollider>()); cardArtObject.transform.SetParent(cardObject.transform, false); cardArtObject.GetComponent <Renderer>().material = new Material(Shader.Find("Unlit/Texture")); ChampionCard card = cardObject.AddComponent <ChampionCard>(); card.championData = champion; card.cardMesh = cardArtObject; card.onPlayActionChain = championActionChain; card.cardName = champion.Name; BoxCollider boxCollider = cardObject.AddComponent <BoxCollider>(); boxCollider.size = new Vector3(1, 1, 0.1f); Texture2D texture; if (championMediumTextures.TryGetValue(champion.Id, out texture)) { card.image = texture; card.thumb = championSmallTextures[champion.Id]; } else { texture = new Texture2D(8, 8); texture.name = string.Format("{0}_image", champion.Name); championMediumTextures[champion.Id] = texture; card.image = texture; StartCoroutine(DownloadImage(string.Format(Constants.championMediumImageUrl, champion.Key, "0"), texture)); texture = new Texture2D(8, 8); texture.name = string.Format("{0}_thumb", champion.Name); championSmallTextures[champion.Id] = texture; card.thumb = texture; StartCoroutine(DownloadImage(string.Format(Constants.championSmallImageUrl, GameWorld.Instance.DragonDataVersion, champion.Key), texture)); } card.Init(); return(card); }
void item_Tap(object sender, System.Windows.Input.GestureEventArgs e) { ChampionDto championSelected = (sender as ChampionSelected).Champion; NavigationService.Navigate(new Uri("/Pages/DetailChampion.xaml?id=" + championSelected.Id, UriKind.Relative)); }
public void ThenIVeGottenInformationFor(string name) { ChampionDto champ = ScenarioContext.Current["CHAMP_DTO"] as ChampionDto; Assert.IsTrue(champ.Name.Equals(name)); }
public Card GetRandomChampionCard() { ChampionDto champion = GameWorld.Instance.Champions.Data[Random.Range(0, GameWorld.Instance.Champions.Data.Length)]; return(GetChampionCardById(champion.Id)); }