/// <summary>
        ///     Initializes a new instance of the <see cref="PlayerStats" /> class.
        /// </summary>
        /// <param name="dataRow">A row of an SQLite query result containing player information.</param>
        /// <param name="tst">The Team Stats dictionary from which to add additional information.</param>
        /// <param name="playoffs">
        ///     if set to <c>true</c>, the row is assumed to contain playoff stats.
        /// </param>
        public PlayerStats(DataRow dataRow, Dictionary<int, TeamStats> tst, bool playoffs = false)
            : this()
        {
            ID = ParseCell.GetInt32(dataRow, "ID");

            if (!playoffs)
            {
                LastName = ParseCell.GetString(dataRow, "LastName");
                FirstName = ParseCell.GetString(dataRow, "FirstName");
                var p1 = ParseCell.GetString(dataRow, "Position1");
                if (String.IsNullOrWhiteSpace(p1))
                {
                    Position1 = Position.None;
                }
                else
                {
                    Position1 = (Position) Enum.Parse(typeof(Position), p1);
                }
                var p2 = ParseCell.GetString(dataRow, "Position2");
                if (String.IsNullOrWhiteSpace(p2))
                {
                    Position2 = Position.None;
                }
                else
                {
                    Position2 = (Position) Enum.Parse(typeof(Position), p2);
                }
                try
                {
                    TeamF = ParseCell.GetInt32(dataRow, "TeamFin");
                    TeamS = ParseCell.GetInt32(dataRow, "TeamSta");
                }
                catch (FormatException)
                {
                    try
                    {
                        TeamF = tst.Single(ts => ts.Value.Name == ParseCell.GetString(dataRow, "TeamFin")).Value.ID;
                    }
                    catch (InvalidOperationException)
                    {
                        TeamF = -1;
                    }
                    try
                    {
                        TeamS = tst.Single(ts => ts.Value.Name == ParseCell.GetString(dataRow, "TeamSta")).Value.ID;
                    }
                    catch (InvalidOperationException)
                    {
                        TeamS = -1;
                    }
                }
                IsSigned = ParseCell.GetBoolean(dataRow, "isActive");

                // Backwards compatibility with databases that didn't have the field
                try
                {
                    IsHidden = ParseCell.GetBoolean(dataRow, "isHidden");
                }
                catch
                {
                    IsHidden = false;
                }

                try
                {
                    YearOfBirth = ParseCell.GetInt32(dataRow, "YearOfBirth");
                }
                catch
                {
                    try
                    {
                        YearOfBirth = Convert.ToInt32(MainWindow.BaseYear) - ParseCell.GetInt32(dataRow, "Age");
                    }
                    catch
                    {
                        YearOfBirth = 0;
                    }
                }

                try
                {
                    YearsPro = ParseCell.GetInt32(dataRow, "YearsPro");
                }
                catch (Exception)
                {
                    YearsPro = 0;
                }
                //

                try
                {
                    var injType = ParseCell.GetInt32(dataRow, "InjuryType");
                    var days = ParseCell.GetInt32(dataRow, "InjuryDaysLeft");
                    Injury = injType != -1
                                 ? new PlayerInjury(injType, days)
                                 : new PlayerInjury(ParseCell.GetString(dataRow, "CustomInjuryName"), days);
                }
                catch
                {
                    Injury = ParseCell.GetBoolean(dataRow, "isInjured") ? new PlayerInjury("Unknown", -1) : new PlayerInjury();
                }

                IsAllStar = ParseCell.GetBoolean(dataRow, "isAllStar");
                IsNBAChampion = ParseCell.GetBoolean(dataRow, "isNBAChampion");
                Contract = new PlayerContract();
                for (var i = 1; i <= 7; i++)
                {
                    int salary;
                    try
                    {
                        salary = ParseCell.GetInt32(dataRow, "ContractY" + i);
                    }
                    catch (ArgumentException)
                    {
                        break;
                    }
                    if (salary == 0)
                    {
                        break;
                    }

                    Contract.ContractSalaryPerYear.Add(salary);
                }
                try
                {
                    Contract.Option =
                        (PlayerContractOption) Enum.Parse(typeof(PlayerContractOption), ParseCell.GetString(dataRow, "ContractOption"));
                }
                catch (ArgumentException)
                {
                    Contract.Option = PlayerContractOption.None;
                }
                try
                {
                    Height = ParseCell.GetFloat(dataRow, "Height");
                    Weight = ParseCell.GetFloat(dataRow, "Weight");
                }
                catch (ArgumentException)
                {
                    Height = 0;
                    Weight = 0;
                }
            }

            GetStatsFromDataRow(dataRow, playoffs);
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="PlayerStats" /> class.
        /// </summary>
        public PlayerStats()
        {
            for (var i = 0; i < Totals.Length; i++)
            {
                Totals[i] = 0;
            }

            for (var i = 0; i < PerGame.Length; i++)
            {
                PerGame[i] = 0;
            }

            for (var i = 0; i < PlTotals.Length; i++)
            {
                PlTotals[i] = 0;
            }

            for (var i = 0; i < PlPerGame.Length; i++)
            {
                PlPerGame[i] = 0;
            }

            for (var i = 0; i < CareerHighs.Length; i++)
            {
                CareerHighs[i] = 0;
            }

            Contract = new PlayerContract();
            IsSigned = false;
            IsHidden = false;
            Injury = new PlayerInjury();
            IsAllStar = false;
            IsNBAChampion = false;
            YearOfBirth = 0;
            YearsPro = 0;
            Height = 0;
            Weight = 0;
            TeamF = -1;
            TeamS = -1;

            Metrics = new Dictionary<string, double>(PlayerStatsHelper.MetricsDict);
            PlMetrics = new Dictionary<string, double>(Metrics);
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="PlayerStats" /> class.
        /// </summary>
        public PlayerStats()
        {
            for (int i = 0; i < Totals.Length; i++)
            {
                Totals[i] = 0;
            }

            for (int i = 0; i < PerGame.Length; i++)
            {
                PerGame[i] = 0;
            }

            for (int i = 0; i < PlTotals.Length; i++)
            {
                PlTotals[i] = 0;
            }

            for (int i = 0; i < PlPerGame.Length; i++)
            {
                PlPerGame[i] = 0;
            }

            for (int i = 0; i < CareerHighs.Length; i++)
            {
                CareerHighs[i] = 0;
            }

            Contract = new PlayerContract();
            IsActive = false;
            IsHidden = false;
            Injury = new PlayerInjury();
            IsAllStar = false;
            IsNBAChampion = false;
            YearOfBirth = 0;
            YearsPro = 0;
            Height = 0;
            Weight = 0;
            TeamF = -1;
            TeamS = -1;

            Metrics = new Dictionary<string, double>(PAbbr.MetricsDict);
            PlMetrics = new Dictionary<string, double>(Metrics);
            /*
            var metricsNames = PAbbr.MetricsNames;
            for (int i = 0; i < metricsNames.Count; i++)
            {
                var name = metricsNames[i];
                Metrics.Add(name, double.NaN);
                PlMetrics.Add(name, double.NaN);
            }
            */
            /*
            PAbbr.MetricsNames.ForEach(name =>
                                       {
                                           Metrics.Add(name, double.NaN);
                                           PlMetrics.Add(name, double.NaN);
                                       });
            */
        }