Example #1
0
        /// <summary>Creates the team and opposing team stats instances using data from the downloaded DataTable.</summary>
        /// <param name="dt">The DataTable.</param>
        /// <param name="name">The name of the team.</param>
        /// <param name="recordparts">The parts of the team's record string.</param>
        /// <param name="ts">The resulting team stats instance.</param>
        /// <param name="tsopp">The resulting opposing team stats instance.</param>
        private static void teamStatsFromDataTable(
            DataTable dt, string name, string[] recordparts, out TeamStats ts, out TeamStats tsopp)
        {
            var teamID = MainWindow.RealTST.Single(pair => pair.Value.Name == name).Key;

            ts    = new TeamStats(teamID, name);
            tsopp = new TeamStats(teamID, name);

            tsopp.Record[1] = ts.Record[0] = Convert.ToByte(recordparts[0]);
            tsopp.Record[0] = ts.Record[1] = Convert.ToByte(recordparts[1]);

            var tr    = dt.Rows[0];
            var toppr = dt.Rows[2];

            ts.Totals[TAbbrT.MINS] = (ushort)(ParseCell.GetUInt16(tr, "MP") / 5);
            ts.Totals[TAbbrT.FGM]  = ParseCell.GetUInt16(tr, "FG");
            ts.Totals[TAbbrT.FGA]  = ParseCell.GetUInt16(tr, "FGA");
            ts.Totals[TAbbrT.TPM]  = ParseCell.GetUInt16(tr, "3P");
            ts.Totals[TAbbrT.TPA]  = ParseCell.GetUInt16(tr, "3PA");
            ts.Totals[TAbbrT.FTM]  = ParseCell.GetUInt16(tr, "FT");
            ts.Totals[TAbbrT.FTA]  = ParseCell.GetUInt16(tr, "FTA");
            ts.Totals[TAbbrT.OREB] = ParseCell.GetUInt16(tr, "ORB");
            ts.Totals[TAbbrT.DREB] = ParseCell.GetUInt16(tr, "DRB");
            ts.Totals[TAbbrT.AST]  = ParseCell.GetUInt16(tr, "AST");
            ts.Totals[TAbbrT.STL]  = ParseCell.GetUInt16(tr, "STL");
            ts.Totals[TAbbrT.BLK]  = ParseCell.GetUInt16(tr, "BLK");
            ts.Totals[TAbbrT.TOS]  = ParseCell.GetUInt16(tr, "TOV");
            ts.Totals[TAbbrT.FOUL] = ParseCell.GetUInt16(tr, "PF");
            ts.Totals[TAbbrT.PF]   = ParseCell.GetUInt16(tr, "PTS");
            ts.Totals[TAbbrT.PA]   = ParseCell.GetUInt16(toppr, "PTS");

            ts.CalcAvg();

            tsopp.Totals[TAbbrT.MINS] = (ushort)(ParseCell.GetUInt16(toppr, "MP") / 5);
            tsopp.Totals[TAbbrT.FGM]  = ParseCell.GetUInt16(toppr, "FG");
            tsopp.Totals[TAbbrT.FGA]  = ParseCell.GetUInt16(toppr, "FGA");
            tsopp.Totals[TAbbrT.TPM]  = ParseCell.GetUInt16(toppr, "3P");
            tsopp.Totals[TAbbrT.TPA]  = ParseCell.GetUInt16(toppr, "3PA");
            tsopp.Totals[TAbbrT.FTM]  = ParseCell.GetUInt16(toppr, "FT");
            tsopp.Totals[TAbbrT.FTA]  = ParseCell.GetUInt16(toppr, "FTA");
            tsopp.Totals[TAbbrT.OREB] = ParseCell.GetUInt16(toppr, "ORB");
            tsopp.Totals[TAbbrT.DREB] = ParseCell.GetUInt16(toppr, "DRB");
            tsopp.Totals[TAbbrT.AST]  = ParseCell.GetUInt16(toppr, "AST");
            tsopp.Totals[TAbbrT.STL]  = ParseCell.GetUInt16(toppr, "STL");
            tsopp.Totals[TAbbrT.BLK]  = ParseCell.GetUInt16(toppr, "BLK");
            tsopp.Totals[TAbbrT.TOS]  = ParseCell.GetUInt16(toppr, "TOV");
            tsopp.Totals[TAbbrT.FOUL] = ParseCell.GetUInt16(toppr, "PF");
            tsopp.Totals[TAbbrT.PF]   = ParseCell.GetUInt16(toppr, "PTS");
            tsopp.Totals[TAbbrT.PA]   = ParseCell.GetUInt16(tr, "PTS");

            tsopp.CalcAvg();
        }