public TableRecordModel ConstructRecordModel(int recno)
        {
            TableRecordModel newRecord = null;
            string           tablename = name;

            // Need to reverse the name if BE
            if (BigEndian)
            {
                string rev = ConvertBE(name);
                tablename = rev;
            }

            switch (tablename)
            {
            case EditorModel.CITY_TABLE:
                newRecord = new CityRecord(recno, this, parentModel);
                break;

            case EditorModel.COACH_TABLE:
            {
                // coch table in streameddata is different than ros/fra
                if (parentModel.FileType == MaddenFileType.Streameddata)
                {
                    newRecord = new CoachCollection(recno, this, parentModel);
                }
                else
                {
                    newRecord = new CoachRecord(recno, this, parentModel);
                }
                break;
            }

            case EditorModel.SALARY_CAP_TABLE:
                newRecord = new SalaryCapRecord(recno, this, parentModel);
                break;

            case EditorModel.COACH_SLIDER_TABLE:
                newRecord = new CoachPrioritySliderRecord(recno, this, parentModel);
                break;

            case EditorModel.TEAM_CAPTAIN_TABLE:
                newRecord = new TeamCaptainRecord(recno, this, parentModel);
                break;

            case EditorModel.OWNER_TABLE:
                newRecord = new OwnerRecord(recno, this, parentModel);
                break;

            case EditorModel.DEPTH_CHART_TABLE:
                newRecord = new DepthChartRecord(recno, this, parentModel);
                break;

            case EditorModel.INJURY_TABLE:
                newRecord = new InjuryRecord(recno, this, parentModel);
                break;

            case EditorModel.PLAYER_TABLE:
                newRecord = new PlayerRecord(recno, this, parentModel);
                break;

            case EditorModel.TEAM_TABLE:
                newRecord = new TeamRecord(recno, this, parentModel);
                break;

            case EditorModel.SCHEDULE_TABLE:
                newRecord = new ScheduleRecord(recno, this, parentModel);
                break;

            case EditorModel.STADIUM_TABLE:
                newRecord = new StadiumRecord(recno, this, parentModel);
                break;

            case EditorModel.UNIFORM_TABLE:
                newRecord = new UniformRecord(recno, this, parentModel);
                break;

            // MADDEN DRAFT EDIT
            case EditorModel.DRAFT_PICK_TABLE:
                newRecord = new DraftPickRecord(recno, this, parentModel);
                break;

            case EditorModel.DRAFTED_PLAYERS_TABLE:
                newRecord = new RookieRecord(recno, this, parentModel);
                break;

            case EditorModel.BOXSCORE_DEFENSE_TABLE:
                newRecord = new BoxScoreDefenseRecord(recno, this, parentModel);
                break;

            case EditorModel.BOXSCORE_OFFENSE_TABLE:
                newRecord = new BoxScoreOffenseRecord(recno, this, parentModel);
                break;

            case EditorModel.CAREER_STATS_DEFENSE_TABLE:
                newRecord = new CareerStatsDefenseRecord(recno, this, parentModel);
                break;

            case EditorModel.CAREER_STATS_OFFENSE_TABLE:
                newRecord = new CareerStatsOffenseRecord(recno, this, parentModel);
                break;

            case EditorModel.SEASON_STATS_DEFENSE_TABLE:
                newRecord = new SeasonStatsDefenseRecord(recno, this, parentModel);
                break;

            case EditorModel.SEASON_STATS_OFFENSE_TABLE:
                newRecord = new SeasonStatsOffenseRecord(recno, this, parentModel);
                break;

            case EditorModel.TEAM_SEASON_STATS:
                newRecord = new TeamSeasonStatsRecord(recno, this, parentModel);
                break;

            case EditorModel.FRANCHISE_TIME_TABLE:
                newRecord = new FranchiseTimeRecord(recno, this, parentModel);
                break;

            case EditorModel.BOXSCORE_TEAM_TABLE:
                newRecord = new BoxScoreTeamStats(recno, this, parentModel);
                break;

            case EditorModel.BOXSCORE_OFFENSIVE_LINE_TABLE:
                newRecord = new BoxScoreOffensiveLineRecord(recno, this, parentModel);
                break;

            case EditorModel.SEASON_STATS_OFFENSIVE_LINE_TABLE:
                newRecord = new SeasonStatsOffensiveLineRecord(recno, this, parentModel);
                break;

            case EditorModel.CAREER_STATS_OFFENSIVE_LINE_TABLE:
                newRecord = new CareerStatsOffensiveLineRecord(recno, this, parentModel);
                break;

            case EditorModel.CAREER_GAMES_PLAYED_TABLE:
                newRecord = new CareerGamesPlayedRecord(recno, this, parentModel);
                break;

            case EditorModel.SEASON_GAMES_PLAYED_TABLE:
                newRecord = new SeasonGamesPlayedRecord(recno, this, parentModel);
                break;

            case EditorModel.CAREER_STATS_KICKPUNT_TABLE:
                newRecord = new CareerPuntKickRecord(recno, this, parentModel);
                break;

            case EditorModel.SEASON_STATS_KICKPUNT_TABLE:
                newRecord = new SeasonPuntKickRecord(recno, this, parentModel);
                break;

            case EditorModel.CAREER_STATS_KICKPUNT_RETURN_TABLE:
                newRecord = new CareerPKReturnRecord(recno, this, parentModel);
                break;

            case EditorModel.SEASON_STATS_KICKPUNT_RETURN_TABLE:
                newRecord = new SeasonPKReturnRecord(recno, this, parentModel);
                break;

            case EditorModel.SCOUTING_STATE_TABLE:
                newRecord = new ScoutingStateRecord(recno, this, parentModel);
                break;

            case EditorModel.RFA_STATE_TABLE:
                newRecord = new RFAStateRecord(recno, this, parentModel);
                break;

            case EditorModel.RFA_PLAYERS:
                newRecord = new RestrictedFreeAgentPlayers(recno, this, parentModel);
                break;

            case EditorModel.RFA_SALARY_TENDERS:
                newRecord = new RestrictedFreeAgentSigningTenders(recno, this, parentModel);
                break;

            case EditorModel.RESIGN_PLAYERS_STATE_TABLE:
                newRecord = new ResignPlayersStateRecord(recno, this, parentModel);
                break;

            case EditorModel.FREE_AGENCY_STATE_TABLE:
                newRecord = new FreeAgencyStateRecord(recno, this, parentModel);
                break;

            case EditorModel.DRAFT_STATE_TABLE:
                newRecord = new DraftStateRecord(recno, this, parentModel);
                break;

            case EditorModel.FRANCHISE_STAGE_TABLE:
                newRecord = new FranchiseStageRecord(recno, this, parentModel);
                break;

            case EditorModel.GAME_OPTIONS_TABLE:
                newRecord = new GameOptionRecord(recno, this, parentModel);
                break;

            case EditorModel.PLAYER_AWARDS_TABLE:
                newRecord = new YearlyAwards(recno, this, parentModel);
                break;

            case EditorModel.FREE_AGENT_PLAYERS:
                newRecord = new FreeAgentPlayers(recno, this, parentModel);
                break;

            case EditorModel.COACHES_EXPECTED_SALARY:
                newRecord = new CoachExpectedSalary(recno, this, parentModel);
                break;

            case EditorModel.COACHING_HISTORY_TABLE:
                newRecord = new CoachHistory(recno, this, parentModel);
                break;

            case EditorModel.PROGRESSION_SCHEDULE:
                newRecord = new ProgressionSchedule(recno, this, parentModel);
                break;

            case EditorModel.USER_OPTIONS_TABLE:
                newRecord = new UserOptionRecord(recno, this, parentModel);
                break;

            case EditorModel.TEAM_RIVAL_HISTORY:
                newRecord = new TeamRivalHistory(recno, this, parentModel);
                break;

            case EditorModel.PRO_BOWL_PLAYERS:
                newRecord = new ProBowlPlayer(recno, this, parentModel);
                break;

            case EditorModel.USER_INFO_TABLE:
                newRecord = new UserInfoRecord(recno, this, parentModel);
                break;

                #region Streamed Data
            case EditorModel.COLLEGES_TABLE:
                newRecord = new CollegesRecord(recno, this, parentModel);
                break;

            case EditorModel.PLAYER_FIRST_NAMES:
                newRecord = new FirstNames(recno, this, parentModel);
                break;

            case EditorModel.PLAYER_LAST_NAMES:
                newRecord = new LastNames(recno, this, parentModel);
                break;

            case EditorModel.ROLES_DEFINE:
                newRecord = new PRDF(recno, this, parentModel);
                break;

            case EditorModel.ROLES_INFO:
                newRecord = new RoleInfo(recno, this, parentModel);
                break;

            case EditorModel.ROLES_PLAYER_EFFECTS:
                newRecord = new RolePlayerEffects(recno, this, parentModel);
                break;

            case EditorModel.ROLES_TEAM_EFFECTS:
                newRecord = new RoleTeamEffects(recno, this, parentModel);
                break;

            case EditorModel.STATS_REQUIRED:
                newRecord = new SuperStarStatsRequired(recno, this, parentModel);
                break;

            case EditorModel.PROGRESSION:
                newRecord = new PlayerProgression(recno, this, parentModel);
                break;

            case EditorModel.REGRESSION:
                newRecord = new PlayerRegression(recno, this, parentModel);
                break;

            case EditorModel.PTCB:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTCE:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTDE:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTDT:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTFB:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTFS:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTGA:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTHB:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTKI:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTKP:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTMB:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTOB:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTPU:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTQB:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTSS:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTTA:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTTE:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTWR:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

                #endregion

            case EditorModel.POSITION_SUBS:
                newRecord = new PlayerSubs(recno, this, parentModel);
                break;

            case EditorModel.DEPTH_CHART_SUBS:
                newRecord = new DepthChartSubs(recno, this, parentModel);
                break;

            case EditorModel.SALARY_CAP_INCREASE:
                newRecord = new SalaryCapIncrease(recno, this, parentModel);
                break;

            case EditorModel.PLAYER_MINIMUM_SALARY_TABLE:
                newRecord = new SalaryYearsPro(recno, this, parentModel);
                break;

            case EditorModel.PLAYER_SALARY_DEMAND_TABLE:
                newRecord = new PlayerSalaryDemands(recno, this, parentModel);
                break;

            case EditorModel.INACTIVE_TABLE:
                newRecord = new InactiveRecord(recno, this, parentModel);
                break;

            case EditorModel.LEAGUE_REVENUE_TABLE:
                newRecord = new LeagueRevenue(recno, this, parentModel);
                break;

            case EditorModel.OWNER_REVENUE_TABLE:
                newRecord = new OwnerRevenue(recno, this, parentModel);
                break;

            case EditorModel.WEEKLY_INCOME_TABLE:
                newRecord = new Income(recno, this, parentModel);
                break;

            case EditorModel.TEAM_WIN_LOSS_RECORD:
                newRecord = new TeamWinLossRecord(recno, this, parentModel);
                break;

            // DB Templates
            case EditorModel.PLAYER_OVERALL_CALC:
                newRecord = new OverallRecord(recno, this, parentModel);
                break;

            case EditorModel.PLAYBOOK_TABLE:
                newRecord = new FRAPlayBooks(recno, this, parentModel);
                break;

            default:
                newRecord = new TableRecordModel(recno, this, parentModel);
                break;
            }

            //Add the new record to our list of records
            recordList.Add(newRecord);

            return(newRecord);
        }
Exemple #2
0
        private void GetTeamStats
        (
            Dictionary <string, int> things,
            int seasonIndex,
            int weekIndex,
            int stageIndex,
            int leagueId
        )
        {
            tableTeamStats.InnerHtml = string.Empty;

            var awayTeamId = 0;
            var homeTeamId = 0;
            var scheduleId = 0;


            foreach (var i in things)
            {
                if (i.Key == "homeTeamId")
                {
                    homeTeamId = i.Value;
                }

                if (i.Key == "awayTeamId")
                {
                    awayTeamId = i.Value;
                }

                if (i.Key == "scheduleId")
                {
                    scheduleId = i.Value;
                }
            }

            var sp = new StoredProc
            {
                Name = "BoxScoreTeamStats_select",
                DataConnectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString,
                ParameterSet         = new SqlCommand()
            };


            sp.ParameterSet.Parameters.AddWithValue("@stageIndex", stageIndex);
            sp.ParameterSet.Parameters.AddWithValue("@seasonIndex", seasonIndex);
            sp.ParameterSet.Parameters.AddWithValue("@weekindex", weekIndex);
            sp.ParameterSet.Parameters.AddWithValue("@scheduleId", scheduleId);
            sp.ParameterSet.Parameters.AddWithValue("@leagueId", leagueId);


            var ds = StoredProc.ShowMeTheData(sp);

            if (ds.Tables.Count == 0)
            {
                return;
            }

            var stats = new BoxScoreTeamStats();


            foreach (DataRow row in ds.Tables[0].Rows)
            {
                if (Helper.IntegerNull(row["teamId"]) == homeTeamId)
                {
                    stats.HomeTotalYards       = Helper.IntegerNull(row["offTotalYds"]);
                    stats.HomeRushYards        = Helper.IntegerNull(row["offRushYds"]);
                    stats.HomePassYards        = Helper.IntegerNull(row["offPassYds"]);
                    stats.HomeTotalYardsGained = Helper.IntegerNull(row["offTotalYdsGained"]);

                    stats.HomeFirstDowns = Helper.IntegerNull(row["off1stDowns"]);

                    stats.HomeTODifferential =
                        $"{Helper.IntegerNull(row["tOGiveaways"])} ({Helper.IntegerNull(row["tODiff"])})";


                    var off3RdDownAtt  = Helper.IntegerNull(row["off3rdDownAtt"]);
                    var off3RdDownConv = Helper.IntegerNull(row["off3rdDownConv"]);
                    stats.HomeThirdDowns =
                        $"{off3RdDownConv} - {off3RdDownAtt} ({Helper.GetPercent(off3RdDownAtt, off3RdDownConv)})";

                    var off4ThDownAtt  = Helper.IntegerNull(row["off4thDownAtt"]);
                    var off4ThDownConv = Helper.IntegerNull(row["off4thDownConv"]);
                    stats.HomeFourthDowns =
                        $"{off4ThDownConv} - {off4ThDownAtt} ({Helper.GetPercent(off4ThDownAtt, off4ThDownConv)})";

                    var offRedZoneTDs = Helper.IntegerNull(row["offRedZoneTDs"]);
                    var offRedZoneFGs = Helper.IntegerNull(row["offRedZoneFGs"]);
                    var offRedZones   = Helper.IntegerNull(row["offRedZones"]);
                    stats.HomeRedZones =
                        $"{offRedZoneFGs + offRedZoneTDs} - {offRedZones} ({Helper.GetPercent(offRedZones, offRedZoneFGs + offRedZoneTDs)})";
                    stats.HomeRedZoneFGs = offRedZoneFGs;
                    stats.HomeRedZoneTDs = offRedZoneTDs;


                    stats.HomePenalties =
                        $"{Helper.IntegerNull(row["penalties"])} - {Helper.IntegerNull(row["penaltyYds"])}";

                    stats.HomeSacks         = Helper.IntegerNull(row["defSacks"]);
                    stats.HomeInterceptions = Helper.IntegerNull(row["defIntsRec"]);
                    stats.HomePassTDs       = Helper.IntegerNull(row["offPassTDs"]);
                    stats.HomeRushTDs       = Helper.IntegerNull(row["offRushTDs"]);
                    stats.HomeTotalTDs      = stats.HomeRushTDs + stats.HomePassTDs;
                }


                if (Helper.IntegerNull(row["teamId"]) == awayTeamId)
                {
                    stats.AwayTotalYards       = Helper.IntegerNull(row["offTotalYds"]);
                    stats.AwayRushYards        = Helper.IntegerNull(row["offRushYds"]);
                    stats.AwayPassYards        = Helper.IntegerNull(row["offPassYds"]);
                    stats.AwayTotalYardsGained = Helper.IntegerNull(row["offTotalYdsGained"]);

                    stats.AwayFirstDowns = Helper.IntegerNull(row["off1stDowns"]);

                    stats.AwayTODifferential =
                        $"{Helper.IntegerNull(row["tOGiveaways"])} ({Helper.IntegerNull(row["tODiff"])})";


                    var off3RdDownAtt  = Helper.IntegerNull(row["off3rdDownAtt"]);
                    var off3RdDownConv = Helper.IntegerNull(row["off3rdDownConv"]);
                    stats.AwayThirdDowns =
                        $"{off3RdDownConv} - {off3RdDownAtt} ({Helper.GetPercent(off3RdDownAtt, off3RdDownConv)})";

                    var off4ThDownAtt  = Helper.IntegerNull(row["off4thDownAtt"]);
                    var off4ThDownConv = Helper.IntegerNull(row["off4thDownConv"]);
                    stats.AwayFourthDowns =
                        $"{off4ThDownConv} - {off4ThDownAtt} ({Helper.GetPercent(off4ThDownAtt, off4ThDownConv)})";

                    var offRedZoneTDs = Helper.IntegerNull(row["offRedZoneTDs"]);
                    var offRedZoneFGs = Helper.IntegerNull(row["offRedZoneFGs"]);
                    var offRedZones   = Helper.IntegerNull(row["offRedZones"]);
                    stats.AwayRedZones =
                        $"{offRedZoneFGs + offRedZoneTDs} - {offRedZones} ({Helper.GetPercent(offRedZones, offRedZoneFGs + offRedZoneTDs)})";
                    stats.AwayRedZoneFGs = offRedZoneFGs;
                    stats.AwayRedZoneTDs = offRedZoneTDs;


                    stats.AwayPenalties =
                        $"{Helper.IntegerNull(row["penalties"])} - {Helper.IntegerNull(row["penaltyYds"])}";

                    stats.AwaySacks         = Helper.IntegerNull(row["defSacks"]);
                    stats.AwayInterceptions = Helper.IntegerNull(row["defIntsRec"]);
                    stats.AwayPassTDs       = Helper.IntegerNull(row["offPassTDs"]);
                    stats.AwayRushTDs       = Helper.IntegerNull(row["offRushTDs"]);
                    stats.AwayTotalTDs      = stats.AwayRushTDs + stats.AwayPassTDs;
                }
            }

            var sb = new StringBuilder();

            sb.Append("<table class='table table-striped table-hover table-bordered'><thead></thead><tbody>");

            sb.Append(
                $"<tr><td class='stat'>{stats.AwayTotalYards}</td> <td class='statName'>Total Offense Yards</td> <td class='stat'>{stats.HomeTotalYards}</td> </tr>");
            sb.Append(
                $"<tr><td class='stat'>{stats.AwayRushYards}</td> <td class='statName'>Rush Yards</td> <td class='stat'>{stats.HomeRushYards}</td> </tr>");
            sb.Append(
                $"<tr><td class='stat'>{stats.AwayPassYards}</td> <td class='statName'>Pass Yards</td> <td class='stat'>{stats.HomePassYards}</td> </tr>");
            sb.Append(
                $"<tr><td class='stat'>{stats.AwayTotalYardsGained}</td> <td class='statName'>Total Yards Gained</td> <td class='stat'>{stats.HomeTotalYardsGained}</td> </tr>");

            sb.Append(
                $"<tr><td class='stat'>{stats.AwayFirstDowns}</td> <td class='statName'>First Downs</td> <td class='stat'>{stats.HomeFirstDowns}</td> </tr>");

            sb.Append(
                $"<tr><td class='stat'>{stats.AwayTODifferential}</td> <td class='statName'>Turnover Diff</td> <td class='stat'>{stats.HomeTODifferential}</td> </tr>");

            sb.Append(
                $"<tr><td class='stat'>{stats.AwayThirdDowns}</td> <td class='statName'>3rd Down</td> <td class='stat'>{stats.HomeThirdDowns}</td> </tr>");
            sb.Append(
                $"<tr><td class='stat'>{stats.AwayFourthDowns}</td> <td class='statName'>4th Down</td> <td class='stat'>{stats.HomeFourthDowns}</td> </tr>");

            sb.Append(
                $"<tr><td class='stat'>{stats.AwayRedZones}</td> <td class='statName'>Red Zone</td> <td class='stat'>{stats.HomeRedZones}</td> </tr>");
            sb.Append(
                $"<tr><td class='stat'>{stats.AwayRedZoneFGs}</td> <td class='statName'>Red Zone FGs</td> <td class='stat'>{stats.HomeRedZoneFGs}</td> </tr>");
            sb.Append(
                $"<tr><td class='stat'>{stats.AwayRedZoneTDs}</td> <td class='statName'>Red Zone TDs</td> <td class='stat'>{stats.HomeRedZoneTDs}</td> </tr>");

            sb.Append(
                $"<tr><td class='stat'>{stats.AwayPenalties}</td> <td class='statName'>Penalties</td> <td class='stat'>{stats.HomePenalties}</td> </tr>");

            sb.Append(
                $"<tr><td class='stat'>{stats.AwaySacks}</td> <td class='statName'>Sacks</td> <td class='stat'>{stats.HomeSacks}</td> </tr>");
            sb.Append(
                $"<tr><td class='stat'>{stats.AwayInterceptions}</td> <td class='statName'>Interceptions</td> <td class='stat'>{stats.HomeInterceptions}</td> </tr>");

            sb.Append(
                $"<tr><td class='stat'>{stats.AwayRushTDs}</td> <td class='statName'>Rush TDs</td> <td class='stat'>{stats.HomeRushTDs}</td> </tr>");
            sb.Append(
                $"<tr><td class='stat'>{stats.AwayPassTDs}</td> <td class='statName'>Pass TDs</td> <td class='stat'>{stats.HomePassTDs}</td> </tr>");
            sb.Append(
                $"<tr><td class='stat'>{stats.AwayTotalTDs}</td> <td class='statName'>Total Offensive TDs</td> <td class='stat'>{stats.HomeTotalTDs}</td> </tr>");

            sb.Append("</tbody></table>");


            tableTeamStats.InnerHtml = sb.ToString();
        }