/// <summary>
 /// Обновляет топ-5 самых используемых игровых режимов
 /// </summary>
 /// <param name="info">Информация о матче</param>
 /// <param name="stats">Статистика сервера</param>
 /// <returns>Новый список топ-5</returns>
 private List <string> GetTop5Modes(MatchInfo info, ServerStats stats)
 {
     return(Top5GameModes.ToList().UpdateTop(5,
                                             m => stats.GameModeFrequency[m],
                                             m => m,
                                             info.GameMode).ToList());
 }
Exemplo n.º 2
0
 protected bool Equals(ServerStat other)
 {
     return(TotalMatchesPlayed == other.TotalMatchesPlayed &&
            MaximumMatchesPerDay == other.MaximumMatchesPerDay &&
            AverageMatchesPerDay == other.AverageMatchesPerDay &&
            MaximumPopulation == other.MaximumPopulation &&
            AveragePopulation == other.AveragePopulation &&
            (Top5GameModes?.SequenceEqual(other.Top5GameModes) ?? false) &&
            (Top5Maps?.SequenceEqual(other.Top5Maps) ?? false));
 }
Exemplo n.º 3
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = TotalMatchesPlayed;
         hashCode = (hashCode * 397) ^ MaximumMatchesPerDay;
         hashCode = (hashCode * 397) ^ AverageMatchesPerDay.GetHashCode();
         hashCode = (hashCode * 397) ^ MaximumPopulation;
         hashCode = (hashCode * 397) ^ AveragePopulation.GetHashCode();
         hashCode = (hashCode * 397) ^ (Top5GameModes?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Top5Maps?.GetHashCode() ?? 0);
         return(hashCode);
     }
 }
Exemplo n.º 4
0
        public void CorrectlyCalculateTop5GameModes_WhenAdded()
        {
            var matchData = new MatchData("localhost-8081", _dateTime2,
                                          JsonConvert.DeserializeObject <MatchInfo>(_matchInfo2));
            var stat = new Top5GameModes();

            for (var i = 0; i < 7; i++)
            {
                for (var j = i; j < 7; j++)
                {
                    matchData.Results.GameMode = j.ToString();
                    stat.Add(matchData, "player1");
                }
            }
            stat.Get(_dict);
            Assert.AreEqual((string)_dict["top5GameModes"], "[\"6\",\"5\",\"4\",\"3\",\"2\"]");
        }