示例#1
0
        public sealed override object Process(CountParameters parameters, object data)
        {
            if (elementsCache == null || (timeGetter.GetCurrentTime() - lasTimeRecached).TotalMinutes > 1)
            {
                elementsCache = Recache().ToArray(); // Call ToArray to evaluate linq expression

                lasTimeRecached = timeGetter.GetCurrentTime();
            }

            return(elementsCache.Take(parameters.Count));
        }
示例#2
0
        private void UpdatePlayerStatistics(Match match, PlayerScore playerScore, bool isWinner, float scoreboardPercent, DateTime matchTime)
        {
            PlayerStatistics statistics = statisticsTable.GetOne(x => x.LowercaseName == playerScore.Name.ToLower());

            if (statistics != null)
            {
                // Update already existing player stats
                if (isWinner)
                {
                    statistics.TotalMatchesWon++;
                }
                statistics.Kills  += playerScore.Kills;
                statistics.Deaths += playerScore.Deaths;

                if (statistics.TotalMatchesPlayed >= 10 && statistics.Deaths > 0)
                {
                    // If player has less than 10 matches or no deaths, set his
                    // kd to 0, to move him down in ordering by kd
                    statistics.KillToDeathRatio = (float)statistics.Kills / statistics.Deaths;
                }

                statistics.MatchPlayed(match.Server, match.Results.GameMode, scoreboardPercent, matchTime);

                statisticsTable.Update(statistics);
            }
            else
            {
                // It's' first match of this player
                // Create new entry in statistics collection
                statistics = new PlayerStatistics
                {
                    DisplayName      = playerScore.Name,
                    Kills            = playerScore.Kills,
                    Deaths           = playerScore.Deaths,
                    TotalMatchesWon  = isWinner ? 1 : 0,
                    FirstMatchPlayed = timeGetter.GetCurrentTime()
                };


                statistics.MatchPlayed(match.Server, match.Results.GameMode, scoreboardPercent, matchTime);

                statisticsTable.Insert(statistics);
            }
        }
 public void SetRepairDate(Device device, ICurrentTimeGetter currentTime)
 {
     device.RepairDate = currentTime.GetCurrentTime();
 }