public ServerStatistics(BaseServerStatistics stats) { this.totalMatchesPlayed = stats.TotalMatchesPlayed; this.maximumMatchesPerDay = stats.MaximumMatchesPerDay; this.averageMatchesPerDay = (double)stats.TotalMatchesPlayed / Math.Max(stats.LastMatchPlayed.Subtract(stats.FirstMatchPlayed).Days, 1); this.maximumPopulation = stats.MaximumPopulation; this.averagePopulation = (double)stats.TotalPlayersInMatches / stats.TotalMatchesPlayed; this.top5GameModes = stats.TopGameModes.Take(5).Select(pair => pair.Key).ToList().AsReadOnly(); this.top5Maps = stats.TopMaps.Take(5).Select(pair => pair.Key).ToList().AsReadOnly(); }
public void Recalculated_WithAdditionalMatch() { var stats = new BaseServerStatistics("192.168.0.1-8080", "TestServer"); var updatedStats = stats.RecalculateWithAdditional(match) as BaseServerStatistics; Assert.AreNotEqual(updatedStats, null); updatedStats.TotalMatchesPlayed.ShouldBeEquivalentTo(1); updatedStats.MaximumMatchesPerDay.ShouldBeEquivalentTo(1); updatedStats.TotalMatchesToday.ShouldBeEquivalentTo(1); updatedStats.LastMatchPlayed.ShouldBeEquivalentTo(new DateTime(2017, 01, 01)); updatedStats.FirstMatchPlayed.ShouldBeEquivalentTo(new DateTime(2017, 01, 01)); updatedStats.MaximumPopulation.ShouldBeEquivalentTo(2); updatedStats.TotalPlayersInMatches.ShouldBeEquivalentTo(2); updatedStats.TopGameModes["TestModeA"].ShouldBeEquivalentTo(1); updatedStats.TopMaps["TestMapA"].ShouldBeEquivalentTo(1); }
public override Tuple <int, int> Selector(BaseServerStatistics arg) { int totalDaysCount = Math.Max(arg.LastMatchPlayed.Subtract(arg.FirstMatchPlayed).Days, 1); return(Tuple.Create(totalDaysCount, arg.TotalMatchesPlayed)); }
public override ServerAverageMatchesPerDayRateStat Transformer(BaseServerStatistics arg) { int totalDaysCount = Math.Max(arg.LastMatchPlayed.Subtract(arg.FirstMatchPlayed).Days, 1); return(new ServerAverageMatchesPerDayRateStat(arg.EndPoint, arg.Name, (double)arg.TotalMatchesPlayed / totalDaysCount)); }
public override bool Filter(BaseServerStatistics arg) { return(true); }