示例#1
0
        /// <summary>
        /// Calculate performance metrics on the player
        /// </summary>
        /// <param name="wn8ExpectedValues"></param>
        public void CalculatePerformance(Wn8ExpectedValues wn8ExpectedValues)
        {
            if (Tanks.Length == 0)
            {
                return;
            }

            // Only tanks that I know about
            Tanks = Tanks.Where(t => wn8ExpectedValues.Exists(t.TankId) && t.All.Battles > 0).ToArray();

            if (Tanks.Length == 0)
            {
                return;
            }

            Battles = Tanks.Sum(t => t.All.Battles);
            WinRate = Tanks.Sum(t => t.All.Wins) * 1.0 / Battles;
            AvgTier = Tanks.Sum(t => wn8ExpectedValues[t.TankId].Tier * t.All.Battles) * 1.0 / Battles;
            Wn8     = wn8ExpectedValues.CalculateWn8(Tanks.ToDictionary(t => t.TankId, t => (TankPlayerWn8Statistics)t.All));

            Tier10Tanks = Tanks.Where(t => wn8ExpectedValues[t.TankId].Tier == 10).ToArray();

            if (Tier10Tanks.Length == 0)
            {
                return;
            }

            Tier10Battles      = Tier10Tanks.Sum(t => t.All.Battles);
            Tier10WinRate      = Tier10Tanks.Sum(t => t.All.Wins) * 1.0 / Tier10Battles;
            Tier10Wn8          = wn8ExpectedValues.CalculateWn8(Tier10Tanks.ToDictionary(t => t.TankId, t => (TankPlayerWn8Statistics)t.All));
            Tier10DirectDamage = Tier10Tanks.Sum(t => t.All.DamageDealt) * 1.0 / Tier10Battles;
        }
示例#2
0
        private static void TestWN8Calculation()
        {
            string            connectionString = ConfigurationManager.ConnectionStrings["Main"].ConnectionString;
            DbProvider        provider         = new DbProvider(connectionString);
            Wn8ExpectedValues expected         = provider.GetWn8ExpectedValues(Platform.XBOX);

            Dictionary <long, TankPlayerStatistics> fakePlayed = new Dictionary <long, TankPlayerStatistics>();

            foreach (Wn8TankExpectedValues e in expected.AllTanks)
            {
                fakePlayed.Add(e.TankId,
                               new TankPlayerStatistics
                {
                    Battles              = 100000,
                    DamageDealt          = (long)(e.Damage * 100000),
                    Wins                 = (long)(e.WinRate * 100000),
                    Kills                = (long)(e.Frag * 100000),
                    Spotted              = (long)(e.Spot * 100000),
                    DroppedCapturePoints = (long)(e.Def * 100000)
                });
            }

            // Teste do geral
            double wn8 = expected.CalculateWn8(fakePlayed);

            Log.Info($"WN8 de Referência: {wn8} - Deve ser proximo de 1565");

            // Teste de um jogador (eu!)
            Stopwatch sw = Stopwatch.StartNew();
            Player    p  = provider.GetPlayer(1763298, true);

            p.Calculate(expected);
            sw.Stop();
            Log.Info($"All:   {p.TotalWn8:N0} on {p.TotalBattles:N0} @ {p.TotalWinRate:P2} on Tier {p.TotalTier:N1}");
            Log.Info($"Month: {p.MonthWn8:N0} on {p.MonthBattles:N0} @ {p.MonthWinRate:P2} on Tier {p.MonthTier:N1}");
            Log.Info($"Week:  {p.WeekWn8:N0} on {p.WeekBattles:N0} @ {p.WeekWinRate:P2} on Tier {p.WeekTier:N1}");
            Log.Debug($"In {sw.Elapsed.TotalMilliseconds:N0}ms");

            foreach (KeyValuePair <long, TankPlayerStatistics> t in p.Performance.Month)
            {
                Wn8TankExpectedValues td = expected[t.Key];
                if (td.Tier < 10)
                {
                    continue;
                }

                Log.Debug($"{td.Name}: {t.Value.Wn8:N0}");
            }

            // Teste de dano esperado para um tanque qualquer (T110E5)
            sw = Stopwatch.StartNew();
            Wn8TankExpectedValues te = expected[10785];
            double damageAverage     = te.GetTargetDamage(Wn8Rating.Average);
            double damageGood        = te.GetTargetDamage(Wn8Rating.Good);
            double damageGreat       = te.GetTargetDamage(Wn8Rating.Great);
            double damageUnicum      = te.GetTargetDamage(Wn8Rating.Unicum);

            sw.Stop();
            Log.Debug($"Target Damages em {sw.Elapsed.TotalMilliseconds:N1}ms: {damageAverage:N0}; {damageGood:N0}; {damageGreat:N0}; {damageUnicum:N0}");
        }