public Task <Demo> AnalyzeBannedPlayersAsync(Demo demo) { return(Task.FromResult(demo)); }
public Task <bool> DeleteDemo(Demo demo) { return(Task.FromResult(true)); }
public Task SaveStatus(Demo demo, string status) { demo.Status = status; return(Task.FromResult(demo)); }
public Task <Demo> AnalyzePlayersPosition(Demo demo, CancellationToken token) { return(Task.FromResult(demo)); }
/// <summary> /// Return PositionPoint for each players determined by selection /// </summary> /// <param name="demo"></param> /// <param name="teamSelector"></param> /// <param name="selectedPlayer"></param> /// <param name="round"></param> /// <returns></returns> public async Task <List <List <PositionPoint> > > GetPoints(Demo demo, string teamSelector, Player selectedPlayer, Round round) { List <List <PositionPoint> > points = new List <List <PositionPoint> >(); if (teamSelector != null) { switch (teamSelector) { case "CT": demo.PositionPoints.Reverse(); foreach (Player playerExtended in demo.Players) { List <PositionPoint> playerPoints = new List <PositionPoint>(); for (int i = demo.PositionPoints.Count - 1; i >= 0; i--) { if (demo.PositionPoints[i].RoundNumber != round.Number) { continue; } // Keep kills from terrorists if (demo.PositionPoints[i].Event != null && demo.PositionPoints[i].Team == Side.Terrorist && demo.PositionPoints[i].Event.GetType() == typeof(KillEvent)) { KillEvent e = (KillEvent)demo.PositionPoints[i].Event; if (e.KillerSteamId == playerExtended.SteamId) { playerPoints.Add(demo.PositionPoints[i]); demo.PositionPoints.RemoveAt(i); continue; } } if (demo.PositionPoints[i].Team != Side.CounterTerrorist) { continue; } // Molotov started if (demo.PositionPoints[i].Event != null && demo.PositionPoints[i].Event.GetType() == typeof(MolotovFireStartedEvent)) { MolotovFireStartedEvent e = (MolotovFireStartedEvent)demo.PositionPoints[i].Event; if (e.ThrowerSteamId == playerExtended.SteamId) { playerPoints.Add(demo.PositionPoints[i]); demo.PositionPoints.RemoveAt(i); continue; } } // Molotov ended if (demo.PositionPoints[i].Event != null && demo.PositionPoints[i].Event.GetType() == typeof(MolotovFireEndedEvent)) { MolotovFireEndedEvent e = (MolotovFireEndedEvent)demo.PositionPoints[i].Event; if (e.ThrowerSteamId == playerExtended.SteamId) { playerPoints.Add(demo.PositionPoints[i]); demo.PositionPoints.RemoveAt(i); continue; } } if (demo.PositionPoints[i].PlayerSteamId != 0 && demo.PositionPoints[i].PlayerSteamId == playerExtended.SteamId) { playerPoints.Add(demo.PositionPoints[i]); demo.PositionPoints.RemoveAt(i); } } if (playerPoints.Any()) { points.Add(playerPoints); } } break; case "T": demo.PositionPoints.Reverse(); foreach (Player playerExtended in demo.Players) { List <PositionPoint> playerPoints = new List <PositionPoint>(); for (int i = demo.PositionPoints.Count - 1; i >= 0; i--) { if (demo.PositionPoints[i].RoundNumber != round.Number) { continue; } // Keep kills from CT if (demo.PositionPoints[i].Event != null && demo.PositionPoints[i].Team == Side.CounterTerrorist && demo.PositionPoints[i].Event.GetType() == typeof(KillEvent)) { KillEvent e = (KillEvent)demo.PositionPoints[i].Event; if (e.KilledSteamId == playerExtended.SteamId) { playerPoints.Add(demo.PositionPoints[i]); demo.PositionPoints.RemoveAt(i); continue; } } if (demo.PositionPoints[i].Team != Side.Terrorist) { continue; } // Molotov started if (demo.PositionPoints[i].Event != null && demo.PositionPoints[i].Event.GetType() == typeof(MolotovFireStartedEvent)) { MolotovFireStartedEvent e = (MolotovFireStartedEvent)demo.PositionPoints[i].Event; if (e.ThrowerSteamId == playerExtended.SteamId) { playerPoints.Add(demo.PositionPoints[i]); demo.PositionPoints.RemoveAt(i); continue; } } // Molotov ended if (demo.PositionPoints[i].Event != null && demo.PositionPoints[i].Event.GetType() == typeof(MolotovFireEndedEvent)) { MolotovFireEndedEvent e = (MolotovFireEndedEvent)demo.PositionPoints[i].Event; if (e.ThrowerSteamId == playerExtended.SteamId) { playerPoints.Add(demo.PositionPoints[i]); demo.PositionPoints.RemoveAt(i); continue; } } if (demo.PositionPoints[i].PlayerSteamId == playerExtended.SteamId) { playerPoints.Add(demo.PositionPoints[i]); demo.PositionPoints.RemoveAt(i); } } if (playerPoints.Any()) { points.Add(playerPoints); } } break; case "BOTH": points.AddRange( demo.Players.Select( playerExtended => demo.PositionPoints.Where( point => point.RoundNumber == round.Number && point.PlayerSteamId == playerExtended.SteamId).ToList()) .Where(pts => pts.Any())); break; } } if (selectedPlayer != null) { await Task.Run(delegate { List <PositionPoint> pt = demo.PositionPoints.ToList().Where( positionPoint => positionPoint.PlayerSteamId == selectedPlayer.SteamId && positionPoint.RoundNumber == round.Number || (positionPoint.Event != null && positionPoint.Event.GetType() == typeof(KillEvent)) && positionPoint.RoundNumber == round.Number).ToList(); if (pt.Any()) { points.Add(pt); } }); } // Set players color await Task.Run(delegate { int index = 0; foreach (List <PositionPoint> positionPoints in points.ToList()) { foreach (PositionPoint positionPoint in positionPoints) { positionPoint.X = MapService.CalculatePointToResolutionX(positionPoint.X); positionPoint.Y = MapService.CalculatePointToResolutionY(positionPoint.Y); positionPoint.Color = ColorToInt(_colors[index]); } index++; } }); return(points); }
public Task SaveComment(Demo demo, string comment) { demo.Comment = comment; return(Task.FromResult(demo)); }
public Task <List <TimelineEvent> > GetTimeLineEventList(Demo demo) { List <TimelineEvent> events = new List <TimelineEvent>(); float tickrate = demo.ServerTickrate; foreach (Round round in demo.Rounds) { int endTick = round.EndTickOfficially > 0 ? round.EndTickOfficially : round.EndTick; var e = new RoundEventTimeline(tickrate, round.Tick, endTick) { Number = round.Number, }; events.Add(e); } foreach (KillEvent e in demo.Kills) { events.Add(new KillEventTimeline(tickrate, e.Tick, (int)(e.Tick + demo.Tickrate)) { VictimName = e.KilledName, KillerName = e.KillerName, WeaponName = e.Weapon.Name, }); } List <WeaponFireEvent> flashs = demo.WeaponFired.Where(e => e.Weapon.Element == EquipmentElement.Flash).ToList(); foreach (WeaponFireEvent e in flashs) { events.Add(new FlashThrownEventTimeline(tickrate, e.Tick, e.Tick + (int)demo.Tickrate) { ThrowerName = e.ShooterName, }); } List <WeaponFireEvent> smokes = demo.WeaponFired.Where(e => e.Weapon.Element == EquipmentElement.Smoke).ToList(); foreach (WeaponFireEvent e in smokes) { events.Add(new SmokeThrownEventTimeline(tickrate, e.Tick, e.Tick + (int)demo.Tickrate) { ThrowerName = e.ShooterName, }); } List <WeaponFireEvent> he = demo.WeaponFired.Where(e => e.Weapon.Element == EquipmentElement.HE).ToList(); foreach (WeaponFireEvent e in he) { events.Add(new HeThrownEventTimeline(tickrate, e.Tick, e.Tick + (int)demo.Tickrate) { ThrowerName = e.ShooterName, }); } List <WeaponFireEvent> molotovs = demo.WeaponFired.Where(e => e.Weapon.Element == EquipmentElement.Molotov).ToList(); foreach (WeaponFireEvent e in molotovs) { events.Add(new MolotovThrownEventTimeline(tickrate, e.Tick, e.Tick + (int)demo.Tickrate) { ThrowerName = e.ShooterName, }); } List <WeaponFireEvent> incendiaries = demo.WeaponFired.Where(e => e.Weapon.Element == EquipmentElement.Incendiary).ToList(); foreach (WeaponFireEvent e in incendiaries) { events.Add(new IncendiaryThrownEventTimeline(tickrate, e.Tick, e.Tick + (int)demo.Tickrate) { ThrowerName = e.ShooterName, }); } List <WeaponFireEvent> decoys = demo.WeaponFired.Where(e => e.Weapon.Element == EquipmentElement.Decoy).ToList(); foreach (WeaponFireEvent e in decoys) { events.Add(new DecoyThrownEventTimeline(tickrate, e.Tick, e.Tick + (int)demo.Tickrate) { ThrowerName = e.ShooterName, }); } foreach (Round round in demo.Rounds) { if (round.BombPlanted != null) { events.Add(new BombPlantedEventTimeline(tickrate, round.BombPlanted.Tick, round.BombPlanted.Tick + (int)demo.Tickrate) { PlanterName = round.BombPlanted.PlanterName, Site = round.BombPlanted.Site, }); } if (round.BombDefused != null) { events.Add(new BombDefusedEventTimeline(tickrate, round.BombDefused.Tick, round.BombDefused.Tick + (int)demo.Tickrate) { Site = round.BombDefused.Site, DefuserName = round.BombDefused.DefuserName, }); } if (round.BombExploded != null) { events.Add(new BombExplodedEventTimeline(tickrate, round.BombExploded.Tick, round.BombExploded.Tick + (int)demo.Tickrate) { PlanterName = round.BombExploded.PlanterName, Site = round.BombExploded.Site, }); } } return(Task.FromResult(events)); }
public Task <Demo> SetSource(Demo demo, string source) { return(Task.FromResult(demo)); }
public async Task SaveStatus(Demo demo, string status) { demo.Status = status; await _cacheService.WriteDemoDataCache(demo); }
public void WriteChatFile(Demo demo, string filePath) { File.WriteAllText(filePath, string.Join(Environment.NewLine, demo.ChatMessageList.ToArray())); }
public async Task SaveComment(Demo demo, string comment) { demo.Comment = comment; await _cacheService.WriteDemoDataCache(demo); }
public async Task <List <Demo> > GetDemosHeader(List <string> folders, List <Demo> currentDemos = null, int demoSize = 0) { // Demos list returned List <Demo> demos = new List <Demo>(); // Contains all demos header data List <Demo> demoHeaderList = new List <Demo>(); if (folders.Count > 0) { // retrieve basic demos data List <DemoBasicData> demoBasicDataList = await _cacheService.GetDemoBasicDataAsync(); // contains possible DemoBasicData that will be keeped List <DemoBasicData> tempDemoBasicDataList = new List <DemoBasicData>(); foreach (string folder in folders) { if (Directory.Exists(folder)) { string[] files = Directory.GetFiles(folder, "*.dem"); foreach (string file in files) { if (file.Contains("myassignedcase")) { continue; } Demo demo = await GetDemoHeaderAsync(file); if (demo != null) { // Skip if the demo is already in the current demos list if ((currentDemos != null && currentDemos.Contains(demo)) || demoHeaderList.Contains(demo)) { continue; } demoHeaderList.Add(demo); } } } } // Process each demo header foreach (Demo demo in demoHeaderList) { // retrieve basic demo data DemoBasicData demoData = demoBasicDataList.FirstOrDefault(d => d.Id == demo.Id); if (demoData == null) { // if basic data are not found, add it to cache demoData = await _cacheService.AddDemoBasicDataAsync(demo); } // Skip if the player isn't in the demo if (ShowOnlyAccountDemos && SelectedStatsAccountSteamId != 0 && !demoData.SteamIdList.Contains(SelectedStatsAccountSteamId)) { continue; } // store basic data to filter on date quickly tempDemoBasicDataList.Add(demoData); } tempDemoBasicDataList.Sort((d1, d2) => d2.Date.CompareTo(d1.Date)); if (demoSize > 0) { tempDemoBasicDataList = tempDemoBasicDataList.Take(demoSize).ToList(); } foreach (DemoBasicData basicData in tempDemoBasicDataList) { Demo demo; bool hasDemoInCache = _cacheService.HasDemoInCache(basicData.Id); if (hasDemoInCache) { demo = await GetDemoDataByIdAsync(basicData.Id); } else { demo = demoHeaderList.First(d => d.Id == basicData.Id); } if (currentDemos == null || !currentDemos.Contains(demo)) { demos.Add(demo); } } } return(demos); }
public void WriteChatFile(Demo demo, string filePath) { }
public Task <Demo> GetDemoDataAsync(Demo demo) { Demo newDemo = new Demo(); return(Task.FromResult(newDemo)); }
public Task <string> GetShareCode(Demo demo) { return(Task.FromResult("CSGO-Vd1T-FD32d-549td-DF41f-Td8dZ")); }
public Task <Demo> AnalyzeDemo(Demo demo, CancellationToken token) { Random random = new Random(); ObservableCollection <Player> players = new ObservableCollection <Player>(); for (int i = 0; i < 10; i++) { Player player = new Player { Name = "player" + (i + 1), HeadshotCount = random.Next(14), OneKillCount = random.Next(10, 30), TwoKillCount = random.Next(10, 20), ThreeKillCount = random.Next(0, 10), FourKillCount = random.Next(0, 5), FiveKillCount = random.Next(0, 2), BombDefusedCount = random.Next(0, 2), BombPlantedCount = random.Next(0, 2), DeathCount = random.Next(0, 32), KillCount = random.Next(30), AssistCount = random.Next(15), Score = random.Next(10, 80), RoundMvpCount = random.Next(6), RankNumberNew = 5, RankNumberOld = 4, RatingHltv = (float)random.NextDouble(), SteamId = random.Next(1000, 800000), IsOverwatchBanned = random.Next(100) < 40, IsVacBanned = random.Next(100) < 40, TeamKillCount = random.Next(0, 1), WinCount = random.Next(10, 687), MolotovThrownCount = random.Next(0, 10), DecoyThrownCount = random.Next(0, 10), IncendiaryThrownCount = random.Next(20), SmokeThrownCount = random.Next(20), FlashbangThrownCount = random.Next(20), HeGrenadeThrownCount = random.Next(20), BombExplodedCount = random.Next(5), AvatarUrl = string.Empty, KillDeathRatio = (decimal)random.NextDouble(), MatchCount = random.Next(100), RoundPlayedCount = random.Next(100) }; players.Add(player); } Team teamCt = new Team { Name = "Team 1", Players = new ObservableCollection <Player>(players.Take(5)), Score = 6, ScoreFirstHalf = 6, ScoreSecondHalf = 1, }; Team teamT = new Team { Name = "Team 2", Players = new ObservableCollection <Player>(players.Skip(5).Take(5)), Score = 16, ScoreFirstHalf = 10, ScoreSecondHalf = 5, }; ObservableCollection <Round> rounds = new ObservableCollection <Round>(); for (int i = 0; i < 32; i++) { ObservableCollection <KillEvent> kills = new ObservableCollection <KillEvent>(); for (int j = 0; j < random.Next(1, 9); j++) { Player killer = players.ElementAt(random.Next(9)); Player killed = players.ElementAt(random.Next(9)); kills.Add(new KillEvent(random.Next(1, 10000), random.Next(1, 100)) { KillerName = killer.Name, KillerSteamId = killer.SteamId, KillerSide = killer.Side, KilledName = killed.Name, KilledSteamId = killed.SteamId, KilledSide = killed.Side, RoundNumber = i, Weapon = Weapon.WeaponList.ElementAt(random.Next(44)) }); } // generate open / entry kills for this round Round round = new Round { Number = i + 1, OneKillCount = random.Next(5), TwoKillCount = random.Next(2), ThreeKillCount = random.Next(1), FourKillCount = random.Next(1), FiveKillCount = random.Next(1), EquipementValueTeamCt = random.Next(4200, 30000), EquipementValueTeamT = random.Next(4200, 30000), StartMoneyTeamCt = random.Next(4200, 50000), StartMoneyTeamT = random.Next(4200, 50000), Tick = random.Next(7000, 100000), WinnerName = teamCt.Name, WinnerSide = Side.CounterTerrorist, StartTimeSeconds = random.Next(1), BombDefused = null, EndTimeSeconds = random.Next(100), BombPlanted = null, BombExploded = null, Type = RoundType.NORMAL, EndReason = RoundEndReason.CTWin, EntryKillEvent = new EntryKillEvent(random.Next(1, 10000), random.Next(1, 100)) { HasWon = random.Next(100) < 50, KillerSteamId = players.ElementAt(random.Next(9)).SteamId, KillerName = players.ElementAt(random.Next(9)).Name, KilledSteamId = players.ElementAt(random.Next(9)).SteamId, KilledName = players.ElementAt(random.Next(9)).Name, Weapon = Weapon.WeaponList.ElementAt(random.Next(44)), KilledSide = Side.CounterTerrorist, KillerSide = Side.Terrorist }, SideTrouble = Side.None, Kills = kills }; rounds.Add(round); } demo.Id = "de_dust25445648778447878"; demo.Source = new Valve(); demo.Name = "esea_nip_vs_titan.dem"; demo.Tickrate = 15; demo.ServerTickrate = 128; demo.MapName = "de_dust2"; demo.ClientName = "localhost"; demo.Hostname = "local"; demo.OneKillCount = 90; demo.TwoKillCount = 30; demo.ThreeKillCount = 25; demo.FourKillCount = 3; demo.FiveKillCount = 1; demo.Path = "C:\\mydemo.dem"; demo.Type = "GOTV"; demo.Comment = "comment"; demo.TeamCT = teamCt; demo.TeamT = teamT; demo.Players = players; demo.Rounds = rounds; demo.MostKillingWeapon = Weapon.WeaponList[random.Next(44)]; foreach (KillEvent e in rounds.SelectMany(round => round.Kills)) { demo.Kills.Add(e); } return(Task.FromResult(demo)); }
public Task <string> GetOldId(Demo demo) { return(Task.FromResult("12345")); }
private static Demo GenerateDemo() { int currentTick = 1; ObservableCollection <Player> players = new ObservableCollection <Player>(); Random random = new Random(); ObservableCollection <EntryKillEvent> entryKills = new ObservableCollection <EntryKillEvent>(); for (int indexEntryKill = 0; indexEntryKill < random.Next(5); indexEntryKill++) { currentTick *= indexEntryKill; Player killer = players.ElementAt(random.Next(0, 9)); Player killed = players.ElementAt(random.Next(0, 9)); EntryKillEvent entryKill = new EntryKillEvent(currentTick, random.Next(1, 50000)) { KilledSteamId = killed.SteamId, KilledName = killed.Name, KilledSide = killed.Side, KillerSteamId = killer.SteamId, KillerName = killer.Name, KillerSide = killer.Side }; entryKills.Add(entryKill); } for (int j = 0; j < 10; j++) { Player player = new Player { Name = "player" + (j + 1), HeadshotCount = random.Next(14), OneKillCount = random.Next(10, 30), TwoKillCount = random.Next(10, 20), ThreeKillCount = random.Next(0, 10), FourKillCount = random.Next(0, 5), FiveKillCount = random.Next(0, 2), BombDefusedCount = random.Next(0, 2), BombPlantedCount = random.Next(0, 2), EntryKills = entryKills, DeathCount = random.Next(0, 32), KillCount = random.Next(30), AssistCount = random.Next(15), Score = random.Next(10, 80), RoundMvpCount = random.Next(6) }; player.EnableUpdates(); players.Add(player); } currentTick = 1; ObservableCollection <Round> rounds = new ObservableCollection <Round>(); for (int k = 0; k < 32; k++) { Round round = new Round { Number = k + 1, OneKillCount = random.Next(5), TwoKillCount = random.Next(2), ThreeKillCount = random.Next(1), FourKillCount = random.Next(1), FiveKillCount = random.Next(1), EquipementValueTeamCt = random.Next(4200, 30000), EquipementValueTeamT = random.Next(4200, 30000), StartMoneyTeamCt = random.Next(4200, 50000), StartMoneyTeamT = random.Next(4200, 50000), Tick = currentTick * k, EndTick = currentTick + 5000, }; currentTick += 5000; round.EnableUpdates(); rounds.Add(round); } Demo demo = new Demo { Id = "de_dust25445648778447878", Name = "mydemo.dem", Tickrate = 32, ServerTickrate = 64, MapName = "de_dust2", ClientName = "localhost", Hostname = "local", OneKillCount = random.Next(50, 90), TwoKillCount = random.Next(20, 50), ThreeKillCount = random.Next(10), FourKillCount = random.Next(3), FiveKillCount = random.Next(1), Path = "C:\\mydemo.dem", Type = "GOTV", Comment = "comment", Players = players, MostBombPlantedPlayer = players.ElementAt(random.Next(10)), MostHeadshotPlayer = players.ElementAt(random.Next(10)), Rounds = rounds, Duration = 2651.65625f, }; Team teamCt = new Team { Name = "Team 1", Players = new ObservableCollection <Player>(players.Take(5)), Score = 6, ScoreFirstHalf = 6, ScoreSecondHalf = 1, }; Team teamT = new Team { Name = "Team 2", Players = new ObservableCollection <Player>(players.Skip(5).Take(5)), Score = 16, ScoreFirstHalf = 10, ScoreSecondHalf = 5, }; demo.TeamT = teamT; demo.TeamCT = teamCt; return(demo); }