예제 #1
0
        public static PlayerRankings CalculateAllRankings(bool playoffs = false)
        {
            var cumRankingsAll =
                new PlayerRankings(MainWindow.PST.Where(ps => !ps.Value.IsHidden).ToDictionary(r => r.Key, r => r.Value), playoffs);

            return(cumRankingsAll);
        }
예제 #2
0
        public static PlayerRankings CalculateActiveRankings(bool playoffs = false)
        {
            var cumRankingsActive =
                new PlayerRankings(MainWindow.PST.Where(ps => ps.Value.IsSigned).ToDictionary(r => r.Key, r => r.Value), playoffs);

            return(cumRankingsActive);
        }
예제 #3
0
 public DBData(
     Dictionary<int, TeamStats> tst,
     Dictionary<int, TeamStats> tstOpp,
     Dictionary<int, Dictionary<string, TeamStats>> splitTeamStats,
     TeamRankings seasonTeamRankings,
     TeamRankings playoffTeamRankings,
     Dictionary<int, PlayerStats> pst,
     Dictionary<int, Dictionary<string, PlayerStats>> splitPlayerStats,
     PlayerRankings seasonPlayerRankings,
     PlayerRankings playoffPlayerRankings,
     List<BoxScoreEntry> bsHist,
     Dictionary<int, string> displayNames)
 {
     BSHist = bsHist;
     DisplayNames = displayNames;
     PST = pst;
     SeasonPlayerRankings = seasonPlayerRankings;
     PlayoffPlayerRankings = playoffPlayerRankings;
     PlayoffTeamRankings = playoffTeamRankings;
     SplitPlayerStats = splitPlayerStats;
     SplitTeamStats = splitTeamStats;
     TST = tst;
     TSTOpp = tstOpp;
     SeasonTeamRankings = seasonTeamRankings;
 }
예제 #4
0
 public DBData()
 {
     BSHist = new List<BoxScoreEntry>();
     DisplayNames = new Dictionary<int, string>();
     PST = new Dictionary<int, PlayerStats>();
     SeasonPlayerRankings = new PlayerRankings();
     PlayoffPlayerRankings = new PlayerRankings();
     PlayoffTeamRankings = new TeamRankings();
     SplitPlayerStats = new Dictionary<int, Dictionary<string, PlayerStats>>();
     SplitTeamStats = new Dictionary<int, Dictionary<string, TeamStats>>();
     TST = new Dictionary<int, TeamStats>();
     TSTOpp = new Dictionary<int, TeamStats>();
     SeasonTeamRankings = new TeamRankings();
 }
예제 #5
0
        public static PlayerRankings CalculateLeadersRankings(out Dictionary <int, PlayerStats> pstLeaders, bool playoffs = false)
        {
            var pstActive  = MainWindow.PST.Where(ps => ps.Value.IsSigned).ToDictionary(ps => ps.Key, ps => ps.Value);
            var listOfKeys = pstActive.Keys.ToList();

            foreach (var key in listOfKeys)
            {
                pstActive[key] = MainWindow.LeadersPrefSetting == "NBA"
                                     ? pstActive[key].ConvertToLeagueLeader(MainWindow.TST, playoffs)
                                     : pstActive[key].ConvertToMyLeagueLeader(MainWindow.TST, playoffs);
            }
            var cumRankingsActive = new PlayerRankings(pstActive, playoffs);

            pstLeaders = pstActive;
            return(cumRankingsActive);
        }
 public static PlayerRankings CalculateLeadersRankings(out Dictionary<int, PlayerStats> pstLeaders, bool playoffs = false)
 {
     Dictionary<int, PlayerStats> pstActive = MainWindow.PST.Where(ps => ps.Value.IsActive)
                                                        .ToDictionary(ps => ps.Key, ps => ps.Value);
     List<int> listOfKeys = pstActive.Keys.ToList();
     foreach (int key in listOfKeys)
     {
         pstActive[key] = MainWindow.LeadersPrefSetting == "NBA"
                              ? pstActive[key].ConvertToLeagueLeader(MainWindow.TST, playoffs)
                              : pstActive[key].ConvertToMyLeagueLeader(MainWindow.TST, playoffs);
     }
     var cumRankingsActive = new PlayerRankings(pstActive, playoffs);
     pstLeaders = pstActive;
     return cumRankingsActive;
 }
 public static PlayerRankings CalculateActiveRankings(bool playoffs = false)
 {
     var cumRankingsActive =
         new PlayerRankings(MainWindow.PST.Where(ps => ps.Value.IsActive).ToDictionary(r => r.Key, r => r.Value), playoffs);
     return cumRankingsActive;
 }
예제 #8
0
 public static PlayerRankings CalculateAllRankings(bool playoffs = false)
 {
     var cumRankingsAll =
         new PlayerRankings(MainWindow.PST.Where(ps => !ps.Value.IsHidden).ToDictionary(r => r.Key, r => r.Value), playoffs);
     return cumRankingsAll;
 }
        /// <summary>
        ///     Gets a player stats dictionary of only the active players, and calculates their rankingsPerGame.
        /// </summary>
        private void getActivePlayers()
        {
            _playersActive = new Dictionary<int, PlayerStats>();

            string q = "select * from " + _playersT + " where isActive LIKE \"True\"";
            q += " AND isHidden LIKE \"False\"";
            DataTable res = _db.GetDataTable(q);
            foreach (DataRow r in res.Rows)
            {
                string q2 = "select * from " + _plPlayersT + " where ID = " + ParseCell.GetInt32(r, "ID");
                DataTable plRes = _db.GetDataTable(q2);

                var ps = new PlayerStats(r, MainWindow.TST);
                _playersActive.Add(ps.ID, ps);
                _playersActive[ps.ID].UpdatePlayoffStats(plRes.Rows[0]);
            }

            _rankingsActive = new PlayerRankings(_playersActive);
            _plRankingsActive = new PlayerRankings(_playersActive, true);
        }
예제 #10
0
        private static void updateNotables()
        {
            Dictionary<int, PlayerStats> pstLeaders;
            SeasonLeadersRankings = PlayerRankings.CalculateLeadersRankings(out pstLeaders);
            _notables = new List<string>();

            Dictionary<int, PlayerStats> temp;
            PlayoffsLeadersRankings = PlayerRankings.CalculateLeadersRankings(out temp, true);

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

            var leadersPSRList = new List<PlayerStatsRow>();
            pstLeaders.Values.ToList().ForEach(
                delegate(PlayerStats ps)
                    {
                        var psr = new PlayerStatsRow(ps, calcRatings: false);
                        leadersPSRList.Add(psr);
                    });
            var psrList = new Dictionary<int, PlayerStatsRow>();
            PST.Values.ToList().ForEach(
                delegate(PlayerStats ps)
                    {
                        var psr = new PlayerStatsRow(ps, calcRatings: false);
                        psrList.Add(psr.ID, psr);
                    });

            //PlayerStatsRow curL = psrList.Single(psr => psr.ID == leadersPSRList.OrderByDescending(pair => pair.PPG).First().ID);
            PlayerStatsRow curL;
            string m, s;
            float ppg;
            try
            {
                curL = psrList[SeasonLeadersRankings.RevRankingsPerGame[PAbbrPG.PPG][1]];

                m = getBestStatsForMarquee(curL, SeasonLeadersRankings, 3, PAbbrPG.PPG);
                s = String.Format(
                    "PPG Leader: {0} {1} ({2}) ({3:F1} PPG, {4})",
                    curL.FirstName,
                    curL.LastName,
                    TST[curL.TeamF].DisplayName,
                    curL.PPG,
                    m);
                _notables.Add(s);
            }
            catch (KeyNotFoundException e)
            {
                Console.WriteLine(e);
            }

            //curL = psrList.Single(psr => psr.ID == leadersPSRList.OrderByDescending(pair => pair.FGp).First().ID);
            try
            {
                curL = psrList[SeasonLeadersRankings.RevRankingsPerGame[PAbbrPG.FGp][1]];
                ppg = double.IsNaN(curL.PPG) ? PST[curL.ID].PerGame[PAbbrPG.PPG] : curL.PPG;

                m = getBestStatsForMarquee(curL, SeasonLeadersRankings, 2, PAbbrPG.FGp);
                s = String.Format(
                    "FG% Leader: {0} {1} ({2}) ({3:F3} FG%, {5:F1} PPG, {4})",
                    curL.FirstName,
                    curL.LastName,
                    TST[curL.TeamF].DisplayName,
                    curL.FGp,
                    m,
                    ppg);
                _notables.Add(s);
            }
            catch (KeyNotFoundException e)
            {
                Console.WriteLine(e);
            }

            //curL = psrList.Single(psr => psr.ID == leadersPSRList.OrderByDescending(pair => pair.RPG).First().ID);
            try
            {
                curL = psrList[SeasonLeadersRankings.RevRankingsPerGame[PAbbrPG.RPG][1]];
                ppg = double.IsNaN(curL.PPG) ? PST[curL.ID].PerGame[PAbbrPG.PPG] : curL.PPG;

                m = getBestStatsForMarquee(curL, SeasonLeadersRankings, 2, PAbbrPG.RPG);
                s = String.Format(
                    "RPG Leader: {0} {1} ({2}) ({3:F1} RPG, {5:F1} PPG, {4})",
                    curL.FirstName,
                    curL.LastName,
                    TST[curL.TeamF].DisplayName,
                    curL.RPG,
                    m,
                    ppg);
                _notables.Add(s);
            }
            catch (KeyNotFoundException e)
            {
                Console.WriteLine(e);
            }

            //curL = psrList.Single(psr => psr.ID == leadersPSRList.OrderByDescending(pair => pair.BPG).First().ID);
            try
            {
                curL = psrList[SeasonLeadersRankings.RevRankingsPerGame[PAbbrPG.BPG][1]];
                ppg = double.IsNaN(curL.PPG) ? PST[curL.ID].PerGame[PAbbrPG.PPG] : curL.PPG;

                m = getBestStatsForMarquee(curL, SeasonLeadersRankings, 2, PAbbrPG.BPG);
                s = String.Format(
                    "BPG Leader: {0} {1} ({2}) ({3:F1} BPG, {5:F1} PPG, {4})",
                    curL.FirstName,
                    curL.LastName,
                    TST[curL.TeamF].DisplayName,
                    curL.BPG,
                    m,
                    ppg);
                _notables.Add(s);
            }
            catch (KeyNotFoundException e)
            {
                Console.WriteLine(e);
            }

            //curL = psrList.Single(psr => psr.ID == leadersPSRList.OrderByDescending(pair => pair.APG).First().ID);
            try
            {
                curL = psrList[SeasonLeadersRankings.RevRankingsPerGame[PAbbrPG.APG][1]];
                ppg = double.IsNaN(curL.PPG) ? PST[curL.ID].PerGame[PAbbrPG.PPG] : curL.PPG;

                m = getBestStatsForMarquee(curL, SeasonLeadersRankings, 2, PAbbrPG.APG);
                s = String.Format(
                    "APG Leader: {0} {1} ({2}) ({3:F1} APG, {5:F1} PPG, {4})",
                    curL.FirstName,
                    curL.LastName,
                    TST[curL.TeamF].DisplayName,
                    curL.APG,
                    m,
                    ppg);
                _notables.Add(s);
            }
            catch (KeyNotFoundException e)
            {
                Console.WriteLine(e);
            }

            //curL = psrList.Single(psr => psr.ID == leadersPSRList.OrderByDescending(pair => pair.SPG).First().ID);
            try
            {
                curL = psrList[SeasonLeadersRankings.RevRankingsPerGame[PAbbrPG.SPG][1]];
                ppg = double.IsNaN(curL.PPG) ? PST[curL.ID].PerGame[PAbbrPG.PPG] : curL.PPG;

                m = getBestStatsForMarquee(curL, SeasonLeadersRankings, 2, PAbbrPG.SPG);
                s = String.Format(
                    "SPG Leader: {0} {1} ({2}) ({3:F1} SPG, {5:F1} PPG, {4})",
                    curL.FirstName,
                    curL.LastName,
                    TST[curL.TeamF].DisplayName,
                    curL.SPG,
                    m,
                    ppg);
                _notables.Add(s);
            }
            catch (KeyNotFoundException e)
            {
                Console.WriteLine(e);
            }

            //curL = psrList.Single(psr => psr.ID == leadersPSRList.OrderByDescending(pair => pair.ORPG).First().ID);
            try
            {
                curL = psrList[SeasonLeadersRankings.RevRankingsPerGame[PAbbrPG.ORPG][1]];
                ppg = double.IsNaN(curL.PPG) ? PST[curL.ID].PerGame[PAbbrPG.PPG] : curL.PPG;

                m = getBestStatsForMarquee(curL, SeasonLeadersRankings, 2, PAbbrPG.ORPG);
                s = String.Format(
                    "ORPG Leader: {0} {1} ({2}) ({3:F1} ORPG, {5:F1} PPG, {4})",
                    curL.FirstName,
                    curL.LastName,
                    TST[curL.TeamF].DisplayName,
                    curL.ORPG,
                    m,
                    ppg);
                _notables.Add(s);
            }
            catch (KeyNotFoundException e)
            {
                Console.WriteLine(e);
            }

            //curL = psrList.Single(psr => psr.ID == leadersPSRList.OrderByDescending(pair => pair.DRPG).First().ID);
            try
            {
                curL = psrList[SeasonLeadersRankings.RevRankingsPerGame[PAbbrPG.DRPG][1]];
                ppg = double.IsNaN(curL.PPG) ? PST[curL.ID].PerGame[PAbbrPG.PPG] : curL.PPG;

                m = getBestStatsForMarquee(curL, SeasonLeadersRankings, 2, PAbbrPG.DRPG);
                s = String.Format(
                    "DRPG Leader: {0} {1} ({2}) ({3:F1} DRPG, {5:F1} PPG, {4})",
                    curL.FirstName,
                    curL.LastName,
                    TST[curL.TeamF].DisplayName,
                    curL.DRPG,
                    m,
                    ppg);
                _notables.Add(s);
            }
            catch (KeyNotFoundException e)
            {
                Console.WriteLine(e);
            }

            //curL = psrList.Single(psr => psr.ID == leadersPSRList.OrderByDescending(pair => pair.TPp).First().ID);
            try
            {
                curL = psrList[SeasonLeadersRankings.RevRankingsPerGame[PAbbrPG.TPp][1]];
                ppg = double.IsNaN(curL.PPG) ? PST[curL.ID].PerGame[PAbbrPG.PPG] : curL.PPG;

                m = getBestStatsForMarquee(curL, SeasonLeadersRankings, 2, PAbbrPG.TPp);
                s = String.Format(
                    "3P% Leader: {0} {1} ({2}) ({3:F3} 3P%, {5:F1} PPG, {4})",
                    curL.FirstName,
                    curL.LastName,
                    TST[curL.TeamF].DisplayName,
                    curL.TPp,
                    m,
                    ppg);
                _notables.Add(s);
            }
            catch (KeyNotFoundException e)
            {
                Console.WriteLine(e);
            }

            //curL = psrList.Single(psr => psr.ID == leadersPSRList.OrderByDescending(pair => pair.FTp).First().ID);
            try
            {
                curL = psrList[SeasonLeadersRankings.RevRankingsPerGame[PAbbrPG.FTp][1]];
                ppg = double.IsNaN(curL.PPG) ? PST[curL.ID].PerGame[PAbbrPG.PPG] : curL.PPG;

                m = getBestStatsForMarquee(curL, SeasonLeadersRankings, 2, PAbbrPG.FTp);
                s = String.Format(
                    "FT% Leader: {0} {1} ({2}) ({3:F3} FT%, {5:F1} PPG, {4})",
                    curL.FirstName,
                    curL.LastName,
                    TST[curL.TeamF].DisplayName,
                    curL.FTp,
                    m,
                    ppg);
                _notables.Add(s);
            }
            catch (KeyNotFoundException e)
            {
                Console.WriteLine(e);
            }

            if (_notables.Count > 0)
            {
                _notables.Shuffle();

                MWInstance.txbMarquee.Text = "League Notables";
                MWInstance._marqueeTimer.Start();
            }
        }
        /// <summary>
        ///     Handles the SelectionChanged event of the cmbTeam control.
        ///     Populates the player combo, resets all relevant DataGrid DataContext and ItemsSource properties, and calculates the in-team player rankingsPerGame.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">
        ///     The <see cref="SelectionChangedEventArgs" /> instance containing the event data.
        /// </param>
        private void cmbTeam_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            dgvOverviewStats.DataContext = null;
            grdOverview.DataContext = null;
            cmbPosition1.SelectedIndex = -1;
            cmbPosition2.SelectedIndex = -1;
            dgvBoxScores.ItemsSource = null;
            dgvHTH.ItemsSource = null;
            dgvHTHBoxScores.ItemsSource = null;
            dgvSplitStats.ItemsSource = null;
            dgvYearly.ItemsSource = null;
            grpPlayoffsFacts.Visibility = Visibility.Collapsed;
            grpPlayoffsLeadersFacts.Visibility = Visibility.Collapsed;
            grpPlayoffsScoutingReport.Visibility = Visibility.Collapsed;
            grpSeasonFacts.Visibility = Visibility.Collapsed;
            grpSeasonLeadersFacts.Visibility = Visibility.Collapsed;
            grpSeasonScoutingReport.Visibility = Visibility.Collapsed;

            if (cmbTeam.SelectedIndex == -1)
            {
                return;
            }

            cmbPlayer.ItemsSource = null;

            playersList = new ObservableCollection<KeyValuePair<int, string>>();
            _playersSameTeam = new Dictionary<int, PlayerStats>();
            if (cmbTeam.SelectedItem.ToString() != "- Inactive -")
            {
                List<PlayerStats> list =
                    MainWindow.PST.Values.Where(
                        ps => ps.TeamF == GetTeamIDFromDisplayName(cmbTeam.SelectedItem.ToString()) && !ps.IsHidden && ps.IsActive)
                              .ToList();
                list.Sort((ps1, ps2) => ps1.LastName.CompareTo(ps2.LastName));
                list.ForEach(delegate(PlayerStats ps)
                    {
                        playersList.Add(new KeyValuePair<int, string>(ps.ID,
                                                                      String.Format("{0}, {1} ({2})", ps.LastName, ps.FirstName,
                                                                                    ps.Position1.ToString())));
                        _playersSameTeam.Add(ps.ID, ps);
                    });
            }
            else
            {
                List<PlayerStats> list = MainWindow.PST.Values.Where(ps => !ps.IsHidden && !ps.IsActive).ToList();
                list.Sort((ps1, ps2) => ps1.LastName.CompareTo(ps2.LastName));
                list.ForEach(delegate(PlayerStats ps)
                    {
                        playersList.Add(new KeyValuePair<int, string>(ps.ID,
                                                                      String.Format("{0}, {1} ({2})", ps.LastName, ps.FirstName,
                                                                                    ps.Position1.ToString())));
                        _playersSameTeam.Add(ps.ID, ps);
                    });
            }
            _rankingsTeam = new PlayerRankings(_playersSameTeam);
            _plRankingsTeam = new PlayerRankings(_playersSameTeam, true);

            cmbPlayer.ItemsSource = playersList;
        }
        /// <summary>
        ///     Handles the SelectionChanged event of the cmbPlayer control.
        ///     Updates the PlayerStatsRow instance and all DataGrid controls with this player's information and stats.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">
        ///     The <see cref="SelectionChangedEventArgs" /> instance containing the event data.
        /// </param>
        private void cmbPlayer_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (cmbPlayer.SelectedIndex == -1)
            {
                return;
            }

            _selectedPlayerID = ((KeyValuePair<int, string>) (((cmbPlayer)).SelectedItem)).Key;

            _pbsList = new ObservableCollection<PlayerBoxScore>();

            try
            {
                _psr = new PlayerStatsRow(MainWindow.PST[_selectedPlayerID]);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Player with ID " + _selectedPlayerID + " couldn't be loaded: " + ex.Message);
                cmbPlayer.SelectedIndex = -1;
                return;
            }
            _plPSR = new PlayerStatsRow(MainWindow.PST[_selectedPlayerID], true);

            updateOverviewAndBoxScores();

            updateSplitStats();

            updateYearlyReport();

            _cumSeasonRankingsActive = PlayerRankings.CalculateActiveRankings();
            _cumSeasonRankingsPosition =
                new PlayerRankings(MainWindow.PST.Where(ps => ps.Value.Position1 == _psr.Position1)
                                             .ToDictionary(r => r.Key, r => r.Value));
            _cumSeasonRankingsTeam =
                new PlayerRankings(MainWindow.PST.Where(ps => ps.Value.TeamF == _psr.TeamF).ToDictionary(r => r.Key, r => r.Value));

            _cumPlayoffsRankingsActive = PlayerRankings.CalculateActiveRankings(true);
            _cumPlayoffsRankingsPosition =
                new PlayerRankings(
                    MainWindow.PST.Where(ps => ps.Value.Position1 == _psr.Position1).ToDictionary(r => r.Key, r => r.Value), true);
            _cumPlayoffsRankingsTeam =
                new PlayerRankings(MainWindow.PST.Where(ps => ps.Value.TeamF == _psr.TeamF).ToDictionary(r => r.Key, r => r.Value),
                                   true);

            updateScoutingReport();

            updateRecords();

            cmbOppPlayer_SelectionChanged(null, null);

            if (cmbGraphStat.SelectedIndex == -1)
            {
                cmbGraphStat.SelectedIndex = 0;
            }
        }
        /// <summary>
        ///     Handles the Click event of the btnScoutingReport control.
        ///     Displays a quick overview of the player's performance in a natural language scouting report.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">
        ///     The <see cref="RoutedEventArgs" /> instance containing the event data.
        /// </param>
        private void btnScoutingReport_Click(object sender, RoutedEventArgs e)
        {
            if (cmbPlayer.SelectedIndex == -1)
            {
                return;
            }

            var temppst = new Dictionary<int, PlayerStats>();
            foreach (var kvp in MainWindow.PST)
            {
                int i = kvp.Key;
                temppst.Add(i, kvp.Value.DeepClone());
                temppst[i].ResetStats();
                temppst[i].AddPlayerStats(MainWindow.PST[i], true);
            }

            PlayerRankings cumRankingsActive = PlayerRankings.CalculateActiveRankings();
            var cumRankingsPosition =
                new PlayerRankings(MainWindow.PST.Where(ps => ps.Value.Position1 == _psr.Position1)
                                             .ToDictionary(r => r.Key, r => r.Value));
            var cumRankingsTeam =
                new PlayerRankings(MainWindow.PST.Where(ps => ps.Value.TeamF == _psr.TeamF).ToDictionary(r => r.Key, r => r.Value));

            new PlayerStatsRow(temppst[_psr.ID]).ScoutingReport(MainWindow.PST, cumRankingsActive, cumRankingsTeam, cumRankingsPosition,
                                                                _pbsList.ToList(), txbGame1.Text);
        }
        /// <summary>
        ///     Updates the overview tab and prepares the available box scores for the current timeframe.
        /// </summary>
        private void updateOverviewAndBoxScores()
        {
            TeamStats ts = _psr.IsActive ? MainWindow.TST[_psr.TeamF] : new TeamStats();
            var tsopp = new TeamStats(ts.ID, "Opponents");

            grdOverview.DataContext = _psr;

            _playersSamePosition =
                MainWindow.PST.Where(ps => ps.Value.Position1 == _psr.Position1 && ps.Value.IsActive)
                          .ToDictionary(ps => ps.Value.ID, ps => ps.Value);

            _rankingsPosition = new PlayerRankings(_playersSamePosition);
            _plRankingsPosition = new PlayerRankings(_playersSamePosition, true);

            foreach (
                BoxScoreEntry bse in
                    MainWindow.BSHist.Where(bse => bse.PBSList.Any(pbs => pbs.PlayerID == _psr.ID && !pbs.IsOut)).ToList())
            {
                var pbs = new PlayerBoxScore();
                pbs = bse.PBSList.Single(pbs1 => pbs1.PlayerID == _psr.ID);
                pbs.AddInfoFromTeamBoxScore(bse.BS, MainWindow.TST);
                pbs.CalcMetrics(bse.BS);
                _pbsList.Add(pbs);
            }

            cmbPosition1.SelectedItem = _psr.Position1.ToString();
            cmbPosition2.SelectedItem = _psr.Position2.ToString();

            _dtOv.Clear();

            DataRow dr = _dtOv.NewRow();

            dr["Type"] = "Stats";
            dr["GP"] = _psr.GP.ToString();
            dr["GS"] = _psr.GS.ToString();
            dr["MINS"] = _psr.MINS.ToString();
            dr["PTS"] = _psr.PTS.ToString();
            dr["FG"] = _psr.FGM.ToString() + "-" + _psr.FGA.ToString();
            dr["3PT"] = _psr.TPM.ToString() + "-" + _psr.TPA.ToString();
            dr["FT"] = _psr.FTM.ToString() + "-" + _psr.FTA.ToString();
            dr["REB"] = (_psr.DREB + _psr.OREB).ToString();
            dr["OREB"] = _psr.OREB.ToString();
            dr["DREB"] = _psr.DREB.ToString();
            dr["AST"] = _psr.AST.ToString();
            dr["TO"] = _psr.TOS.ToString();
            dr["STL"] = _psr.STL.ToString();
            dr["BLK"] = _psr.BLK.ToString();
            dr["FOUL"] = _psr.FOUL.ToString();

            _dtOv.Rows.Add(dr);

            dr = _dtOv.NewRow();

            dr["Type"] = "Averages";
            dr["MINS"] = String.Format("{0:F1}", _psr.MPG);
            dr["PTS"] = String.Format("{0:F1}", _psr.PPG);
            dr["FG"] = String.Format("{0:F3}", _psr.FGp);
            dr["FGeff"] = String.Format("{0:F2}", _psr.FGeff);
            dr["3PT"] = String.Format("{0:F3}", _psr.TPp);
            dr["3Peff"] = String.Format("{0:F2}", _psr.TPeff);
            dr["FT"] = String.Format("{0:F3}", _psr.FTp);
            dr["FTeff"] = String.Format("{0:F2}", _psr.FTeff);
            dr["REB"] = String.Format("{0:F1}", _psr.RPG);
            dr["OREB"] = String.Format("{0:F1}", _psr.ORPG);
            dr["DREB"] = String.Format("{0:F1}", _psr.DRPG);
            dr["AST"] = String.Format("{0:F1}", _psr.APG);
            dr["TO"] = String.Format("{0:F1}", _psr.TPG);
            dr["STL"] = String.Format("{0:F1}", _psr.SPG);
            dr["BLK"] = String.Format("{0:F1}", _psr.BPG);
            dr["FOUL"] = String.Format("{0:F1}", _psr.FPG);

            _dtOv.Rows.Add(dr);

            #region Rankings

            if (_psr.IsActive)
            {
                int id = _selectedPlayerID;

                dr = _dtOv.NewRow();

                dr["Type"] = "Rankings";
                dr["MINS"] = String.Format("{0}", _rankingsActive.RankingsPerGame[id][PAbbr.MPG]);
                dr["PTS"] = String.Format("{0}", _rankingsActive.RankingsPerGame[id][PAbbr.PPG]);
                dr["FG"] = String.Format("{0}", _rankingsActive.RankingsPerGame[id][PAbbr.FGp]);
                dr["FGeff"] = String.Format("{0}", _rankingsActive.RankingsPerGame[id][PAbbr.FGeff]);
                dr["3PT"] = String.Format("{0}", _rankingsActive.RankingsPerGame[id][PAbbr.TPp]);
                dr["3Peff"] = String.Format("{0}", _rankingsActive.RankingsPerGame[id][PAbbr.TPeff]);
                dr["FT"] = String.Format("{0}", _rankingsActive.RankingsPerGame[id][PAbbr.FTp]);
                dr["FTeff"] = String.Format("{0}", _rankingsActive.RankingsPerGame[id][PAbbr.FTeff]);
                dr["REB"] = String.Format("{0}", _rankingsActive.RankingsPerGame[id][PAbbr.RPG]);
                dr["OREB"] = String.Format("{0}", _rankingsActive.RankingsPerGame[id][PAbbr.ORPG]);
                dr["DREB"] = String.Format("{0}", _rankingsActive.RankingsPerGame[id][PAbbr.DRPG]);
                dr["AST"] = String.Format("{0}", _rankingsActive.RankingsPerGame[id][TAbbr.PAPG]);
                dr["TO"] = String.Format("{0}", _rankingsActive.RankingsPerGame[id][PAbbr.TPG]);
                dr["STL"] = String.Format("{0}", _rankingsActive.RankingsPerGame[id][PAbbr.SPG]);
                dr["BLK"] = String.Format("{0}", _rankingsActive.RankingsPerGame[id][PAbbr.BPG]);
                dr["FOUL"] = String.Format("{0}", _rankingsActive.RankingsPerGame[id][PAbbr.FPG]);

                _dtOv.Rows.Add(dr);

                dr = _dtOv.NewRow();

                dr["Type"] = "In-team Rankings";
                dr["MINS"] = String.Format("{0}", _rankingsTeam.RankingsPerGame[id][PAbbr.MPG]);
                dr["PTS"] = String.Format("{0}", _rankingsTeam.RankingsPerGame[id][PAbbr.PPG]);
                dr["FG"] = String.Format("{0}", _rankingsTeam.RankingsPerGame[id][PAbbr.FGp]);
                dr["FGeff"] = String.Format("{0}", _rankingsTeam.RankingsPerGame[id][PAbbr.FGeff]);
                dr["3PT"] = String.Format("{0}", _rankingsTeam.RankingsPerGame[id][PAbbr.TPp]);
                dr["3Peff"] = String.Format("{0}", _rankingsTeam.RankingsPerGame[id][PAbbr.TPeff]);
                dr["FT"] = String.Format("{0}", _rankingsTeam.RankingsPerGame[id][PAbbr.FTp]);
                dr["FTeff"] = String.Format("{0}", _rankingsTeam.RankingsPerGame[id][PAbbr.FTeff]);
                dr["REB"] = String.Format("{0}", _rankingsTeam.RankingsPerGame[id][PAbbr.RPG]);
                dr["OREB"] = String.Format("{0}", _rankingsTeam.RankingsPerGame[id][PAbbr.ORPG]);
                dr["DREB"] = String.Format("{0}", _rankingsTeam.RankingsPerGame[id][PAbbr.DRPG]);
                dr["AST"] = String.Format("{0}", _rankingsTeam.RankingsPerGame[id][TAbbr.PAPG]);
                dr["TO"] = String.Format("{0}", _rankingsTeam.RankingsPerGame[id][PAbbr.TPG]);
                dr["STL"] = String.Format("{0}", _rankingsTeam.RankingsPerGame[id][PAbbr.SPG]);
                dr["BLK"] = String.Format("{0}", _rankingsTeam.RankingsPerGame[id][PAbbr.BPG]);
                dr["FOUL"] = String.Format("{0}", _rankingsTeam.RankingsPerGame[id][PAbbr.FPG]);

                _dtOv.Rows.Add(dr);

                dr = _dtOv.NewRow();

                dr["Type"] = "Position Rankings";
                dr["MINS"] = String.Format("{0}", _rankingsPosition.RankingsPerGame[id][PAbbr.MPG]);
                dr["PTS"] = String.Format("{0}", _rankingsPosition.RankingsPerGame[id][PAbbr.PPG]);
                dr["FG"] = String.Format("{0}", _rankingsPosition.RankingsPerGame[id][PAbbr.FGp]);
                dr["FGeff"] = String.Format("{0}", _rankingsPosition.RankingsPerGame[id][PAbbr.FGeff]);
                dr["3PT"] = String.Format("{0}", _rankingsPosition.RankingsPerGame[id][PAbbr.TPp]);
                dr["3Peff"] = String.Format("{0}", _rankingsPosition.RankingsPerGame[id][PAbbr.TPeff]);
                dr["FT"] = String.Format("{0}", _rankingsPosition.RankingsPerGame[id][PAbbr.FTp]);
                dr["FTeff"] = String.Format("{0}", _rankingsPosition.RankingsPerGame[id][PAbbr.FTeff]);
                dr["REB"] = String.Format("{0}", _rankingsPosition.RankingsPerGame[id][PAbbr.RPG]);
                dr["OREB"] = String.Format("{0}", _rankingsPosition.RankingsPerGame[id][PAbbr.ORPG]);
                dr["DREB"] = String.Format("{0}", _rankingsPosition.RankingsPerGame[id][PAbbr.DRPG]);
                dr["AST"] = String.Format("{0}", _rankingsPosition.RankingsPerGame[id][TAbbr.PAPG]);
                dr["TO"] = String.Format("{0}", _rankingsPosition.RankingsPerGame[id][PAbbr.TPG]);
                dr["STL"] = String.Format("{0}", _rankingsPosition.RankingsPerGame[id][PAbbr.SPG]);
                dr["BLK"] = String.Format("{0}", _rankingsPosition.RankingsPerGame[id][PAbbr.BPG]);
                dr["FOUL"] = String.Format("{0}", _rankingsPosition.RankingsPerGame[id][PAbbr.FPG]);

                _dtOv.Rows.Add(dr);

                dr = _dtOv.NewRow();

                dr["Type"] = "Team Avg";
                dr["PTS"] = String.Format("{0:F1}", ts.PerGame[TAbbr.PPG]);
                dr["FG"] = String.Format("{0:F3}", ts.PerGame[TAbbr.FGp]);
                dr["FGeff"] = String.Format("{0:F2}", ts.PerGame[TAbbr.FGeff]);
                dr["3PT"] = String.Format("{0:F3}", ts.PerGame[TAbbr.TPp]);
                dr["3Peff"] = String.Format("{0:F2}", ts.PerGame[TAbbr.TPeff]);
                dr["FT"] = String.Format("{0:F3}", ts.PerGame[TAbbr.FTp]);
                dr["FTeff"] = String.Format("{0:F2}", ts.PerGame[TAbbr.FTeff]);
                dr["REB"] = String.Format("{0:F1}", ts.PerGame[TAbbr.RPG]);
                dr["OREB"] = String.Format("{0:F1}", ts.PerGame[TAbbr.ORPG]);
                dr["DREB"] = String.Format("{0:F1}", ts.PerGame[TAbbr.DRPG]);
                dr["AST"] = String.Format("{0:F1}", ts.PerGame[TAbbr.APG]);
                dr["TO"] = String.Format("{0:F1}", ts.PerGame[TAbbr.TPG]);
                dr["STL"] = String.Format("{0:F1}", ts.PerGame[TAbbr.SPG]);
                dr["BLK"] = String.Format("{0:F1}", ts.PerGame[TAbbr.BPG]);
                dr["FOUL"] = String.Format("{0:F1}", ts.PerGame[TAbbr.FPG]);

                _dtOv.Rows.Add(dr);
            }

            #endregion

            dr = _dtOv.NewRow();

            dr["Type"] = " ";

            _dtOv.Rows.Add(dr);

            #region Playoffs

            dr = _dtOv.NewRow();

            dr["Type"] = "Pl Stats";
            dr["GP"] = _plPSR.GP.ToString();
            dr["GS"] = _plPSR.GS.ToString();
            dr["MINS"] = _plPSR.MINS.ToString();
            dr["PTS"] = _plPSR.PTS.ToString();
            dr["FG"] = _plPSR.FGM.ToString() + "-" + _plPSR.FGA.ToString();
            dr["3PT"] = _plPSR.TPM.ToString() + "-" + _plPSR.TPA.ToString();
            dr["FT"] = _plPSR.FTM.ToString() + "-" + _plPSR.FTA.ToString();
            dr["REB"] = (_plPSR.DREB + _plPSR.OREB).ToString();
            dr["OREB"] = _plPSR.OREB.ToString();
            dr["DREB"] = _plPSR.DREB.ToString();
            dr["AST"] = _plPSR.AST.ToString();
            dr["TO"] = _plPSR.TOS.ToString();
            dr["STL"] = _plPSR.STL.ToString();
            dr["BLK"] = _plPSR.BLK.ToString();
            dr["FOUL"] = _plPSR.FOUL.ToString();

            _dtOv.Rows.Add(dr);

            dr = _dtOv.NewRow();

            dr["Type"] = "Pl Avg";
            dr["MINS"] = String.Format("{0:F1}", _plPSR.MPG);
            dr["PTS"] = String.Format("{0:F1}", _plPSR.PPG);
            dr["FG"] = String.Format("{0:F3}", _plPSR.FGp);
            dr["FGeff"] = String.Format("{0:F2}", _plPSR.FGeff);
            dr["3PT"] = String.Format("{0:F3}", _plPSR.TPp);
            dr["3Peff"] = String.Format("{0:F2}", _plPSR.TPeff);
            dr["FT"] = String.Format("{0:F3}", _plPSR.FTp);
            dr["FTeff"] = String.Format("{0:F2}", _plPSR.FTeff);
            dr["REB"] = String.Format("{0:F1}", _plPSR.RPG);
            dr["OREB"] = String.Format("{0:F1}", _plPSR.ORPG);
            dr["DREB"] = String.Format("{0:F1}", _plPSR.DRPG);
            dr["AST"] = String.Format("{0:F1}", _plPSR.APG);
            dr["TO"] = String.Format("{0:F1}", _plPSR.TPG);
            dr["STL"] = String.Format("{0:F1}", _plPSR.SPG);
            dr["BLK"] = String.Format("{0:F1}", _plPSR.BPG);
            dr["FOUL"] = String.Format("{0:F1}", _plPSR.FPG);

            _dtOv.Rows.Add(dr);

            #region Rankings

            if (_psr.IsActive)
            {
                int id = Convert.ToInt32(_selectedPlayerID);

                dr = _dtOv.NewRow();

                dr["Type"] = "Pl Rank";
                dr["MINS"] = String.Format("{0}", _plRankingsActive.RankingsPerGame[id][PAbbr.MPG]);
                dr["PTS"] = String.Format("{0}", _plRankingsActive.RankingsPerGame[id][PAbbr.PPG]);
                dr["FG"] = String.Format("{0}", _plRankingsActive.RankingsPerGame[id][PAbbr.FGp]);
                dr["FGeff"] = String.Format("{0}", _plRankingsActive.RankingsPerGame[id][PAbbr.FGeff]);
                dr["3PT"] = String.Format("{0}", _plRankingsActive.RankingsPerGame[id][PAbbr.TPp]);
                dr["3Peff"] = String.Format("{0}", _plRankingsActive.RankingsPerGame[id][PAbbr.TPeff]);
                dr["FT"] = String.Format("{0}", _plRankingsActive.RankingsPerGame[id][PAbbr.FTp]);
                dr["FTeff"] = String.Format("{0}", _plRankingsActive.RankingsPerGame[id][PAbbr.FTeff]);
                dr["REB"] = String.Format("{0}", _plRankingsActive.RankingsPerGame[id][PAbbr.RPG]);
                dr["OREB"] = String.Format("{0}", _plRankingsActive.RankingsPerGame[id][PAbbr.ORPG]);
                dr["DREB"] = String.Format("{0}", _plRankingsActive.RankingsPerGame[id][PAbbr.DRPG]);
                dr["AST"] = String.Format("{0}", _plRankingsActive.RankingsPerGame[id][TAbbr.PAPG]);
                dr["TO"] = String.Format("{0}", _plRankingsActive.RankingsPerGame[id][PAbbr.TPG]);
                dr["STL"] = String.Format("{0}", _plRankingsActive.RankingsPerGame[id][PAbbr.SPG]);
                dr["BLK"] = String.Format("{0}", _plRankingsActive.RankingsPerGame[id][PAbbr.BPG]);
                dr["FOUL"] = String.Format("{0}", _plRankingsActive.RankingsPerGame[id][PAbbr.FPG]);

                _dtOv.Rows.Add(dr);

                dr = _dtOv.NewRow();

                dr["Type"] = "Pl In-Team";
                dr["MINS"] = String.Format("{0}", _plRankingsTeam.RankingsPerGame[id][PAbbr.MPG]);
                dr["PTS"] = String.Format("{0}", _plRankingsTeam.RankingsPerGame[id][PAbbr.PPG]);
                dr["FG"] = String.Format("{0}", _plRankingsTeam.RankingsPerGame[id][PAbbr.FGp]);
                dr["FGeff"] = String.Format("{0}", _plRankingsTeam.RankingsPerGame[id][PAbbr.FGeff]);
                dr["3PT"] = String.Format("{0}", _plRankingsTeam.RankingsPerGame[id][PAbbr.TPp]);
                dr["3Peff"] = String.Format("{0}", _plRankingsTeam.RankingsPerGame[id][PAbbr.TPeff]);
                dr["FT"] = String.Format("{0}", _plRankingsTeam.RankingsPerGame[id][PAbbr.FTp]);
                dr["FTeff"] = String.Format("{0}", _plRankingsTeam.RankingsPerGame[id][PAbbr.FTeff]);
                dr["REB"] = String.Format("{0}", _plRankingsTeam.RankingsPerGame[id][PAbbr.RPG]);
                dr["OREB"] = String.Format("{0}", _plRankingsTeam.RankingsPerGame[id][PAbbr.ORPG]);
                dr["DREB"] = String.Format("{0}", _plRankingsTeam.RankingsPerGame[id][PAbbr.DRPG]);
                dr["AST"] = String.Format("{0}", _plRankingsTeam.RankingsPerGame[id][TAbbr.PAPG]);
                dr["TO"] = String.Format("{0}", _plRankingsTeam.RankingsPerGame[id][PAbbr.TPG]);
                dr["STL"] = String.Format("{0}", _plRankingsTeam.RankingsPerGame[id][PAbbr.SPG]);
                dr["BLK"] = String.Format("{0}", _plRankingsTeam.RankingsPerGame[id][PAbbr.BPG]);
                dr["FOUL"] = String.Format("{0}", _plRankingsTeam.RankingsPerGame[id][PAbbr.FPG]);

                _dtOv.Rows.Add(dr);

                dr = _dtOv.NewRow();

                dr["Type"] = "Pl Position";
                dr["MINS"] = String.Format("{0}", _plRankingsPosition.RankingsPerGame[id][PAbbr.MPG]);
                dr["PTS"] = String.Format("{0}", _plRankingsPosition.RankingsPerGame[id][PAbbr.PPG]);
                dr["FG"] = String.Format("{0}", _plRankingsPosition.RankingsPerGame[id][PAbbr.FGp]);
                dr["FGeff"] = String.Format("{0}", _plRankingsPosition.RankingsPerGame[id][PAbbr.FGeff]);
                dr["3PT"] = String.Format("{0}", _plRankingsPosition.RankingsPerGame[id][PAbbr.TPp]);
                dr["3Peff"] = String.Format("{0}", _plRankingsPosition.RankingsPerGame[id][PAbbr.TPeff]);
                dr["FT"] = String.Format("{0}", _plRankingsPosition.RankingsPerGame[id][PAbbr.FTp]);
                dr["FTeff"] = String.Format("{0}", _plRankingsPosition.RankingsPerGame[id][PAbbr.FTeff]);
                dr["REB"] = String.Format("{0}", _plRankingsPosition.RankingsPerGame[id][PAbbr.RPG]);
                dr["OREB"] = String.Format("{0}", _plRankingsPosition.RankingsPerGame[id][PAbbr.ORPG]);
                dr["DREB"] = String.Format("{0}", _plRankingsPosition.RankingsPerGame[id][PAbbr.DRPG]);
                dr["AST"] = String.Format("{0}", _plRankingsPosition.RankingsPerGame[id][TAbbr.PAPG]);
                dr["TO"] = String.Format("{0}", _plRankingsPosition.RankingsPerGame[id][PAbbr.TPG]);
                dr["STL"] = String.Format("{0}", _plRankingsPosition.RankingsPerGame[id][PAbbr.SPG]);
                dr["BLK"] = String.Format("{0}", _plRankingsPosition.RankingsPerGame[id][PAbbr.BPG]);
                dr["FOUL"] = String.Format("{0}", _plRankingsPosition.RankingsPerGame[id][PAbbr.FPG]);

                _dtOv.Rows.Add(dr);

                dr = _dtOv.NewRow();

                dr["Type"] = "Pl Team Avg";
                dr["PTS"] = String.Format("{0:F1}", ts.PlPerGame[TAbbr.PPG]);
                dr["FG"] = String.Format("{0:F3}", ts.PlPerGame[TAbbr.FGp]);
                dr["FGeff"] = String.Format("{0:F2}", ts.PlPerGame[TAbbr.FGeff]);
                dr["3PT"] = String.Format("{0:F3}", ts.PlPerGame[TAbbr.TPp]);
                dr["3Peff"] = String.Format("{0:F2}", ts.PlPerGame[TAbbr.TPeff]);
                dr["FT"] = String.Format("{0:F3}", ts.PlPerGame[TAbbr.FTp]);
                dr["FTeff"] = String.Format("{0:F2}", ts.PlPerGame[TAbbr.FTeff]);
                dr["REB"] = String.Format("{0:F1}", ts.PlPerGame[TAbbr.RPG]);
                dr["OREB"] = String.Format("{0:F1}", ts.PlPerGame[TAbbr.ORPG]);
                dr["DREB"] = String.Format("{0:F1}", ts.PlPerGame[TAbbr.DRPG]);
                dr["AST"] = String.Format("{0:F1}", ts.PlPerGame[TAbbr.APG]);
                dr["TO"] = String.Format("{0:F1}", ts.PlPerGame[TAbbr.TPG]);
                dr["STL"] = String.Format("{0:F1}", ts.PlPerGame[TAbbr.SPG]);
                dr["BLK"] = String.Format("{0:F1}", ts.PlPerGame[TAbbr.BPG]);
                dr["FOUL"] = String.Format("{0:F1}", ts.PlPerGame[TAbbr.FPG]);

                _dtOv.Rows.Add(dr);
            }

            #endregion

            #endregion

            var dvOv = new DataView(_dtOv) {AllowNew = false};

            dgvOverviewStats.DataContext = dvOv;

            #region Prepare Box Scores

            dgvBoxScores.ItemsSource = _pbsList;
            updateBest();
            cmbGraphStat_SelectionChanged(null, null);

            #endregion
        }
        private List<string> GetFacts(int id, PlayerRankings rankings, bool onlyLeaders = false)
        {
            var leadersStats = new List<int> {PAbbr.PPG, PAbbr.FGp, PAbbr.TPp, PAbbr.FTp, PAbbr.RPG, PAbbr.SPG, PAbbr.APG, PAbbr.BPG};
            int count = 0;
            var facts = new List<string>();
            for (int i = 0; i < rankings.RankingsPerGame[id].Length; i++)
            {
                if (onlyLeaders)
                {
                    if (!leadersStats.Contains(i))
                    {
                        continue;
                    }
                }
                int rank = rankings.RankingsPerGame[id][i];
                if (rank <= 20)
                {
                    string fact = String.Format("{0}{1} in {2}: ", rank, Misc.GetRankingSuffix(rank), PAbbr.PerGame[i]);
                    if (PAbbr.PerGame[i].EndsWith("%"))
                    {
                        fact += String.Format("{0:F3}", MainWindow.PST[id].PerGame[i]);
                    }
                    else if (PAbbr.PerGame[i].EndsWith("eff"))
                    {
                        fact += String.Format("{0:F2} ", MainWindow.PST[id].PerGame[i]);
                        switch (PAbbr.PerGame[i].Substring(0, 2))
                        {
                            case "FG":
                                fact += String.Format("({0:F1} FGM/G on {1:F3})",
                                                      ((double) MainWindow.PST[id].Totals[PAbbr.FGM])/
                                                      MainWindow.PST[id].Totals[PAbbr.GP], MainWindow.PST[id].PerGame[PAbbr.FGp]);
                                break;
                            case "3P":
                                fact += String.Format("({0:F1} 3PM/G on {1:F3})",
                                                      ((double) MainWindow.PST[id].Totals[PAbbr.TPM])/
                                                      MainWindow.PST[id].Totals[PAbbr.GP], MainWindow.PST[id].PerGame[PAbbr.TPp]);
                                break;
                            case "FT":
                                fact += String.Format("({0:F1} FTM/G on {1:F3})",
                                                      ((double) MainWindow.PST[id].Totals[PAbbr.FTM])/
                                                      MainWindow.PST[id].Totals[PAbbr.GP], MainWindow.PST[id].PerGame[PAbbr.FTp]);
                                break;
                        }
                    }
                    else
                    {
                        fact += String.Format("{0:F1}", MainWindow.PST[id].PerGame[i]);
                    }
                    facts.Add(fact);
                    count++;
                }
            }
            var metricsToSkip = new List<string> {"aPER", "uPER"};
            for (int i = 0; i < rankings.RankingsMetrics[id].Keys.Count; i++)
            {
                string metricName = rankings.RankingsMetrics[id].Keys.ToList()[i];
                if (metricsToSkip.Contains(metricName))
                {
                    continue;
                }

                int rank = rankings.RankingsMetrics[id][metricName];
                if (rank <= 20)
                {
                    string fact = String.Format("{0}{1} in {2}: ", rank, Misc.GetRankingSuffix(rank), metricName.Replace("p", "%"));
                    if (metricName.EndsWith("p") || metricName.EndsWith("%"))
                    {
                        fact += String.Format("{0:F3}", MainWindow.PST[id].Metrics[metricName]);
                    }
                    else if (metricName.EndsWith("eff"))
                    {
                        fact += String.Format("{0:F2}", MainWindow.PST[id].Metrics[metricName]);
                    }
                    else
                    {
                        fact += String.Format("{0:F1}", MainWindow.PST[id].Metrics[metricName]);
                    }
                    facts.Add(fact);
                    count++;
                }
            }
            if (!onlyLeaders)
            {
                for (int i = 0; i < rankings.RankingsTotal[id].Length; i++)
                {
                    int rank = rankings.RankingsTotal[id][i];
                    if (rank <= 20)
                    {
                        string fact = String.Format("{0}{1} in {2}: ", rank, Misc.GetRankingSuffix(rank), PAbbr.Totals[i]);
                        fact += String.Format("{0}", MainWindow.PST[id].Totals[i]);
                        facts.Add(fact);
                        count++;
                    }
                }
            }
            facts.Sort(
                (f1, f2) =>
                Convert.ToInt32(f1.Substring(0, f1.IndexOfAny(new[] {'s', 'n', 'r', 't'})))
                       .CompareTo(Convert.ToInt32(f2.Substring(0, f2.IndexOfAny(new[] {'s', 'n', 'r', 't'})))));
            return facts;
        }
        /// <summary>
        ///     Shows a scouting report for the player in natural language.
        /// </summary>
        /// <param name="pst">The PlayerStats dictionary containing all the player information.</param>
        /// <param name="rankingsActive">The rankingsPerGame of currently active players.</param>
        /// <param name="rankingsTeam">The rankingsPerGame of the players in the same team.</param>
        /// <param name="rankingsPosition">The rankingsPerGame of the players in the same position.</param>
        /// <param name="pbsList">The list of the player's available box scores.</param>
        /// <param name="bestGame">The well-formatted string from the player's best game.</param>
        public string ScoutingReport(Dictionary<int, PlayerStats> pst, PlayerRankings rankingsActive, PlayerRankings rankingsTeam,
                                     PlayerRankings rankingsPosition, IList<PlayerBoxScore> pbsIList, string bestGame,
                                     bool playoffs = false)
        {
            List<PlayerBoxScore> pbsList = pbsIList.ToList();
            string s = "";
            s += String.Format("{0} {1}, born in {3} ({6} years old today), is a {4}{5} tall {2} ", FirstName, LastName, Position1,
                               YearOfBirth, DisplayHeight, MainWindow.IsImperial ? "" : "cm.", DateTime.Today.Year - YearOfBirth);
            if (Position2 != Position.None)
            {
                s += String.Format("(alternatively {0})", Position2);
            }
            s += ", ";

            if (IsActive)
            {
                s += String.Format("who currently plays for the {0}.", TeamF);
            }
            else
            {
                s += String.Format("who is currently a Free Agent.");
            }

            s += String.Format(" He's been a pro for {0} year", YearsPro);
            if (YearsPro != 1)
            {
                s += "s";
            }
            s += ".";

            s += "\n\n";

            s += String.Format("He PerGame {0:F1} PPG on {1:F1} MPG, making for {2:F1} points per 36 minutes. ", PPG, MPG, PTSR);

            if (rankingsTeam.RankingsPerGame[ID][PAbbr.PPG] <= 3)
            {
                s += String.Format("One of the best scorers in the team, #{0} among his teammates. ",
                                   rankingsTeam.RankingsPerGame[ID][PAbbr.PPG]);
            }
            if (rankingsPosition.RankingsPerGame[ID][PAbbr.PPG] <= 10)
            {
                s +=
                    String.Format(
                        "His performance has got him to become one of the best at his position in scoring, #{0} among {1}'s. ",
                        rankingsPosition.RankingsPerGame[ID][PAbbr.PPG], Position1);
            }
            if (rankingsActive.RankingsPerGame[ID][PAbbr.PPG] <= 20)
            {
                s += String.Format("He's actually one of the best in the league in scoring, rated #{0} overall. ",
                                   rankingsActive.RankingsPerGame[ID][PAbbr.PPG]);
            }

            Dictionary<string, string> statList = GetBestStatsList(5);

            s += "\n\n";

            foreach (var stat in statList)
            {
                switch (stat.Key)
                {
                    case "FG":
                        s +=
                            String.Format(
                                "Shooting, one of his main strengths. He's averaging {0} as far as field goals go. Percentage-wise, his performance " +
                                "ranks him at #{1} overall. ", stat.Value, rankingsActive.RankingsPerGame[ID][PAbbr.FGp]);
                        if (rankingsTeam.RankingsPerGame[ID][PAbbr.FGp] <= 3)
                        {
                            s += String.Format("Top from the floor in his team, ranks at #{0} ",
                                               rankingsTeam.RankingsPerGame[ID][PAbbr.FGp]);
                        }
                        if (rankingsPosition.RankingsPerGame[ID][PAbbr.FGp] <= 10)
                        {
                            s += String.Format("Definitely dominating among {0}'s on scoring percentage, ranked at #{1}. ", Position1,
                                               rankingsPosition.RankingsPerGame[ID][PAbbr.FGp]);
                        }
                        break;
                    case "3P":
                        s +=
                            String.Format(
                                "His 3-point shooting is another area of focus. His three-point shooting PerGame {0}. #{1} in the league in 3P%. ",
                                stat.Value, rankingsActive.RankingsPerGame[ID][PAbbr.TPp]);
                        if (rankingsTeam.RankingsPerGame[ID][PAbbr.TPp] <= 3)
                        {
                            s += String.Format("One of the best guys from the arc in his team, ranks at #{0} ",
                                               rankingsTeam.RankingsPerGame[ID][PAbbr.TPp]);
                        }
                        if (rankingsPosition.RankingsPerGame[ID][PAbbr.TPp] <= 10)
                        {
                            s += String.Format("Not many {0}'s do better than him, as he's ranked at #{1}. ", Position1,
                                               rankingsPosition.RankingsPerGame[ID][PAbbr.TPp]);
                        }
                        break;
                    case "FT":
                        s +=
                            String.Format(
                                "Take a look at his free throw stats: He's averaging {0} from the line, which " +
                                "ranks him at #{1} overall. ", stat.Value, rankingsActive.RankingsPerGame[ID][PAbbr.FTp]);
                        if (rankingsTeam.RankingsPerGame[ID][PAbbr.FTp] <= 3)
                        {
                            s +=
                                String.Format(
                                    "Coach might prefer him to get all the fouls late in the game, as he ranks #{0} in his team. ",
                                    rankingsTeam.RankingsPerGame[ID][PAbbr.FTp]);
                        }
                        if (rankingsPosition.RankingsPerGame[ID][PAbbr.FTp] <= 10)
                        {
                            s += String.Format("Most {0}'s in the league struggle to keep up with him, he's ranked at #{1}. ",
                                               Position1, rankingsPosition.RankingsPerGame[ID][PAbbr.FTp]);
                        }
                        break;
                    case "ORPG":
                        s +=
                            String.Format(
                                "Crashing the offensive glass, one of his main strengths. His average offensive boards per game are at {0}, which " +
                                "ranks him at #{1} overall. He grabs {2:F1} offensive rebounds every 36 minutes. ", stat.Value,
                                rankingsActive.RankingsPerGame[ID][PAbbr.ORPG], OREBR);
                        if (rankingsTeam.RankingsPerGame[ID][PAbbr.ORPG] <= 3)
                        {
                            s += String.Format("One of the main guys to worry about below your basket, #{0} in his team. ",
                                               rankingsTeam.RankingsPerGame[ID][PAbbr.ORPG]);
                        }
                        if (rankingsPosition.RankingsPerGame[ID][PAbbr.ORPG] <= 10)
                        {
                            s += String.Format("He's ranked at #{1} among {0}'s in grabbing those second chance opportunities. ",
                                               Position1, rankingsPosition.RankingsPerGame[ID][PAbbr.ORPG]);
                        }
                        break;
                    case "RPG":
                        s +=
                            String.Format(
                                "He makes a point of crashing the boards. His RPG are at {0} ({2:F1} per 36 minutes), which " +
                                "ranks him at #{1} overall. ", stat.Value, rankingsActive.RankingsPerGame[ID][PAbbr.RPG], REBR);
                        if (rankingsTeam.RankingsPerGame[ID][PAbbr.RPG] <= 3)
                        {
                            s += String.Format("One of the top rebounders in his team, #{0} actually. ",
                                               rankingsTeam.RankingsPerGame[ID][PAbbr.RPG]);
                        }
                        if (rankingsPosition.RankingsPerGame[ID][PAbbr.RPG] <= 10)
                        {
                            s += String.Format("He's ranked at #{1} among {0}'s in crashing the boards. ", Position1,
                                               rankingsPosition.RankingsPerGame[ID][PAbbr.RPG]);
                        }
                        break;
                    case "BPG":
                        s +=
                            String.Format(
                                "Keep him in mind when he's in your face. His BPG are at {0} ({2:F1} per 36 minutes), which " +
                                "ranks him at #{1} overall. ", stat.Value, rankingsActive.RankingsPerGame[ID][PAbbr.BPG], BLKR);
                        if (rankingsTeam.RankingsPerGame[ID][PAbbr.BPG] <= 3)
                        {
                            s += String.Format("Among the top blockers in the team, ranked at #{0}. ",
                                               rankingsTeam.RankingsPerGame[ID][PAbbr.BPG]);
                        }
                        if (rankingsPosition.RankingsPerGame[ID][PAbbr.BPG] <= 10)
                        {
                            s += String.Format("One of the best {0}'s (#{1}) at blocking shots. ", Position1,
                                               rankingsPosition.RankingsPerGame[ID][PAbbr.BPG]);
                        }
                        break;
                    case "APG":
                        s +=
                            String.Format(
                                "Assisting the ball, an important aspect of his game. He does {0} APG ({2:F1} per 36 minutes), ranking him at #{1} overall. ",
                                stat.Value, rankingsActive.RankingsPerGame[ID][PAbbr.APG], ASTR);
                        if (rankingsTeam.RankingsPerGame[ID][PAbbr.APG] <= 3)
                        {
                            s += String.Format("#{0} as far as playmakers in the team go. ",
                                               rankingsTeam.RankingsPerGame[ID][PAbbr.APG]);
                        }
                        if (rankingsPosition.RankingsPerGame[ID][PAbbr.APG] <= 10)
                        {
                            s += String.Format("One of the league's best {0}'s (#{1}) at setting up teammates for a shot. ", Position1,
                                               rankingsPosition.RankingsPerGame[ID][PAbbr.APG]);
                        }
                        break;
                    case "SPG":
                        s +=
                            String.Format(
                                "Tries to keep his hands active; keep in mind his {0} SPG ({2:F1} per 36 minutes). His performance in taking the ball away has " +
                                "ranked him at #{1} in the league. ", stat.Value, rankingsActive.RankingsPerGame[ID][PAbbr.SPG], STLR);
                        if (rankingsTeam.RankingsPerGame[ID][PAbbr.SPG] <= 3)
                        {
                            s += String.Format("#{0} in taking the ball away among his teammates. ",
                                               rankingsTeam.RankingsPerGame[ID][PAbbr.SPG]);
                        }
                        if (rankingsPosition.RankingsPerGame[ID][PAbbr.SPG] <= 10)
                        {
                            s += String.Format("One of the league's best {0}'s (#{1}) in this aspect. ", Position1,
                                               rankingsPosition.RankingsPerGame[ID][PAbbr.SPG]);
                        }
                        break;
                    case "FTM/FGA":
                        s += String.Format("He fights through contact to get to the line. His FTM/FGA rate is at {0}. ", stat.Value);
                        break;
                }
                s += "\n";
            }

            s +=
                String.Format(
                    "His foul rate is at {0:F1} per 36 minutes, while his turnover rate is at {1:F1} per the same duration.\n\n",
                    (double) FOUL/MINS*36, TOR);

            pbsList.Sort((pbs1, pbs2) => pbs1.RealDate.CompareTo(pbs2.RealDate));
            pbsList.Reverse();

            if (!String.IsNullOrWhiteSpace(bestGame))
            {
                string[] parts = bestGame.Split(new[] {": ", " vs ", " (", "\n"}, StringSplitOptions.None);
                s += String.Format("His best game was at {0} against the {1}, with a Game Score of {2:F2} ", parts[1], parts[2],
                                   pbsList.Find(pbs => pbs.RealDate == Convert.ToDateTime(parts[1])).GmSc);
                s += "(";
                for (int i = 5; i < parts.Length; i++)
                {
                    if (String.IsNullOrWhiteSpace(parts[i]))
                    {
                        break;
                    }

                    s += String.Format("{0} {1}", parts[i + 1], parts[i]);
                    if (parts[i + 2].Contains(")"))
                    {
                        s += String.Format(" ({0}, ", parts[i + 2]);
                        i += 2;
                    }
                    else
                    {
                        s += ", ";
                        i += 1;
                    }
                }
                s = s.TrimEnd(new[] {',', ' '});
                s += "). ";
            }

            if (pbsList.Count > 5)
            {
                double sum = 0;
                for (int i = 0; i < 5; i++)
                {
                    sum += pbsList[i].GmSc;
                }
                double average = sum/5;
                s += String.Format("He's been averaging a Game Score of {0:F2} in his last 5 games, ", average);
                if (average > GmSc)
                {
                    s += String.Format("which can be considered an improvement compared to his season average of {0:F2}. ", GmSc);
                }
                else
                {
                    s += String.Format("which is lower than his season average of {0:F2}. ", GmSc);
                }
            }
            else if (pbsList.Count > 3)
            {
                double sum = 0;
                for (int i = 0; i < 3; i++)
                {
                    sum += pbsList[i].GmSc;
                }
                double average = sum/3;
                s += String.Format("He's been averaging a Game Score of {0:F2} in his last 3 games, ", average);
                if (average > GmSc)
                {
                    s += String.Format("which can be considered an improvement compared to his season average of {0:F2}. ", GmSc);
                }
                else
                {
                    s += String.Format("which is lower than his season average of {0:F2}. ", GmSc);
                }
            }
            else
            {
                s += String.Format("He's been averaging a Game Score of {0:F2}. ", GmSc);
            }

            s += "\n\nAccording to his rankings in the league, his best areas are ";
            var dict = new Dictionary<int, int>();
            for (int k = 0; k < rankingsActive.RankingsPerGame[ID].Length; k++)
            {
                dict.Add(k, rankingsActive.RankingsPerGame[ID][k]);
            }
            dict[TAbbr.FPG] = pst.Count + 1 - dict[TAbbr.FPG];
            dict[TAbbr.TPG] = pst.Count + 1 - dict[TAbbr.TPG];
            dict[TAbbr.PAPG] = pst.Count + 1 - dict[TAbbr.PAPG];
            List<int> strengths = (from entry in dict
                                   orderby entry.Value ascending
                                   select entry.Key).ToList();
            int m = 0;
            int j = 3;
            while (true)
            {
                if (m == j)
                {
                    break;
                }
                switch (strengths[m])
                {
                    case PAbbr.APG:
                        s += String.Format("assists (#{0}, {1:F1}), ", rankingsActive.RankingsPerGame[ID][PAbbr.APG], APG);
                        break;
                    case PAbbr.BPG:
                        s += String.Format("blocks (#{0}, {1:F1}), ", rankingsActive.RankingsPerGame[ID][PAbbr.BPG], BPG);
                        break;
                    case PAbbr.DRPG:
                        s += String.Format("defensive rebounds (#{0}, {1:F1}), ", rankingsActive.RankingsPerGame[ID][PAbbr.DRPG], DRPG);
                        break;
                    case PAbbr.FGeff:
                        s += String.Format("field goals (#{0}, {1:F1} per game on {2:F3}), ",
                                           rankingsActive.RankingsPerGame[ID][PAbbr.FGeff], (double) FGM/GP, FGp);
                        break;
                    case PAbbr.FPG:
                        s += String.Format("fouls (#{0}, {1:F1}), ", rankingsActive.RankingsPerGame[ID][PAbbr.FPG], FPG);
                        break;
                    case PAbbr.FTeff:
                        s += String.Format("free throws (#{0}, {1:F1} per game on {2:F3}), ",
                                           rankingsActive.RankingsPerGame[ID][PAbbr.FTeff], (double) FTM/GP, FTp);
                        break;
                    case PAbbr.ORPG:
                        s += String.Format("offensive rebounds (#{0}, {1:F1}), ", rankingsActive.RankingsPerGame[ID][PAbbr.ORPG], ORPG);
                        break;
                    case PAbbr.PPG:
                        s += String.Format("scoring (#{0}, {1:F1}), ", rankingsActive.RankingsPerGame[ID][PAbbr.PPG], PPG);
                        break;
                    case PAbbr.RPG:
                        s += String.Format("rebounds (#{0}, {1:F1}), ", rankingsActive.RankingsPerGame[ID][PAbbr.RPG], RPG);
                        break;
                    case PAbbr.SPG:
                        s += String.Format("steals (#{0}, {1:F1}), ", rankingsActive.RankingsPerGame[ID][PAbbr.SPG], SPG);
                        break;
                    case PAbbr.TPG:
                        s += String.Format("turnovers (#{0}, {1:F1}), ", rankingsActive.RankingsPerGame[ID][PAbbr.TPG], TPG);
                        break;
                    case PAbbr.TPeff:
                        s += String.Format("three-pointers (#{0}, {1:F1} per game on {2:F3}), ",
                                           rankingsActive.RankingsPerGame[ID][PAbbr.TPeff], (double) TPM/GP, TPp);
                        break;
                    default:
                        j++;
                        break;
                }
                m++;
            }
            s = s.TrimEnd(new[] {' ', ','});
            s += ".";

            return s;
        }
예제 #17
0
 private static string getBestStatsForMarquee(PlayerStatsRow curLr, PlayerRankings rankingsActive, int count, int statToIgnore)
 {
     var s = "";
     var dict = new Dictionary<int, int>();
     for (var k = 0; k < rankingsActive.RankingsPerGame[curLr.ID].Length; k++)
     {
         dict.Add(k, rankingsActive.RankingsPerGame[curLr.ID][k]);
     }
     dict[PAbbrPG.FPG] = PST.Count + 1 - dict[PAbbrPG.FPG];
     dict[PAbbrPG.TPG] = PST.Count + 1 - dict[PAbbrPG.TPG];
     //dict[t.PAPG] = pst.Count + 1 - dict[t.PAPG];
     var strengths = (from entry in dict orderby entry.Value ascending select entry.Key).ToList();
     var m = 0;
     var j = count;
     while (true)
     {
         if (m == j)
         {
             break;
         }
         if (strengths[m] == statToIgnore || strengths[m] == PAbbrPG.PPG || strengths[m] == PAbbrPG.DRPG)
         {
             j++;
             m++;
             continue;
         }
         switch (strengths[m])
         {
             case PAbbrPG.APG:
                 s += String.Format("{0:F1} APG, ", curLr.APG);
                 break;
             case PAbbrPG.BPG:
                 s += String.Format("{0:F1} BPG, ", curLr.BPG);
                 break;
             case PAbbrPG.DRPG:
                 s += String.Format("{0:F1} DRPG, ", curLr.DRPG);
                 break;
             case PAbbrPG.FGp:
                 s += String.Format("{0:F3} FG%, ", curLr.FGp);
                 break;
             case PAbbrPG.FPG:
                 s += String.Format("{0:F1} FPG, ", curLr.FPG);
                 break;
             case PAbbrPG.FTp:
                 s += String.Format("{0:F3} FT%, ", curLr.FTp);
                 break;
             case PAbbrPG.ORPG:
                 s += String.Format("{0:F1} ORPG, ", curLr.ORPG);
                 break;
             case PAbbrPG.PPG:
                 s += String.Format("{0:F1} PPG, ", curLr.PPG);
                 break;
             case PAbbrPG.RPG:
                 s += String.Format("{0:F1} RPG, ", curLr.RPG);
                 break;
             case PAbbrPG.SPG:
                 s += String.Format("{0:F1} SPG, ", curLr.SPG);
                 break;
             case PAbbrPG.TPG:
                 s += String.Format("{0:F1} TPG, ", curLr.TPG);
                 break;
             case PAbbrPG.TPp:
                 s += String.Format("{0:F3} 3P%, ", curLr.TPp);
                 break;
             default:
                 j++;
                 break;
         }
         m++;
     }
     s = s.TrimEnd(new[] { ' ', ',' });
     return s;
 }
예제 #18
0
 private static void parseDBData(DBData dbData)
 {
     TST = dbData.TST;
     TSTOpp = dbData.TSTOpp;
     PST = dbData.PST;
     SeasonTeamRankings = dbData.SeasonTeamRankings;
     PlayoffTeamRankings = dbData.PlayoffTeamRankings;
     SplitTeamStats = dbData.SplitTeamStats;
     SplitPlayerStats = dbData.SplitPlayerStats;
     SeasonPlayerRankings = dbData.SeasonPlayerRankings;
     PlayoffPlayerRankings = dbData.PlayoffPlayerRankings;
     DisplayNames = dbData.DisplayNames;
     BSHist = dbData.BSHist;
 }
 /// <summary>Gets a player stats dictionary of only the active players, and calculates their rankingsPerGame.</summary>
 private void getActivePlayers()
 {
     _playersActive = MainWindow.PST.Where(ps => ps.Value.IsSigned && !ps.Value.IsHidden)
                                .ToDictionary(ps => ps.Key, ps => ps.Value);
     _rankingsActive = new PlayerRankings(_playersActive);
     _plRankingsActive = new PlayerRankings(_playersActive, true);
 }