public ObservableCollection <RecentMatch> ConvertToRecentMatches(Match[] matches) { ObservableCollection <RecentMatch> recentMatchesObservable = new ObservableCollection <RecentMatch>(); foreach (Match match in matches) { RecentMatch recentMatch = new RecentMatch() { match_id = Convert.ToString(match.match_id), Win = match.Won, //WinBrush = new Converter().ToGameBrush(match.Won),// requires Converter Duration = Convert.ToString(match.duration), GameMode = new Converter().GetGameMode(match.game_mode), // requires converter HeroName = new Converter().GetHeroName(match.hero_id), // requires converter hero = new Converter().GetHeroImg(match.hero_id), // requires converter Kills = Convert.ToString(match.kills), Deaths = Convert.ToString(match.deaths), Assists = Convert.ToString(match.assists), XPpm = Convert.ToString(match.xp_per_min), Gpm = Convert.ToString(match.gold_per_min), HeroDmg = Convert.ToString(match.hero_damage), TowerDmg = Convert.ToString(match.tower_damage), HeroHeal = Convert.ToString(match.hero_healing), LastHit = Convert.ToString(match.last_hits) }; recentMatchesObservable.Add(recentMatch); } return(recentMatchesObservable); }
public void ShowPopUp(UIElement target, RecentMatch recentMatch) { //duration //SetDuration(0,0); GetTextBlock(1, 0).Text = recentMatch.Duration; //game made GetTextBlock(1, 1).Text = recentMatch.GameMode; //hero name GetTextBlock(1, 2).Text = recentMatch.HeroName; //kills GetTextBlock(1, 3).Text = $"{recentMatch.Kills}:{recentMatch.Deaths}:{recentMatch.Assists}"; //XPpm GetTextBlock(1, 4).Text = recentMatch.XPpm; //SetGold GetTextBlock(1, 5).Text = recentMatch.Gpm; //hero damage GetTextBlock(1, 6).Text = recentMatch.HeroDmg; //tower damage GetTextBlock(1, 7).Text = recentMatch.TowerDmg; //heal GetTextBlock(1, 8).Text = recentMatch.HeroHeal; //lasthit GetTextBlock(1, 9).Text = recentMatch.LastHit; PlacementTarget(target); }
public bool IsWon(RecentMatch Match) { if (Match.RadiantWin) { return(Match.PlayerSlot < dataFactory.GetRadiantIndex()); } else { return(Match.PlayerSlot > dataFactory.GetRadiantIndex()); } }
/// Test methouds private void tst() { ObservableCollection <PlayerModel> players = new ObservableCollection <PlayerModel>(); ObservableCollection <RecentMatch> recentMatches = new ObservableCollection <RecentMatch>(); BitmapImage image = new BitmapImage(); image.BeginInit(); image.UriSource = new Uri(AppDomain.CurrentDomain.BaseDirectory + "/Resources/Icons/Abaddon.png"); image.EndInit(); for (int i = 0; i < 20; i++) { RecentMatch recent = new RecentMatch() { hero = image, match_id = Convert.ToString(i), radiant_win = true, Duration = "60", GameMode = "Turbo", HeroName = "Abadon", Kills = "10", Deaths = "3", Assists = "12", XPpm = "1000", Gpm = "1300", HeroDmg = "50000", TowerDmg = "10000", HeroHeal = "50", LastHit = "120", }; recentMatches.Add(recent); } for (int i = 0; i < 10; i++) { PlayerModel pvm = new PlayerModel() { Avatar = new BitmapImage(), Name = $"n{i}", RecentMatchesObservable = recentMatches }; players.Add(pvm); } PlayersViewmodel.PlayerModelsObservable = players; }
public async Task <object> GetRecentMatch(string userId) { try { HttpResponseMessage response = await client.GetAsync(dotaRemoteRepoManager.GetUserRecentMatchsById(userId)); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); RecentMatch[] recentMatchs = RecentMatch.FromJson(responseBody); List <Match> returnMatchs = new List <Match>(); foreach (RecentMatch match in recentMatchs) { Match playerMatch = new Match(); playerMatch.assist = match.Assists; playerMatch.death = match.Deaths; playerMatch.gpm = match.GoldPerMin; playerMatch.myHero = await dataFactory.GetHerosById(match.HeroId); playerMatch.isWon = matchHandler.IsWon(match); playerMatch.kill = match.Kills; playerMatch.matchId = match.MatchId; returnMatchs.Add(playerMatch); } return(Json(returnMatchs, new JsonSerializerSettings { ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver(), Formatting = Formatting.Indented })); } catch (HttpRequestException e) { return(Ok("no match found")); } }
private void RecentMatch_MouseLeftButtonUp(object sender, RoutedEventArgs e) { Image img = sender as Image; Binding binding = BindingOperations.GetBinding(img, Image.SourceProperty); string path = Convert.ToString(binding.Path.Path); //"[x].RecentMatchesObservable[i].hero" var c = path.Split("]"); int x = Convert.ToInt32(c[0].Split("[")[1]); int i = Convert.ToInt32(c[1].Split("[")[1]); try { RecentMatch match = PlayersViewmodel.PlayerModelsObservable[x].RecentMatchesObservable[i]; RecentMatch_Popup.ShowPopUp(img, match); } catch { return; } }
public static string FormatPlayer(string name, RecentMatch match) { return($"{name} | {match.Hero} | {match.LobbyType} | {match.GameMode} | {(match.Win ? "**Win**" : "Loss")} | {match.Duration} | {match.Kills}/{match.Deaths}/{match.Assists}"); }