public bool ChangeCoachTeam(int teamid)
        {
            if (CurrentCoachRecord.TeamId == teamid)
            {
                return(false);
            }
            bool changed = false;
            bool exists  = false;

            if (teamid != 1009)
            {
                exists = CheckForExisitingCoach(CurrentCoachRecord.Position, teamid);
            }

            if (!exists)
            {
                if (model.CoachModel.CurrentCoachRecord.wasinstreamed)
                {
                    CoachRecord cr = (CoachRecord)model.TableModels[EditorModel.COACH_TABLE].CreateNewRecord(true);
                    cr = model.CoachModel.CurrentCoachRecord;
                    cr.wasinstreamed = false;
                    int id = cr.CoachId;
                    currentstreamedID = -1;
                    model.CoachModel.CurrentCoachRecord = GetCoachById(id);
                }

                model.CoachModel.CurrentCoachRecord.TeamId   = teamid;
                model.CoachModel.CurrentCoachRecord.LastTeam = teamid;
                ChangeCoachControl(CurrentCoachRecord.Position);
                changed = true;
            }

            return(changed);
        }
        public bool CheckForExisitingCoach(int newposition, int newteam)
        {
            bool exists = false;

            if (newteam == 1023 || newteam == 1009)    // free agents no need to check
            {
                return(false);
            }

            foreach (TableRecordModel rec in model.TableModels[EditorModel.COACH_TABLE].GetRecords())
            {
                if (rec.Deleted)
                {
                    continue;
                }
                CoachRecord coach = (CoachRecord)rec;
                if (coach.Position == newposition && coach.TeamId == newteam)
                {
                    exists = true;
                    break;
                }
            }

            if (exists)
            {
                MessageBox.Show("Team has an exisiting coach.\r\nPlease remove current coach for desired team", "Warning...", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(exists);
        }
        public CoachRecord GetPreviousCoachRecord()
        {
            CoachRecord record = null;

            int startingindex = currentCoachID;

            while (true)
            {
                currentCoachID--;
                if (currentCoachID == startingindex)
                {
                    //We have looped around
                    return(null);
                }

                if (currentCoachID < 0)
                {
                    currentCoachID = model.TableModels[EditorModel.COACH_TABLE].RecordCount;
                    continue;
                }

                record = (CoachRecord)model.TableModels[EditorModel.COACH_TABLE].GetRecord(currentCoachID);

                //If this record is marked for deletion then skip it
                if (record.Deleted)
                {
                    continue;
                }

                if (currentTeamFilter != null)
                {
                    if (!(model.TeamModel.GetTeamNameFromTeamId(record.TeamId).Equals(currentTeamFilter)))
                    {
                        continue;
                    }
                }
                if (currentPositionFilter != -1)
                {
                    if (record.Position != currentPositionFilter)
                    {
                        continue;
                    }
                }

                //Found one
                break;
            }

            return(record);
        }
 public void SetCoachTendency(CoachRecord record)
 {
     if (coachPassOff.Value <= 50 && coachOffAggression.Value <= 50)
     {
         OffTendency.SelectedIndex = 1;
         DefTendency.SelectedIndex = 1;
     }
     else if (coachPassOff.Value <= 50 && coachOffAggression.Value > 50)
     {
         OffTendency.SelectedIndex = 0;
         DefTendency.SelectedIndex = 0;
     }
     else if (coachPassOff.Value > 50 && coachOffAggression.Value <= 50)
     {
         OffTendency.SelectedIndex = 3;
         DefTendency.SelectedIndex = 3;
     }
     else if (coachPassOff.Value > 50 && coachOffAggression.Value > 50)
     {
         OffTendency.SelectedIndex = 2;
         DefTendency.SelectedIndex = 2;
     }
 }
        public CoachRecord GetCoachById(int id)
        {
            currentstreamedID = -1;
            currentCoachID    = -1;

            // we want to return the ROS/FRA coach record if it exists
            foreach (TableRecordModel record in model.TableModels[EditorModel.COACH_TABLE].GetRecords())
            {
                if (((CoachRecord)record).CoachId == id)
                {
                    currentCoachID = id;
                    CoachRecord cr = (CoachRecord)record;
                    return(cr);
                }
            }

            // Doesnt exist in ROS/FRA so let's see if it is in the streameddata coch table
            if (manager.stream_model != null)
            {
                foreach (TableRecordModel rec in manager.stream_model.TableModels[EditorModel.COACH_COLLECTIONS_TABLE].GetRecords())
                {
                    if (rec.Deleted)
                    {
                        continue;
                    }
                    CoachCollection coachc = (CoachCollection)rec;
                    if (coachc.CoachId == id)
                    {
                        currentstreamedID = id;
                        CoachRecord cr = SetCoachFromCollection(coachc);
                        return(cr);
                    }
                }
            }

            return(null);
        }
        public bool CheckCoaches(int Teamid)
        {
            List <CoachRecord> teamcoaches = new List <CoachRecord>();

            foreach (TableRecordModel recs in model.TableModels[EditorModel.COACH_TABLE].GetRecords())
            {
                if (recs.Deleted)
                {
                    continue;
                }

                CoachRecord c = (CoachRecord)recs;
                if (c.TeamId == Teamid && !teamcoaches.Contains(c))
                {
                    teamcoaches.Add(c);
                }
                else if (teamcoaches.Contains(c))
                {
                    recs.SetDeleteFlag(true);
                }
            }

            return(true);
        }
        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);
        }
 public void DeleteCoachRecord(CoachRecord record)
 {
     // TO DO : FINISH THIS
     record.SetDeleteFlag(true);
 }
        public CoachRecord SetCoachFromCollection(CoachCollection collection)
        {
            CoachRecord newcoach = (CoachRecord)model.TableModels[EditorModel.COACH_TABLE].CreateNewRecord(true);

            newcoach.wasinstreamed = true;

            newcoach.Age                 = collection.Age;
            newcoach.BodySize            = collection.BodySize;
            newcoach.Chemistry           = collection.Chemistry;
            newcoach.CoachId             = collection.CoachId;
            newcoach.ContractLength      = collection.ContractLength;
            newcoach.CareerLosses        = collection.CareerLosses;
            newcoach.PlayoffLosses       = collection.PlayoffLosses;
            newcoach.PlayoffsMade        = collection.PlayoffsMade;
            newcoach.PlayoffWins         = collection.PlayoffWins;
            newcoach.Cctc                = collection.Cctc;
            newcoach.CareerTies          = collection.CareerTies;
            newcoach.CareerWins          = collection.CareerWins;
            newcoach.WinningSeasons      = collection.WinningSeasons;
            newcoach.DefenseRating       = collection.DefenseRating;
            newcoach.DefensivePlaybook   = collection.DefensivePlaybook;
            newcoach.DefensiveAggression = collection.DefensiveAggression;
            newcoach.DefensiveStrategy   = collection.DefensiveStrategy;
            newcoach.Ethics              = collection.Ethics;
            newcoach.CPUDraftPlayer      = collection.CPUDraftPlayer;
            newcoach.CPUSignDraftPicks   = collection.CPUSignDraftPicks;
            newcoach.CPUControlled       = collection.CPUControlled;
            newcoach.CPUSignFreeAgents   = collection.CPUSignFreeAgents;
            newcoach.CPUFillRosters      = collection.CPUFillRosters;
            newcoach.cfhl                = collection.cfhl;
            newcoach.CPUResignPlayers    = collection.CPUResignPlayers;
            newcoach.CPUManageDepth      = collection.CPUManageDepth;
            newcoach.Cfsh                = collection.Cfsh;
            newcoach.UserControlled      = collection.UserControlled;
            newcoach.Char                = collection.Char;
            newcoach.height              = collection.height;
            newcoach.HeadHair            = collection.HeadHair;
            newcoach.Chsd                = collection.Chsd;
            newcoach.Chty                = collection.Chty;
            newcoach.Knowledge           = collection.Knowledge;
            newcoach.Name                = collection.Name;
            newcoach.LastTeamFranchise   = collection.LastTeamFranchise;
            newcoach.LastTeamRelocated   = collection.LastTeamRelocated;
            newcoach.Motivation          = collection.Motivation;
            newcoach.Offense             = collection.Offense;
            newcoach.Position            = collection.Position;
            newcoach.OffensiveAggression = collection.OffensiveAggression;
            newcoach.OffensiveStrategy   = collection.OffensiveStrategy;
            newcoach.CoachOfTheYear      = collection.CoachOfTheYear;
            newcoach.OffensivePlaybook   = collection.OffensivePlaybook;
            newcoach.FaceId              = collection.FaceId;
            newcoach.RBCarryDist         = collection.RBCarryDist;
            newcoach.CoachDB             = collection.CoachDB;
            newcoach.CoachDL             = collection.CoachDL;
            newcoach.KickerRating        = collection.CoachKS;
            newcoach.CoachLB             = collection.CoachLB;
            newcoach.CoachOL             = collection.CoachOL;
            newcoach.CoachPS             = collection.CoachPS;
            newcoach.CoachQB             = collection.CoachQB;
            newcoach.CoachRB             = collection.CoachRB;
            newcoach.CoachS              = collection.CoachS;
            newcoach.CoachWR             = collection.CoachWR;
            newcoach.Salary              = collection.Salary;
            newcoach.SuperBowlLoses      = collection.SuperBowlLoses;
            newcoach.SuperBowlWins       = collection.SuperBowlWins;
            newcoach.SkinColor           = collection.SkinColor;
            newcoach.Cspc                = collection.Cspc;
            newcoach.Coachpic            = collection.Coachpic;
            newcoach.CoachGlasses        = collection.CoachGlasses;
            newcoach.Cthg                = collection.Cthg;
            newcoach.WasPlayer           = collection.WasPlayer;
            newcoach.TeamId              = collection.TeamId;

            return(newcoach);
        }
        public void InitCoachList()
        {
            if (coachlist == null)
            {
                coachlist = new List <int>();
            }
            else
            {
                coachlist.Clear();
            }
            if (CoachNames == null)
            {
                CoachNames = new Dictionary <int, string>();
            }
            else
            {
                CoachNames.Clear();
            }
            Duplicates.Clear();
            currentstreamedID = -1;
            currentCoachID    = -1;

            if (FilterCoachTeam == -2)
            {
                if (manager.stream_model == null)
                {
                    return;
                }
                foreach (CoachCollection coll in manager.stream_model.TableModels[EditorModel.COACH_COLLECTIONS_TABLE].GetRecords())
                {
                    if (coll.Deleted)
                    {
                        continue;
                    }
                    else if (coll.TeamId == 1023 && !coachlist.Contains(coll.CoachId))
                    {
                        coachlist.Add(coll.CoachId);
                    }
                    else
                    {
                        continue;
                    }
                }

                coachlist.Sort();
                foreach (int i in coachlist)
                {
                    foreach (TableRecordModel rec in manager.stream_model.TableModels[EditorModel.COACH_COLLECTIONS_TABLE].GetRecords())
                    {
                        if (rec.Deleted)
                        {
                            continue;
                        }

                        CoachCollection coachcoll = (CoachCollection)rec;
                        if (i == coachcoll.CoachId && !CoachNames.ContainsKey(coachcoll.CoachId))
                        {
                            CoachNames.Add(coachcoll.CoachId, coachcoll.Name);
                        }
                    }
                }

                bool stop = true;
            }

            else
            {
                foreach (TableRecordModel rec in model.TableModels[EditorModel.COACH_TABLE].GetRecords())
                {
                    if (rec.Deleted)
                    {
                        continue;
                    }
                    else
                    {
                        bool        add   = false;
                        CoachRecord coach = (CoachRecord)rec;

                        if (FilterCoachTeam == -1 && FilterCoachPosition == -1)
                        {
                            add = true;
                        }

                        else if (FilterCoachPosition == -1 || FilterCoachTeam == -1)
                        {
                            if (FilterCoachPosition == -1 && FilterCoachTeam == coach.TeamId)
                            {
                                add = true;
                            }

                            else if (FilterCoachTeam == -1 && FilterCoachPosition == coach.Position)
                            {
                                //if (coach.TeamId >=0 && coach.TeamId <= 31)   // Most coaches are listed as head coaches
                                add = true;
                            }
                            else
                            {
                                continue;
                            }
                        }

                        else if (FilterCoachPosition == coach.Position && FilterCoachTeam == coach.TeamId)
                        {
                            add = true;
                        }

                        else
                        {
                            continue;
                        }

                        if (add)
                        {
                            if (!coachlist.Contains(coach.CoachId))
                            {
                                coachlist.Add(coach.CoachId);
                            }
                            else
                            {
                                if (!Duplicates.ContainsKey(coach.CoachId))
                                {
                                    Duplicates.Add(coach.CoachId, coach.Name);
                                }
                            }
                        }
                    }
                }


                coachlist.Sort();

                foreach (int i in coachlist)
                {
                    if (!CoachNames.ContainsKey(i))
                    {
                        CoachNames.Add(i, GetCoachById(i).Name);
                    }
                    else
                    {
                        if (!Duplicates.ContainsKey(i))
                        {
                            Duplicates.Add(i, GetCoachById(i).Name);
                        }
                    }
                }
            }
        }
Exemple #11
0
 public void UpdateCoach(CoachRecord rec)
 {
     this.AGE = rec.Age;
     this.BIGGEST_LOSS_MARGIN = rec.BiggestLossMargin;
     this.CBSZ = rec.BodySize;
     this.BIGGEST_WIN_MARGIN           = rec.BiggestWinMargin;
     this.ratings.CHEMISTRY            = rec.Chemistry;
     this.COACH_ID                     = rec.CoachId;
     this.CONTRACT_LENGTH              = rec.ContractLength;
     this.CAREER_LOSSES                = rec.CareerLosses;
     this.CAREER_LONGEST_LOSING_STREAK = rec.CareerLosingStreak;
     this.PLAYOFF_LOSSES               = rec.PlayoffLosses;
     this.PLAYOFFS_MADE                = rec.PlayoffsMade;
     this.CCPR                      = rec.Ccpr;
     this.PLAYFF_WINS               = rec.PlayoffWins;
     this.CCTC                      = rec.Cctc;
     this.CAREER_TIES               = rec.CareerTies;
     this.CAREER_WINS               = rec.CareerWins;
     this.WINNING_SEASONS           = rec.WinningSeasons;
     this.ratings.DEFENSE           = rec.DefenseRating;
     this.DEFENSIVE_PLAYBOOK        = rec.DefensivePlaybook;
     this.ratings.DEF_AGGR          = rec.DefensiveAggression;
     this.ratings.DEF_STRAT         = rec.DefensiveStrategy;
     this.DEFENSE_TYPE              = rec.DefenseType;
     this.CDWS                      = rec.Cdws;
     this.ratings.ETHICS            = rec.Ethics;
     this.CFCO                      = rec.cfco;
     this.DRAFT_PLAYER              = rec.CPUDraftPlayer;
     this.SIGN_DRAFT_PICKS          = rec.CPUSignDraftPicks;
     this.CFEX                      = rec.CPUControlled;
     this.SIGN_FREE_AGENTS          = rec.CPUSignFreeAgents;
     this.FILL_ROSTERS              = rec.CPUFillRosters;
     this.CFHL                      = rec.cfhl;
     this.RESIGN_PLAYERS            = rec.CPUResignPlayers;
     this.MANAGE_DEPTH              = rec.CPUManageDepth;
     this.CFSH                      = rec.Cfsh;
     this.USER_CONTROLLED           = rec.UserControlled;
     this.CHAR                      = rec.Char;
     this.HEIGHT                    = rec.height;
     this.HEADHAIR_ID               = rec.HeadHair;
     this.CHSD                      = rec.Chsd;
     this.CHTY                      = rec.Chty;
     this.ratings.KNOWLEDGE         = rec.Knowledge;
     this.LAST_TEAM                 = rec.LastTeam;
     this.NAME                      = rec.Name;
     this.CLTF                      = rec.LastTeamFranchise;
     this.CLTR                      = rec.LastTeamRelocated;
     this.ratings.MOTIVATION        = rec.Motivation;
     this.COAP                      = rec.Coap;
     this.COCI                      = rec.Coci;
     this.COCT                      = rec.Coct;
     this.CODA                      = rec.Coda;
     this.CODP                      = rec.Codp;
     this.COEX                      = rec.Coex;
     this.COFA                      = rec.Cofa;
     this.ratings.OFFENSE           = rec.Offense;
     this.COFR                      = rec.Cofr;
     this.COPL                      = rec.Copl;
     this.POSITION                  = rec.Position;
     this.CORP                      = rec.Corp;
     this.CORR                      = rec.Corr;
     this.ratings.OFF_AGGR          = rec.DefensiveAggression;
     this.ratings.OFF_STRAT         = rec.OffensiveStrategy;
     this.COACH_OF_THE_YEAR         = rec.CoachOfTheYear;
     this.CPAG                      = rec.Cpag;
     this.OFFENSE_PLAYBOOK_ID       = OFFENSE_PLAYBOOK_ID;
     this.FaceID                    = rec.FaceId;
     this.CPWS                      = rec.PlayoffWinStreak;
     this.APPROVAL_RATING           = rec.ApprovalRating;
     this.ratings.RB_CARRY_DIST     = rec.RBCarryDist;
     this.ratings.DB_RATING         = rec.CoachDB;
     this.ratings.DL_RATING         = rec.CoachDL;
     this.ratings.KICK_RATING       = rec.KickerRating;
     this.ratings.LB_RATING         = rec.CoachLB;
     this.ratings.OL_RATING         = rec.CoachOL;
     this.ratings.PUNT_RATING       = rec.PuntRating;
     this.ratings.QB_RATING         = rec.CoachQB;
     this.ratings.RB_RATING         = rec.CoachRB;
     this.ratings.S_RATING          = rec.CoachSafety;
     this.ratings.WR_RATING         = rec.CoachWR;
     this.CRWS                      = rec.Crws;
     this.CRYL                      = rec.Cryl;
     this.SALARY                    = rec.Salary;
     this.SUPERBOWL_LOSES           = rec.SuperBowlLoses;
     this.CSBS                      = rec.SuperBowlStreak;
     this.SUPERBOWL_WINS            = rec.SuperBowlWins;
     this.SKIN_COLOR                = rec.SkinColor;
     this.CSLM                      = rec.Cslm;
     this.SEASON_LOSSES             = rec.SeasonLosses;
     this.CSLS                      = rec.Csls;
     this.CSPA                      = rec.Cspa;
     this.CSPC                      = rec.Cspc;
     this.CSPF                      = rec.Cspf;
     this.SEASON_TIES               = rec.SeasonTies;
     this.SEASON_WINS               = rec.SeasonWins;
     this.SEASON_BIGGEST_WIN_MARGIN = rec.SeasonBigWin;
     this.SEASON_WINNING_STREAK     = rec.SeasonWinStreak;
     this.PORTRAIT                  = rec.Coachpic;
     this.COACH_GLASSES             = rec.CoachGlasses;
     this.CTHG                      = rec.Cthg;
     this.CWPL                      = rec.WasPlayer;
     this.CWST                      = rec.Cwst;
     this.CWWS                      = rec.Cwws;
     this.TEAM_ID                   = rec.TeamId;
 }
Exemple #12
0
        public void InitTeamView()
        {
            if (teamview != null)
            {
                teamview.Dispose();
            }

            teamview                     = new DataGridView();
            teamview.Bounds              = new Rectangle(new Point(1, 1), new Size(658, 760));
            teamview.MultiSelect         = false;
            teamview.RowHeadersVisible   = false;
            teamview.AutoGenerateColumns = false;
            teamview.ScrollBars          = ScrollBars.Vertical;
            teamview.Dock                = DockStyle.Fill;
            teamview.AllowUserToAddRows  = false;
            teamview.ColumnCount         = 10;

            teamview.Columns[0].Name     = "Team";
            teamview.Columns[0].Width    = 100;
            teamview.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
            teamview.Columns[1].Name     = "Owner";
            teamview.Columns[1].Width    = 50;
            teamview.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
            teamview.Columns[2].Name     = "Coach";
            teamview.Columns[2].Width    = 50;
            teamview.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
            teamview.Columns[3].Name     = "Draft";
            teamview.Columns[3].Width    = 50;
            teamview.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable;
            teamview.Columns[4].Name     = "Sign Picks";
            teamview.Columns[4].Width    = 70;
            teamview.Columns[4].SortMode = DataGridViewColumnSortMode.NotSortable;
            teamview.Columns[5].Name     = "Sign FA";
            teamview.Columns[5].Width    = 60;
            teamview.Columns[5].SortMode = DataGridViewColumnSortMode.NotSortable;
            teamview.Columns[6].Name     = "Fill Rosters";
            teamview.Columns[6].Width    = 70;
            teamview.Columns[6].SortMode = DataGridViewColumnSortMode.NotSortable;
            teamview.Columns[7].Name     = "Re-Sign";
            teamview.Columns[7].Width    = 60;
            teamview.Columns[7].SortMode = DataGridViewColumnSortMode.NotSortable;
            teamview.Columns[8].Name     = "Reorder";
            teamview.Columns[8].Width    = 60;
            teamview.Columns[8].SortMode = DataGridViewColumnSortMode.NotSortable;
            teamview.Columns[9].Name     = "Play";
            teamview.Columns[9].Width    = 50;
            teamview.Columns[9].SortMode = DataGridViewColumnSortMode.NotSortable;

            InitTeamPlayGames();

            foreach (TableRecordModel rec in model.TableModels[EditorModel.OWNER_TABLE].GetRecords())
            {
                OwnerRecord owner = (OwnerRecord)rec;
                //  coach controlled options are in the coach table, overrides anything set in the owner table
                if (owner.TeamId > 31)
                {
                    continue;
                }
                string teamname = owner.TeamName;
                string ownedby  = "CPU";
                if (owner.UserControlled)
                {
                    ownedby = "USER";
                }
                string coachcontrol   = "CPU";
                string draftplayer    = "CPU";
                string signpicks      = "CPU";
                string signfreeagents = "CPU";
                string fillrosters    = "CPU";
                string resignplayers  = "CPU";
                string reorderdepth   = "CPU";
                string playgames      = "NO";

                foreach (TableRecordModel record in model.TableModels[EditorModel.COACH_TABLE].GetRecords())
                {
                    CoachRecord crec = (CoachRecord)record;
                    if (owner.TeamId == crec.TeamId && crec.Position == 0) // Position 0 is Head coach
                    {
                        if (crec.UserControlled == true)
                        {
                            coachcontrol = "USER";
                            playgames    = "YES";
                        }
                        if (crec.CPUDraftPlayer == false)
                        {
                            draftplayer = "USER";
                        }
                        if (crec.CPUSignDraftPicks == false)
                        {
                            signpicks = "USER";
                        }
                        if (crec.CPUSignFreeAgents == false)
                        {
                            signfreeagents = "USER";
                        }
                        if (crec.CPUFillRosters == false)
                        {
                            fillrosters = "USER";
                        }
                        if (crec.CPUResignPlayers == false)
                        {
                            resignplayers = "USER";
                        }
                        if (crec.CPUManageDepth == false)
                        {
                            reorderdepth = "USER";
                        }

                        if (PlayGamesList[owner.TeamId].Contains(true))
                        {
                            playgames = "YES";
                        }
                        if (!PlayGamesList[owner.TeamId].Contains(true))
                        {
                            playgames = "NO";
                        }
                    }
                }

                string[] entry = { teamname, ownedby, coachcontrol, draftplayer, signpicks, signfreeagents, fillrosters, resignplayers, reorderdepth, playgames };
                teamview.Rows.Add(entry);
            }

            teamview.CellClick += teamview_CellClick;
            panel2.Controls.Add(teamview);
        }
Exemple #13
0
        public void ApplyChanges()
        {
            // set owner table for user/cpu controlled teams
            for (int o = 0; o < teamview.RowCount; o++)
            {
                TableRecordModel t     = model.TableModels[EditorModel.OWNER_TABLE].GetRecord(o);
                OwnerRecord      owner = (OwnerRecord)t;
                if ((string)teamview.Rows[o].Cells[1].Value == "USER")
                {
                    owner.UserControlled = true;
                }
                else
                {
                    owner.UserControlled = false;
                }

                foreach (TableRecordModel trm in model.TableModels[EditorModel.COACH_TABLE].GetRecords())
                {
                    CoachRecord crec = (CoachRecord)trm;
                    if (owner.TeamId == crec.TeamId && crec.Position == 0)      // Position 0 is Head coach
                    {
                        if ((string)teamview.Rows[o].Cells[2].Value == "USER")
                        {
                            crec.UserControlled = true;
                            crec.CPUControlled  = false;                        // not sure what this does, but it needs to be set as user controlled
                        }
                        else
                        {
                            crec.UserControlled = false;
                            crec.CPUControlled  = true;                         // again this needs to be set
                        }

                        if ((string)teamview.Rows[o].Cells[3].Value == "CPU")
                        {
                            crec.CPUDraftPlayer = true;
                            owner.DraftPlayers  = true;
                        }
                        else
                        {
                            crec.CPUDraftPlayer = false;
                            owner.DraftPlayers  = false;
                        }

                        if ((string)teamview.Rows[o].Cells[4].Value == "CPU")
                        {
                            crec.CPUSignDraftPicks = true;
                            owner.SignDraftPicks   = true;
                        }
                        else
                        {
                            crec.CPUSignDraftPicks = false;
                            owner.SignDraftPicks   = false;
                        }

                        if ((string)teamview.Rows[o].Cells[5].Value == "CPU")
                        {
                            crec.CPUSignFreeAgents = true;
                            owner.SignFreeAgents   = true;
                        }
                        else
                        {
                            crec.CPUSignFreeAgents = false;
                            owner.SignFreeAgents   = false;
                        }

                        if ((string)teamview.Rows[o].Cells[6].Value == "CPU")
                        {
                            crec.CPUFillRosters = true;
                            owner.FillRosters   = true;
                        }
                        else
                        {
                            crec.CPUFillRosters = false;
                            owner.FillRosters   = false;
                        }

                        if ((string)teamview.Rows[o].Cells[7].Value == "CPU")
                        {
                            crec.CPUResignPlayers = true;
                            owner.ResignPlayers   = true;
                        }
                        else
                        {
                            crec.CPUResignPlayers = false;
                            owner.ResignPlayers   = false;
                        }

                        if ((string)teamview.Rows[o].Cells[8].Value == "CPU")
                        {
                            crec.CPUManageDepth      = true;
                            owner.ReorderDepthCharts = true;
                        }
                        else
                        {
                            crec.CPUManageDepth      = false;
                            owner.ReorderDepthCharts = false;
                        }

                        if ((string)teamview.Rows[o].Cells[9].Value == "YES" && (string)teamview.Rows[o].Cells[1].Value == "USER")
                        {
                            if (model.FranchiseStage.CurrentStage < 7)  // No schedule exists while in training camp
                            {
                                return;
                            }

                            // Fix Scheduled Games
                            foreach (TableRecordModel sch in model.TableModels[EditorModel.SCHEDULE_TABLE].GetRecords())
                            {
                                ScheduleRecord sr = (ScheduleRecord)sch;
                                if (sr.WeekType != 25 && sr.WeekType != 0)  // regular and pre season
                                {
                                    continue;
                                }
                                if (owner.TeamId == sr.AwayTeam.TeamId || owner.TeamId == sr.HomeTeam.TeamId)
                                {
                                    TeamRecord team = model.TeamModel.GetTeamRecord(owner.TeamId);

                                    if (PlayALLGames_Checkbox.Checked)
                                    {
                                        sr.HumanControlled = true;
                                    }
                                    else if (PlayAwayGames_Checkbox.Checked && sr.AwayTeam.TeamId == owner.TeamId)
                                    {
                                        sr.HumanControlled = true;
                                    }
                                    else if (PlayHomeGames_Checkbox.Checked && sr.HomeTeam.TeamId == owner.TeamId)
                                    {
                                        sr.HumanControlled = true;
                                    }
                                    else if (PlayDIVGames_Checkbox.Checked)
                                    {
                                        if (team.TeamId != sr.HomeTeam.TeamId && team.DivisionId == sr.HomeTeam.TeamId)
                                        {
                                            sr.HumanControlled = true;
                                        }
                                        else if (team.TeamId != sr.AwayTeam.TeamId && team.DivisionId == sr.AwayTeam.DivisionId)
                                        {
                                            sr.HumanControlled = true;
                                        }
                                        else
                                        {
                                            sr.HumanControlled = false;
                                        }
                                    }
                                    else
                                    {
                                        sr.HumanControlled = false;
                                    }
                                }
                                else
                                {
                                    sr.HumanControlled = false;
                                }
                            }
                        }

                        break;
                    }
                }
            }
        }
Exemple #14
0
        public Coach(CoachRecord rec)
        {
            NAME                 = rec.Name;
            COACH_ID             = rec.CoachId;
            TEAM_ID              = rec.TeamId;
            POSITION             = rec.Position;
            LAST_TEAM            = rec.LastTeam;
            CONTRACT_LENGTH      = rec.ContractLength;
            SALARY               = rec.Salary;
            years_exp            = 0;
            USER_CONTROLLED      = rec.UserControlled;
            CPU_CONTROLLED       = rec.CPUControlled;
            CPU_DRAFT_PLAYER     = rec.CPUDraftPlayer;
            CPU_SIGN_DRAFT_PICKS = rec.CPUSignDraftPicks;
            CPU_SIGN_FREE_AGENTS = rec.CPUSignFreeAgents;
            CPU_FILL_ROSTERS     = rec.CPUFillRosters;
            CPU_RESIGN_PLAYERS   = rec.CPUResignPlayers;
            CPU_MANAGE_DEPTH     = rec.CPUManageDepth;
            if (POSITION == 0)
            {
                CPU_SIGN_COACHES = true;
            }
            else
            {
                CPU_SIGN_COACHES = false;
            }
            EGO              = 50;
            PATIENCE         = 50;
            KNOWLEDGE        = rec.Knowledge;
            SPENDING         = 50;
            LOYALTY          = 50;
            RISK             = 50;
            ETHICS           = rec.Ethics;
            MORALE           = 50;
            CHEMISTRY        = rec.Chemistry;
            DEFENSE          = rec.DefenseRating;
            DEF_AGGR         = rec.DefensiveAggression;
            DEF_STRAT        = rec.DefensiveStrategy;
            MOTIVATION       = rec.Motivation;
            OFFENSE          = rec.Offense;
            OFF_AGGR         = rec.OffensiveAggression;
            OFF_STRAT        = rec.OffensiveStrategy;
            RB_CARRY_DIST    = rec.RBCarryDist;
            DB_RATING        = rec.CoachDB;
            DL_RATING        = rec.CoachDL;
            K_RATING         = rec.CoachKS;
            LB_RATING        = rec.CoachLB;
            OL_RATING        = rec.CoachOL;
            P_RATING         = rec.CoachPS;
            QB_RATING        = rec.CoachQB;
            RB_RATING        = rec.CoachRB;
            S_RATING         = rec.CoachS;
            WR_RATING        = rec.CoachWR;
            HC_GM            = false;
            HC_OC            = false;
            HC_DC            = false;
            CanBeInterviewed = true;
            CanBeHired       = true;
            InPlayoffs       = false;

            History    = new Dictionary <int, CoachHistory>();
            Priorities = new Dictionary <int, Pri>();
            Interviews = new List <int>();
            Offers     = new Dictionary <int, Dictionary <int, double> >();
        }
Exemple #15
0
        public void EvaluateCoach(Coach ecoach, Team eteam)
        {
            double evaluation = 0;
            Team   coachteam  = null;

            if (ecoach.TEAM_ID != 1009 && ecoach.TEAM_ID != 1010 && ecoach.TEAM_ID != 1011)
            {
                coachteam = this.Teams[ecoach.TEAM_ID];
            }
            CoachRecord coachrec = model.CoachModel.GetCoachById(ecoach.COACH_ID);

            double cw_perc = 0;

            if (coachrec.CareerWins + coachrec.CareerLosses + coachrec.CareerTies != 0)
            {
                cw_perc = (double)(coachrec.CareerWins + coachrec.CareerTies / 2) / (coachrec.CareerWins + coachrec.CareerLosses + coachrec.CareerTies);
            }

            double po_perc = 0;

            if (coachrec.PlayoffWins + coachrec.PlayoffLosses != 0)
            {
                po_perc = (double)(coachrec.PlayoffWins / (coachrec.PlayoffWins + coachrec.PlayoffLosses));
            }

            double sb_perc = 0;

            if (coachrec.SuperBowlWins + coachrec.SuperBowlLoses != 0)
            {
                sb_perc = (double)(coachrec.SuperBowlWins / (coachrec.SuperBowlWins + coachrec.SuperBowlLoses));
            }

            double po_made = (double)coachrec.PlayoffsMade;

            double po_exp = 0;

            if (ecoach.years_exp != 0)
            {
                po_exp = (double)coachrec.PlayoffsMade / ecoach.years_exp;
            }

            double avg_wins = 0;

            if (ecoach.years_exp != 0)
            {
                avg_wins = (double)(coachrec.CareerWins / ecoach.years_exp);
            }

            double season         = 0;
            double previous       = 0;
            double season_playoff = 0;

            if (coachteam != null)
            {
                season = (double)(coachteam.team.SeasonWins + coachteam.team.SeasonTies / 2) / (coachteam.team.SeasonLosses + coachteam.team.SeasonTies / 2);
                // Previous Season Record
                previous = (double)(coachteam.team.PreviousSeasonWins + coachteam.team.PreviousSeasonTies / 2) / (coachteam.team.PreviousSeasonLosses +
                                                                                                                  coachteam.team.PreviousSeasonTies / 2);
                season_playoff = 0;
                if (coachteam.team.SeasonConfStanding <= 5)
                {
                    season_playoff += 500;
                }
            }

            LeagueStats league10 = GetTeamStatsAvg(10, -1);



            double probowlplayers = 0;

            #region Pro Bowl Players Bonus
            foreach (TableRecordModel rec in model.TableModels[EditorModel.PRO_BOWL_PLAYERS].GetRecords())
            {
                if (rec.Deleted)
                {
                    continue;
                }

                ProBowlPlayer pbp = (ProBowlPlayer)rec;
                if (pbp.TeamID != ecoach.TEAM_ID)
                {
                    continue;
                }

                if (ecoach.POSITION == 0)
                {
                    probowlplayers += .5;
                }
                if (ecoach.POSITION == 1 && pbp.Position <= 9)
                {
                    probowlplayers += 1;
                }
                if (ecoach.POSITION == 2 && pbp.Position >= 10 && pbp.Position <= 18)
                {
                    probowlplayers += 1;
                }
                if (ecoach.POSITION == 3 && pbp.Position >= 19)
                {
                    probowlplayers += 1;
                }
                if (ecoach.POSITION == 3 && pbp.Position <= 18)
                {
                    probowlplayers += .25;
                }
            }
            #endregion

            #region Loyalty/Patience for Current Coaches
            double loyalty  = 0;
            double patience = 0;
            if (ecoach.TEAM_ID == eteam.team.TeamId)
            {
                // Adjusting current staff with loyalty and patience
                // If this is not a HC, and there is an employed HC that Acts as GM
                // evaluate the coach using the HC ratings
                bool done = false;
                if (ecoach.POSITION != 0)
                {
                    if (eteam.Coaches.ContainsKey(0))
                    {
                        if (eteam.Coaches[0].CONTRACT_LENGTH > 0 && eteam.Coaches[0].HC_GM)
                        {
                            loyalty  = (double)eteam.Coaches[0].LOYALTY / 300;       // max bonus of 33%
                            patience = (double)eteam.Coaches[0].PATIENCE - 50 / 150; // max bonus +/- 33%
                            done     = true;
                        }
                    }
                }

                if (!done)
                {
                    // Owner/GM does the eval
                    loyalty  = (double)eteam.Owner_GM.LOYALTY / 300;       // max bonus of 33%
                    patience = (double)eteam.Owner_GM.PATIENCE - 50 / 150; // max bonus +/- 33%
                }
            }
            #endregion
        }
        public void LoadCoachInfo(CoachRecord record)
        {
            model.CoachModel.CurrentCoachRecord = record;

            if (record == null)
            {
                MessageBox.Show("No Records available.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            isInitialising = true;

            try
            {
                //Load Coach General info
                coachName.Text = record.Name;

                // TO FIX not working right for 2007
                // Shows Unemployed coaches and lists Positions as Head Coaches etc...
                // While team field is blank.  1009 = unemployed.
                coachesPositionCombo.Text = coachesPositionCombo.Items[record.Position].ToString();;


                TeamRecord team    = model.TeamModel.GetTeamRecord(record.TeamId);
                TeamRecord prvteam = model.TeamModel.GetTeamRecord(record.LastTeamFranchise);
                if (record.TeamId == 1023)      // have to fix this
                {
                    record.TeamId = 1009;
                }
                if (record.TeamId == 1009)
                {
                    CoachTeamCombo.Text    = "Free Agents";
                    coachPreviousTeam.Text = "Free Agents";
                }
                else
                {
                    CoachTeamCombo.SelectedItem    = (object)team;
                    coachPreviousTeam.SelectedItem = (object)prvteam;
                }

                coachAge.Value = (int)record.Age;

                // this isnt right for all versions
                foreach (Object obj in model.CoachModel.CoachSkinColor)
                {
                    if (((GenericRecord)obj).Id == record.SkinColor)
                    {
                        cbSkinColor.SelectedItem = obj;
                        break;
                    }
                }

                GetCoachHeight();

                WearsGlassesCheckbox.Checked  = record.CoachGlasses;
                FormerPlayer_Checkbox.Checked = record.WasPlayer;
                coachpic.Value           = (int)record.Coachpic;
                CoachFaceID_UpDown.Value = (int)record.FaceId;
                CoachHeadID_UpDown.Value = (int)record.HeadHair;
                coachSalary.Value        = (decimal)((double)record.Salary / 100.0);
                coachyearsleft.Value     = (int)record.ContractLength;
                Approval.Value           = (int)record.ApprovalRating;
                BodySize.Value           = (int)record.BodySize;

                CoachOff.Value          = (int)record.Offense;
                CoachDef.Value          = (int)record.DefenseRating;
                CoachSafetyUpDown.Value = (int)record.CoachS;
                coachQB.Value           = (int)record.CoachQB;
                coachRB.Value           = (int)record.CoachRB;
                coachWR.Value           = (int)record.CoachWR;
                coachOL.Value           = (int)record.CoachOL;
                coachDL.Value           = (int)record.CoachDL;
                coachLB.Value           = (int)record.CoachLB;
                coachDB.Value           = (int)record.CoachDB;
                coachKS.Value           = (int)record.CoachKS;
                coachPS.Value           = (int)record.CoachPS;

                //Win-Loss Records
                coachPlayoffWins.Value    = (int)record.PlayoffWins;
                coachPlayoffLoses.Value   = (int)record.PlayoffLosses;
                coachSuperbowlWins.Value  = (int)record.SuperBowlWins;
                coachSuperBowlLoses.Value = (int)record.SuperBowlLoses;
                coachWinningSeasons.Value = (int)record.WinningSeasons;
                coachCareerWins.Value     = (int)record.CareerWins;
                coachCareerLoses.Value    = (int)record.CareerLosses;
                coachCareerTies.Value     = (int)record.CareerTies;
                PlayoffsMade.Value        = (int)record.PlayoffsMade;
                coachSeasonWins.Value     = (int)record.SeasonWins;
                coachSeasonLosses.Value   = (int)record.SeasonLosses;
                coachSeasonTies.Value     = (int)record.SeasonTies;

                threeFourButton.Checked = false;
                fourThreeButton.Checked = false;

                if (model.FileVersion != MaddenFileVersion.Ver2019)
                {
                    if (record.DefenseType == 95)
                    {
                        fourThreeButton.Checked = true;
                    }
                    else if (record.DefenseType == 5)
                    {
                        threeFourButton.Checked = true;
                    }
                    else
                    {
                        // have seen this get corrupted, change it to 4-3
                        record.DefenseType      = 95;
                        fourThreeButton.Checked = true;
                    }
                }
                else
                {
                    threeFourButton.Enabled = false;
                    fourThreeButton.Enabled = false;
                }

                //Attributes
                coachEthics.Value        = (int)record.Ethics;
                coachKnowledge.Value     = (int)record.Knowledge;
                coachMotivation.Value    = (int)record.Motivation;
                coachChemistry.Value     = (int)record.Chemistry;
                coachPassOff.Value       = (int)record.OffensiveStrategy;
                coachRunOff.Value        = (int)(100 - record.OffensiveStrategy);
                coachPassDef.Value       = (int)record.DefensiveStrategy;
                coachRunDef.Value        = (int)(100 - record.DefensiveStrategy);
                rb2.Value                = (int)(100 - record.RBCarryDist);
                rb1.Value                = (int)(record.RBCarryDist);
                coachDefAggression.Value = record.DefensiveAggression;
                coachOffAggression.Value = record.OffensiveAggression;

                SetCoachTendency(record);

                coachDefensivePlaybook.Text = model.TeamModel.GetDEFPlaybook((int)record.DefensivePlaybook);
                coachOffensivePlaybook.Text = model.TeamModel.GetOFFPlaybook((int)record.OffensivePlaybook);

                // Set slider values to 0
                for (int i = 0; i < Enum.GetNames(typeof(PlayerDraftedPositions)).Length; i++)
                {
                    prioritySliders[i].Value          = 0;
                    priorityTypeSliders[i].Value      = 0;
                    priorityDescriptionLabels[i].Text = "";
                    prioritySliders[i].Enabled        = false;
                    priorityTypeSliders[i].Enabled    = false;
                }
                //Priorities (NOTE: Madden 2007-2008 don't have coach sliders)
                if (model.FileVersion >= MaddenFileVersion.Ver2007)
                {
                    if (tabcontrol.TabPages.Contains(tabPage2))
                    {
                        tabcontrol.TabPages.Remove(tabPage2);
                    }
                }
                else
                {
                    if (!tabcontrol.TabPages.Contains(tabPage2))
                    {
                        tabcontrol.TabPages.Add(tabPage2);
                    }

                    if (!record.wasinstreamed)
                    {
                        bool priorityMatches = false;
                        SortedList <int, CoachPrioritySliderRecord> priorites = null;
                        if (model.FileVersion <= MaddenFileVersion.Ver2006)
                        {
                            priorites = model.CoachModel.GetCurrentCoachSliders();
                            int priorityCount = Enum.GetNames(typeof(PlayerDraftedPositions)).Length;
                            priorityMatches = (priorityCount != priorites.Count);
                        }

                        if (!priorityMatches)
                        {
                            int index = 0;
                            foreach (CoachPrioritySliderRecord priorRecord in priorites.Values)
                            {
                                prioritySliders[index].Value          = priorRecord.Priority;
                                priorityTypeSliders[index].Value      = priorRecord.PriorityType;
                                priorityDescriptionLabels[index].Text = DecodePriorityType((PlayerDraftedPositions)index, priorRecord.PriorityType);
                                prioritySliders[index].Enabled        = true;
                                priorityTypeSliders[index].Enabled    = true;
                                index++;
                            }
                        }
                    }
                }

                if (model.FileVersion == MaddenFileVersion.Ver2019)
                {
                    coachAsset.Text     = record.Asset;
                    coachFirstName.Text = record.FirstName;
                    coachLastName.Text  = record.LastName;
                }
            }

            catch (Exception e)
            {
                MessageBox.Show("Exception Occured loading this Coach:\r\n" + e.ToString(), "Exception Loading Coach", MessageBoxButtons.OK, MessageBoxIcon.Error);
                LoadCoachInfo(lastLoadedRecord);
                return;
            }
            finally
            {
                isInitialising = false;
            }

            lastLoadedRecord = record;
            DisplayCoachPort();
            isInitialising = false;
        }