private DeathEventAggregate ConvertToTeamkillAggregate(DeathEventAggregate aggregate) { return(new DeathEventAggregate() { Kills = aggregate.Teamkills, Deaths = aggregate.Deaths, Headshots = aggregate.Headshots, HeadshotDeaths = aggregate.HeadshotDeaths }); }
private DeathEventAggregate GetStatsForPlayerLoadout(IEnumerable <LoadoutVsLoadoutSummaryRow> groupedVsRows, int playerLoadoutId) { var attackerAggregate = new DeathEventAggregate(); var victimAggregate = new DeathEventAggregate(); var attackerRows = groupedVsRows.Where(grp => grp.AttackerLoadoutId == playerLoadoutId).ToArray(); foreach (var row in attackerRows) { var addend = (row.AttackerFactionId != row.VictimFactionId) ? row.AttackerStats : new DeathEventAggregate() { Kills = 0, Deaths = ConvertToTeamkillAggregate(row.AttackerStats).Deaths, Headshots = 0, HeadshotDeaths = ConvertToTeamkillAggregate(row.AttackerStats).HeadshotDeaths }; attackerAggregate.Add(addend); } var victimRows = groupedVsRows.Where(grp => grp.VictimLoadoutId == playerLoadoutId).ToArray(); foreach (var row in victimRows) { var rowEnemyLoadoutId = row.AttackerLoadoutId; if (groupedVsRows.Any(grp => grp.AttackerLoadoutId == playerLoadoutId && grp.VictimLoadoutId == row.AttackerLoadoutId)) { continue; } var addend = (row.AttackerFactionId != row.VictimFactionId) ? row.VictimStats : new DeathEventAggregate() { Kills = 0, Deaths = ConvertToTeamkillAggregate(row.VictimStats).Deaths, Headshots = 0, HeadshotDeaths = ConvertToTeamkillAggregate(row.VictimStats).HeadshotDeaths }; victimAggregate.Add(addend); } return(attackerAggregate.Add(victimAggregate)); }
private DeathEventAggregate GetStatsForFactionVsPlayerLoadout(IEnumerable <LoadoutVsLoadoutSummaryRow> groupedVsRows, int playerLoadoutId, int playerFactionId, int enemyFactionId) { var attackerAggregate = new DeathEventAggregate(); var victimAggregate = new DeathEventAggregate(); var useTeamkills = (playerFactionId == enemyFactionId); if (groupedVsRows.Any(grp => grp.AttackerLoadoutId == playerLoadoutId && grp.VictimFactionId == enemyFactionId)) { var targetRows = groupedVsRows.Where(grp => grp.AttackerLoadoutId == playerLoadoutId && grp.VictimFactionId == enemyFactionId).ToArray(); if (useTeamkills == false) { attackerAggregate.Kills = targetRows.Sum(row => row.AttackerStats.Kills); attackerAggregate.Headshots = targetRows.Sum(row => row.AttackerStats.Headshots); attackerAggregate.Deaths = targetRows.Sum(row => row.AttackerStats.Deaths); attackerAggregate.HeadshotDeaths = targetRows.Sum(row => row.AttackerStats.HeadshotDeaths); } else { attackerAggregate.Kills = targetRows.Sum(row => ConvertToTeamkillAggregate(row.AttackerStats).Kills); attackerAggregate.Headshots = targetRows.Sum(row => ConvertToTeamkillAggregate(row.AttackerStats).Headshots); attackerAggregate.Deaths = targetRows.Sum(row => ConvertToTeamkillAggregate(row.AttackerStats).Deaths); attackerAggregate.HeadshotDeaths = targetRows.Sum(row => ConvertToTeamkillAggregate(row.AttackerStats).HeadshotDeaths); } } var victimRows = groupedVsRows.Where(grp => grp.VictimLoadoutId == playerLoadoutId && grp.AttackerFactionId == enemyFactionId).ToArray(); foreach (var row in victimRows) { var rowEnemyLoadoutId = row.AttackerLoadoutId; var rowPlayerLoadoutId = row.VictimLoadoutId; if (groupedVsRows.Any(grp => grp.AttackerLoadoutId == rowPlayerLoadoutId && grp.VictimLoadoutId == rowEnemyLoadoutId)) { continue; } var addend = (useTeamkills == false) ? row.VictimStats : ConvertToTeamkillAggregate(row.VictimStats); victimAggregate.Add(addend); } return(attackerAggregate.Add(victimAggregate)); }