コード例 #1
0
        private static void ShowStats(DatabaseRepository repository)
        {
            List <SteamUser> list = repository.Load();

            int playerCount            = list.Count;
            List <SteamUser> vacs      = list.Where(x => x.BanType == BanType.VAC).ToList();
            List <SteamUser> community = list.Where(x => x.BanType == BanType.Community).ToList();
            List <SteamUser> noBans    = list.Where(x => x.BanType == BanType.None).ToList();

            int noBansCount = noBans.Count;
            var newPlayers  = list.Count(x => x.TimePlayed.TotalHours < 15);

            var below30 = list.Count(x => x.TimePlayed.TotalHours < 30);

            Console.WriteLine("Total: {0}", playerCount);
            Console.WriteLine("Average hours: {0}", list.Median(x => x.TimePlayed.TotalHours));
            Percentage.ConsoleWrite("New players", newPlayers, playerCount);
            Percentage.ConsoleWrite("Below 30 hours", below30, playerCount);
            Percentage.ConsoleWrite("No bans", noBansCount, playerCount);

            //
            // VAC bans
            //
            int vacCount    = vacs.Count;
            var vacsBelow30 = vacs.Count(x => x.TimePlayed.TotalHours < 30);

            Percentage.ConsoleWrite("VACS", vacCount, playerCount);
            Console.WriteLine("VAC average hours: {0}", vacs.Median(x => x.TimePlayed.TotalHours));
            Percentage.ConsoleWrite("VAC below 30 hours", vacsBelow30, vacCount);

            //
            // Community
            //
            int communityCount   = community.Count;
            var communityBelow30 = vacs.Count(x => x.TimePlayed.TotalHours < 30);

            Percentage.ConsoleWrite("Community", communityCount, playerCount);
            Console.WriteLine("Community average hours: {0}", community.Median(x => x.TimePlayed.TotalHours));
            Percentage.ConsoleWrite("Community below 30 hours", communityBelow30, communityCount);

            Console.WriteLine("OK Computer?");
            Console.Read();

            return;
        }