Ejemplo n.º 1
0
        /// <summary>
        /// Calcula o WN8 de um conjunto de tanques jogados
        /// </summary>
        /// <param name="played">Dicionário com o ID de cada tanque jogado e seus valores totais</param>
        /// <returns>o WN8</returns>
        public double CalculateWn8(IDictionary <long, TankPlayerWn8Statistics> played)
        {
            if (played == null)
            {
                return(0);
            }

            if (played.Count == 0)
            {
                return(0);
            }

            if ((_values == null) || (_values.Count == 0))
            {
                throw new InvalidOperationException("There are no expected values!");
            }

            double sumPlayedDamage = 0, sumRefDamage = 0;
            double sumPlayedWin = 0, sumRefWin = 0;
            double sumPlayedFrag = 0, sumRefFrag = 0;
            double sumPlayedSpot = 0, sumRefSpot = 0;
            double sumPlayedDef = 0, sumRefDef = 0;

            foreach (var p in played)
            {
                if (_values.TryGetValue(p.Key, out var exp))
                {
                    sumPlayedDamage += p.Value.DamageDealt;
                    sumPlayedWin    += p.Value.Wins;
                    sumPlayedFrag   += p.Value.Kills;
                    sumPlayedSpot   += p.Value.Spotted;
                    sumPlayedDef    += p.Value.DroppedCapturePoints;

                    sumRefDamage += (exp.Damage * p.Value.Battles);
                    sumRefWin    += (exp.WinRate * p.Value.Battles);
                    sumRefFrag   += (exp.Frag * p.Value.Battles);
                    sumRefSpot   += (exp.Spot * p.Value.Battles);
                    sumRefDef    += (exp.Def * p.Value.Battles);
                }
                else
                {
                    Log.Debug($"Played Tank id {p.Key} could not be found on the Expected Values.");
                }
            }

            var relDamage = sumPlayedDamage / sumRefDamage;
            var relWin    = sumPlayedWin / sumRefWin;
            var relFrag   = sumPlayedFrag / sumRefFrag;
            var relSpot   = sumPlayedSpot / sumRefSpot;
            var relDef    = sumPlayedDef / sumRefDef;

            return(Wn8TankExpectedValues.GetWn8FromRelatives(relDamage, relWin, relFrag, relSpot, relDef));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Adiciona uma referência
 /// </summary>
 /// <param name="ev"></param>
 public void Add(Wn8TankExpectedValues ev)
 {
     _values[ev.TankId] = ev;
 }