Пример #1
0
        /// <summary>
        /// Computes ranking points (and editions played count) for every players at a specified date.
        /// </summary>
        /// <param name="startDate">Ranking date.</param>
        /// <param name="cachePlayerEditionPoints">Cache of player / edition / point.</param>
        /// <returns>Points and editions played count, by player.</returns>
        internal Dictionary <PlayerPivot, Tuple <uint, uint> > ComputePointsForPlayersInvolvedAtDate(DateTime startDate,
                                                                                                     Dictionary <KeyValuePair <PlayerPivot, EditionPivot>, uint> cachePlayerEditionPoints)
        {
            // Collection of players to insert for the current week.
            // Key is the player, Value is number of points and editions played count.
            var playersRankedThisWeek = new Dictionary <PlayerPivot, Tuple <uint, uint> >();

            // Editions in one year rolling to the current date.
            var editionsRollingYear = EditionPivot.EditionsForRankingAtDate(this, startDate,
                                                                            out List <PlayerPivot> playersInvolved).ToList();

            // Computes infos for each player involved at the current date.
            foreach (var player in playersInvolved)
            {
                var pointsAndCount = ComputePointsAndCountForPlayer(player, editionsRollingYear, cachePlayerEditionPoints);

                playersRankedThisWeek.Add(player, pointsAndCount);
            }

            // Sorts each player by descending points.
            // Then by editions played count (the fewer the better).
            playersRankedThisWeek =
                playersRankedThisWeek
                .OrderByDescending(me => me.Value.Item1)
                .ThenBy(me => me.Value.Item2)
                .ToDictionary(me => me.Key, me => me.Value);

            return(playersRankedThisWeek);
        }
Пример #2
0
 /// <summary>
 /// Debugs ranking calculation for a specified player at specified date.
 /// </summary>
 /// <param name="player"><see cref="PlayerPivot"/></param>
 /// <param name="dateEnd">Ranking date to debug.</param>
 /// <returns>Points count and editions played count.</returns>
 internal Tuple <uint, uint> DebugRankingForPlayer(PlayerPivot player, DateTime dateEnd)
 {
     return(ComputePointsAndCountForPlayer(player,
                                           EditionPivot.EditionsForRankingAtDate(this, dateEnd, out List <PlayerPivot> playersInvolved).ToList(),
                                           new Dictionary <KeyValuePair <PlayerPivot, EditionPivot>, uint>()));
 }